Search Results

Search found 4035 results on 162 pages for 'extends'.

Page 31/162 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • Can ScalaCheck/Specs warnings safely be ignored when using SBT with ScalaTest?

    - by pdbartlett
    I have a simple FunSuite-based ScalaTest: package pdbartlett.hello_sbt import org.scalatest.FunSuite class SanityTest extends FunSuite { test("a simple test") { assert(true) } test("a very slightly more complicated test - purposely fails") { assert(42 === (6 * 9)) } } Which I'm running with the following SBT project config: import sbt._ class HelloSbtProject(info: ProjectInfo) extends DefaultProject(info) { // Dummy action, just to show config working OK. lazy val solveQ = task { println("42"); None } // Managed dependencies val scalatest = "org.scalatest" % "scalatest" % "1.0" % "test" } However, when I runsbt test I get the following warnings: ... [info] == test-compile == [info] Source analysis: 0 new/modified, 0 indirectly invalidated, 0 removed. [info] Compiling test sources... [info] Nothing to compile. [warn] Could not load superclass 'org.scalacheck.Properties' : java.lang.ClassNotFoundException: org.scalacheck.Properties [warn] Could not load superclass 'org.specs.Specification' : java.lang.ClassNotFoundException: org.specs.Specification [warn] Could not load superclass 'org.specs.Specification' : java.lang.ClassNotFoundException: org.specs.Specification [info] Post-analysis: 3 classes. [info] == test-compile == For the moment I'm assuming these are just "noise" (caused by the unified test interface?) and that I can safely ignore them. But it is slightly annoying to some inner OCD part of me (though not so annoying that I'm prepared to add dependencies for the other frameworks). Is this a correct assumption, or are there subtle errors in my test/config code? If it is safe to ignore, is there any other way to suppress these errors, or do people routinely include all three frameworks so they can pick and choose the best approach for different tests? TIA, Paul. (ADDED: scala v2.7.7 and sbt v0.7.4)

    Read the article

  • java : how to handle the design when template methods throw exception when overrided method not throw

    - by jiafu
    when coding. try to solve the puzzle: how to design the class/methods when InputStreamDigestComputor throw IOException? It seems we can't use this degisn structure due to the template method throw exception but overrided method not throw it. but if change the overrided method to throw it, will cause other subclass both throw it. So can any good suggestion for this case? abstract class DigestComputor{ String compute(DigestAlgorithm algorithm){ MessageDigest instance; try { instance = MessageDigest.getInstance(algorithm.toString()); updateMessageDigest(instance); return hex(instance.digest()); } catch (NoSuchAlgorithmException e) { LOG.error(e.getMessage(), e); throw new UnsupportedOperationException(e.getMessage(), e); } } abstract void updateMessageDigest(MessageDigest instance); } class ByteBufferDigestComputor extends DigestComputor{ private final ByteBuffer byteBuffer; public ByteBufferDigestComputor(ByteBuffer byteBuffer) { super(); this.byteBuffer = byteBuffer; } @Override void updateMessageDigest(MessageDigest instance) { instance.update(byteBuffer); } } class InputStreamDigestComputor extends DigestComputor{ // this place has error. due to exception. if I change the overrided method to throw it. evey caller will handle the exception. but @Override void updateMessageDigest(MessageDigest instance) { throw new IOException(); } }

    Read the article

  • J-Monkey subclass

    - by user2971104
    I'm new in java and J-monkey and I'm trying to make a java game so for the Menu I have made a enum so I can Switch between any of my State but I want to keep the main file shorter so it can be easily to read so I'm making subclass the problem is that when run the game it give me an error that say "Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main] NullPointerException" I think this problem has to be something whit the pipeline Here is the code of my main file: package mygame; import com.jme3.app.SimpleApplication; import com.jme3.font.BitmapText; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.renderer.RenderManager; import com.jme3.scene.Spatial; import com.jme3.scene.Geometry; import com.jme3.input.*; import com.jme3.input.controls.*; public class Main extends SimpleApplication { //GameStates enum GameState{Logo, Menu, Playing, Option}; GameState gameState = GameState.Logo; //Class Variables Logo logo; public Main() { logo = new Logo(); } public static void main(String[] args) { Main app = new Main(); app.start(); } public static void logo(String[] args) { Logo app = new Logo(); app.start(); } @Override public void simpleInitApp() { //Load flyCam.setMoveSpeed(20); if(gameState == GameState.Logo){ logo.simpleInitApp(); } } @Override public void simpleUpdate(float tpf) { } @Override public void simpleRender(RenderManager rm) { //TODO: add render code //Load if(gameState == GameState.Logo) { } } } And here is my Logo subclass: package mygame; import com.jme3.app.SimpleApplication; import com.jme3.renderer.RenderManager; import com.jme3.scene.Spatial; public class Logo extends SimpleApplication { @Override public void simpleInitApp() { Spatial Logo_Model = assetManager.loadModel("Models/Teapot/Logo.obj"); rootNode.attachChild(Logo_Model); } public void simpleRender(RenderManager rm) { //Load } }

    Read the article

  • How to call implemented method of generic enum in Java?

    - by Justin Wiseman
    I am trying pass an enum into a method, iterate over that enums values, and call the method that that enum implements on all of those values. I am getting compiler errors on the part "value.getAlias()". It says "The method getAlias() is undefined for the type E" I have attempted to indicate that E implements the HasAlias interface, but it does not seem to work. Is this possible, and if so, how do I fix the code below to do what I want? The code below is only meant to show my process, it is not my intention to just print the names of the values in an enum, but to demonstate my problem. public interface HasAlias{ String getAlias(); }; public enum Letters implements HasAlias { A("The letter A"), B("The letter B"); private final String alias; public String getAlias(){return alias;} public Letters(String alias) { this.alias = alias; } } public enum Numbers implements HasAlias { ONE("The number one"), TWO("The number two"); private final String alias; public String getAlias(){return alias;} public Letters(String alias) { this.alias = alias; } } public class Identifier { public <E extends Enum<? extends HasAlias>> void identify(Class<E> enumClass) { for(E value : enumClass.getEnumConstants()) { System.out.println(value.getAlias()); } } }

    Read the article

  • Webview shouldoverrideurlloading doesn't work

    - by Zak
    I have this code in my app: public class Home extends Activity{ @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.home); final ProgressDialog progressBar; if(isOnline()){ WebView webView = (WebView) findViewById(R.id.home_web); webView.setBackgroundColor(Color.parseColor(getString(R.color.colore_bg))); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setPluginsEnabled(true); webView.setWebViewClient(new MyWebViewClient()); progressBar = ProgressDialog.show(this,getString(R.string.caricamento),getString(R.string.attendere)); webView.setWebViewClient(new WebViewClient(){ public void onPageFinished(WebView view, String url) { if (progressBar.isShowing()) { progressBar.dismiss(); } } }); webView.loadUrl("http://www.mysite.com/android.php"); }else{ Toast.makeText(this,getString(R.string.no_connessione),Toast.LENGTH_LONG).show(); } } private class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { System.out.println("here"); if (Uri.parse(url).getHost().equals("mysite.com")) { // This is my web site, so do not override; let my WebView load the page return false; } // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } } public boolean isOnline(){ ConnectivityManager cm=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); if(ni==null){ return false; } return ni.isConnected(); } } The shouldOverrideUrlLoading doesn't work, neither print the system.out, it seems to be never called. How can I repair this? I need to open all the link (except the main page www.mysite.com/iphone.php) in the default browser

    Read the article

  • Multiple Exception Handling in one if statement [closed]

    - by JA3N
    I am having trouble with throwing and catching exceptions. Here is the code for assignSeat(), assignSeat is called in a try block in another class. void assignSeat(String passengerName, int x, int y) throws SeatOccupiedException, InvalidPassengerNameException { Seat tSeat = airplane.getSeat(x,y); if (tSeat!=null) { if (passengerName.isEmpty() || !passengerName.matches("[a-zA-Z]+")) { throw new InvalidPassengerNameException(); } //excluded else if else if (foundPassenger(passengerName)) { airplane.seatList.get(airplane.seatNumber(passengerName)).unOccupy(); tSeat.occupy(); for (int i = 0; i<passengers.size();i++) if (passengers.get(i).getName().equals(passengerName)) passengers.get(i).changeSeat(tSeat.getSeatName()); } else if (!tSeat.occupied) { tSeat.occupy(); addPassenger(passengerName, tSeat.getSeatName()); } else if (tSeat.occupied) { throw new SeatOccupiedException(); } } and here is the code that calls assignSeat() and is in another class (I won't copy the whole class to make it look clearer) if (afComp.currentAF != null) { try { afComp.currentAF.assignSeat(nameField.getText(), x, y); //<-Problem here, "Unhandled exception type SeatOccupiedException" } catch (SeatOccupiedException exception) //<-Problem here, "Unreachable catch block, This exception is never thrown from the try statement body" { } catch(InvalidPassengerNameException exception) //<-No problems. { } } Whats wrong with the try block? why won't it throw the SeatOccupiedException? Exception classes: SeatOccupied: package a2; public class SeatOccupiedException extends Exception { public SeatOccupiedException(){} } InvalidPassengerName: package a2; public class InvalidPassengerNameException extends Exception { public InvalidPassengerNameException() {} } Every class I have is in package a2 imports for class that calls assignSeat package a2; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.event.MouseEvent; import java.awt.BorderLayout; import javax.swing.*; import javax.swing.event.*; imports for class that has assignSeat package a2; import java.util.ArrayList;

    Read the article

  • ActionListener isn't Implementing

    - by Nick Gibson
    JFrameWithPanel is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener public class JFrameWithPanel extends JFrame implements ActionListener I Don't get this code. Book and Java site tells me this is the syntax for the method, but again this error shows up constantly. import javax.swing.*; import javax.swing.JOptionPane; import java.awt.*; import java.awt.event.*; import java.lang.Math.*; import java.lang.Integer.*; import java.util.*; import java.util.Random; import java.io.*; import java.text.*; import java.text.DecimalFormat.*; public class JFrameWithPanel extends JFrame implements ActionListener { JButton button = new JButton("Exit"); public JFrameWithPanel() { super("JFrame with Panel"); JComboBox packageChoice = new JComboBox(); packageChoice.addItem("A+ Certification"); packageChoice.addItem("Network+ Certification "); packageChoice.addItem("Security+ Certifictation"); packageChoice.addItem("CIT Full Test Package"); packageChoice.addActionListener(this); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel pane = new JPanel(); pane.add(button); pane.add(packageChoice); setContentPane(pane); setSize(200,100); setVisible(true); } } then later public class CreateJFrameWithPanel { public static void main(String[] args) { JFrameWithPanel panel = new JFrameWithPanel(); } }

    Read the article

  • Socket - Adress already in use

    - by Hamza Karmouda
    I'm new to socketand i try to code an Server and client on the same application just to see how it work. here's my code : public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ((Button)this.findViewById(R.id.bouton1)).setOnClickListener(this); } public void onClick(View v) { TCPServer server = new TCPServer(); TCPClient client = new TCPClient(); server.start(); client.start(); } public class TCPServer extends Thread { @Override public void run() { try { ServerSocket s = new ServerSocket(8080,0,InetAddress.getLocalHost()); Socket cli = s.accept(); byte[] b = new byte[512]; int n; InputStream is = cli.getInputStream(); while((n=is.read(b))>0){ Log.d("TCPServer",new String(b)); if(new String(b).contains("\r\n\r\n"))break; b = new byte[512]; } OutputStream os = cli.getOutputStream(); os.write("Hello".getBytes()); } catch (Exception e) { e.printStackTrace(); } } } public class TCPClient extends Thread { @Override public void run() { try { Socket s = new Socket(InetAddress.getLocalHost().getHostAddress(),8080); //Socket s = new Socket("www.google.com",80); //Log.i("",s.getLocalAddress().getHostAddress()); byte[] b = new byte[512]; int n; if (s.isConnected()) { OutputStream os = s.getOutputStream(); os.write("Hi How are you \r\n\r\n".getBytes()); InputStream is = s.getInputStream(); while((n=is.read(b))>0){ Log.d("TCPClient",new String(b)); b = new byte[512]; } } s.close(); } catch (Exception e) { e.printStackTrace(); } } } the code work fine but just for the first time i click my button. the error is java.net.BindException: Address already in use .

    Read the article

  • java - question about thread abortion and deadlock - volatile keyword

    - by Tiyoal
    Hello all, I am having some troubles to understand how I have to stop a running thread. I'll try to explain it by example. Assume the following class: public class MyThread extends Thread { protected volatile boolean running = true; public void run() { while (running) { synchronized (someObject) { while (someObject.someCondition() == false && running) { try { someObject.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } // do something useful with someObject } } } public void halt() { running = false; interrupt(); } } Assume the thread is running and the following statement is evaluated to true: while (someObject.someCondition() == false && running) Then, another thread calls MyThread.halt(). Eventhough this function sets 'running' to false (which is a volatile boolean) and interrupts the thread, the following statement is still executed: someObject.wait(); We have a deadlock. The thread will never be halted. Then I came up with this, but I am not sure if it is correct: public class MyThread extends Thread { protected volatile boolean running = true; public void run() { while (running) { synchronized (someObject) { while (someObject.someCondition() == false && running) { try { someObject.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } // do something useful with someObject } } } public void halt() { running = false; synchronized(someObject) { interrupt(); } } } Is this correct? Is this the most common way to do this? This seems like an obvious question, but I fail to come up with a solution. Thanks a lot for your help.

    Read the article

  • convert a textview, including those contents off the screen, to bitmap

    - by user623318
    Hi, I want to save(export) contents of MyView, which extends TextView, into a bitmap. I followed the code: [this][1]. It works fine when the size of the text is small. But when there are lots of texts, and some of the content is out of the screen, what I got is only what showed in the screen. Then I add a "layout" in my code: private class MyView extends TextView{ public MyView(Context context) { super(context); // TODO Auto-generated constructor stub } public Bitmap export(){ Layout l = getLayout(); int width = l.getWidth() + getPaddingLeft() + getPaddingRight(); int height = l.getHeight() + getPaddingTop() + getPaddingBottom(); Bitmap viewBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(viewBitmap); setCursorVisible(false); layout(0, 0, width, height); draw(canvas); setCursorVisible(true); return viewBitmap; } } Now the strange thing happened: The first time I invoke "export"(I use an option key to do that), I got contents only on the screen. When I invoke "export" again, I got complete contents, including those out of the screen. Why? How to "export" a view, including contents cannot be showed on the screen? Thank you! [1]: http://www.techjini.com/blog/2010/02/10/quicktip-how-to-convert-a-view-to-an-image-android/ this

    Read the article

  • DefaultTableCellRenderer getTableCellRendererComponent never gets called

    - by Dean Schulze
    I need to render a java.util.Date in a JTable. I've implemented a custom renderer that extends DefaultTableCellRenderer (below). I've set it as the renderer for the column, but the method getTableCellRendererComponent() never gets called. This is a pretty common problem, but none of the solutions I've seen work. public class DateCellRenderer extends DefaultTableCellRenderer { String sdfStr = "yyyy-MM-dd HH:mm:ss.SSS"; SimpleDateFormat sdf = new SimpleDateFormat(sdfStr); public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (value instanceof Date) { this.setText(sdf.format((Date) value)); } else logger.info("class: " + value.getClass().getCanonicalName()); return this; } } I've installed the custom renderer (and verified that it has been installed) like this: DateCellRenderer dcr = new DateCellRenderer(); table.getColumnModel().getColumn(2).setCellRenderer(dcr); I've also tried table.setDefaultRenderer( java.util.Date.class, dcr ); Any idea why the renderer gets installed, but never called?

    Read the article

  • retrieve image from gallery in android

    - by smsys
    I have created an Activity where i have a Button. By pressing the button an android Gallery opens. When i choose an image from the gallery it is shows it in an ImageView of my Activity but after choosing second time the following error occuring 01-13 17:55:25.323: ERROR/AndroidRuntime(14899): java.lang.OutOfMemoryError: bitmap size exceeds VM budget Here is the source code i am using: public class MyImage extends Activity { /** Called when the activity is first created. */ Gallery gallery; private Uri[] mUrls; String[] mFiles=null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); File images = Environment.getDataDirectory(); File[] imagelist = images.listFiles(); mFiles = new String[imagelist.length]; for(int i= 0 ; i< imagelist.length; i++) { mFiles[i] = imagelist[i].getAbsolutePath(); } mUrls = new Uri[mFiles.length]; for(int i=0; i < mFiles.length; i++) { mUrls[i] = Uri.parse(mFiles[i]); } Gallery g = (Gallery) findViewById(R.id.Gallery01); g.setAdapter(new ImageAdapter(this)); g.setFadingEdgeLength(40); } public class ImageAdapter extends BaseAdapter{ int mGalleryItemBackground; public ImageAdapter(Context c) { mContext = c; } public int getCount(){ return mUrls.length; } public Object getItem(int position){ return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent){ ImageView i = new ImageView(mContext); i.setImageURI(mUrls[position]); i.setScaleType(ImageView.ScaleType.FIT_XY); i.setLayoutParams(new Gallery.LayoutParams(260, 210)); return i; } private Context mContext; } }

    Read the article

  • Jersey, JAXB and getting an objectextending an abstract class as a parameter

    - by krajol
    I want to get an object as a parameter of a POST request. I got an abstract superclass that is called Promotion and subclasses Product and Percent. Here's how I try to get a request: @POST @Consumes(MediaType.APPLICATION_XML) @Produces(MediaType.APPLICATION_XML) @Path("promotion/") public Promotion createPromotion(Promotion promotion) { Product p = (Product) promotion; System.out.println(p.getPriceAfter()); return promotion; } and here's how I use JAXB in classes' definitions: @XmlRootElement(name="promotion") @XmlSeeAlso({Product.class,Percent.class}) public abstract class Promotion { //body } @XmlRootElement(name="promotion") public class Product extends Promotion { //body } @XmlRootElement(name="promotion") public class Percent extends Promotion { //body } So the problem now is when I send a POST request with a body like this: <promotion> <priceBefore>34.5</priceBefore> <marked>false</marked> <distance>44</distance> </promotion> and I try to cast it to Product (as in this case, fields 'marked' and 'distance' are from Promotion class and 'priceBefore' is from Product class) I get an Exception: java.lang.ClassCastException: Percent cannot be cast to Product. It seems like Percent is chosen as a 'default' subclass. Why is that and how can I get an object that is a Product?

    Read the article

  • GWT + Seam, cannot fetch scoped beans from gwt servlet in seam resource servlet.

    - by David Göransson
    Hello all I am trying to get session and conversation scoped beans to a gwt servlet in the seam resource servlet. I have a conversation scoped bean: @Name ("viewFormCopyAction") @Scope (ScopeType.CONVERSATION) public class ViewFormCopyAction {} and a session scoped bean: @Name ("authenticator") @Scope (ScopeType.SESSION) public class AuthenticatorAction {} There is a RemoteService interface: @RemoteServiceRelativePath ("strokesService") public interface StrokesService extends RemoteService { public Position getPosition (int conversationId); } with corresponding async interface: public interface StrokesServiceAsync extends RemoteService { public void getPosition (int conversationId, AsyncCallback callback); } and implementation: @Name ("com.web.actions.forms.gwt.client.StrokesService") @Scope (ScopeType.EVENT) public class StrokesServiceImpl implements StrokesService { @In Manager manager; @Override @WebRemote public Position getPosition (int conversationId) { manager.switchConversation( "" + conversationId ); ViewFormCopyAction vfca = (ViewFormCopyAction) Component.getInstance( "viewFormCopyAction" ); AuthenticatorAction aa = (AuthenticatorAction) Component.getInstance( "authenticator" ); return null; } } The gwt page is within an IFrame in a regular seam page and the conversationId is propagted with the src attribute of the IFrame. Both bean objects end up with only null values. Can anyone see anything wrong with the code? I know that I could use strings instead of the int, but never mind that at this point.

    Read the article

  • Backbone.js routes not firing

    - by drale2k
    I have a Base Router where i define some functions that need to be run everywhere. Every Router extends this Router. Now my problem is, that none of my routes defined in this Base router, actually fire. Every other route in other Routers work fine. I have created a test route called 'a' which calls method 'b', which should fire an alert but nothing happens. Here is the code: (This is Coffeescript, don't pay attention to the indentation, it's fine in my file) class Etaxi.Routers.Base extends Backbone.Router routes: 'register' : 'registerDevice' 'a' : 'b' b: -> alert "a" initialize: -> @registerDevice() unless localStorage.device_id? @getGeolocation() registerDevice: -> @collection = new Etaxi.Collections.Devices() @collection.fetch() view = new Etaxi.Views.RegisterDevice(collection: @collection) $('#wrapper').append(view.render().el) getGeolocation: -> navigator.geolocation.getCurrentPosition (position) -> lat = position.coords.latitude lng = position.coords.longitude #$('#apphead').tap -> # alert 'Position: ' + lat + " ," + lng So when i visit '/register' or '/a' it should fire the appropriate method but it does not. I wonder if it has something to do with the fact that other Router extend from this Router? Would be wired but it is the only thing i can think of because every other Router works fine.

    Read the article

  • Playframework sends 2 queries for fetched query

    - by MRu
    I currently have problems with the JPA at the play framework 1.2.4. I need to have a UserOptions model in a separate database and want to join it lazyly cause its only needed in one query. In this query I want to load the options eagerly and by searching I found out that can only be done by using a join query. If I use eager instead oder lazy, everything would be fine by using User.findById() and the options and the user is found in one query. But play sends two queries when I use a 'left join fetch' query. So heres the query: User.find(" SELECT user FROM User user LEFT JOIN FETCH user.options options WHERE user.id = ? ", Long.parseLong(id)).first(); And here the models: @Entity public class User extends Model { @OneToOne(mappedBy = "user", fetch = FetchType.LAZY) public UserOptions options; // ... } @Entity public class UserOptions extends Model { @OneToOne(fetch = FetchType.LAZY) public User user; } The question is why play sends two query for the fetch query? Thanks in advance

    Read the article

  • What could possibly be causing this NPE in onCreate?

    - by Adam Johns
    I am getting an NPE in onCreate of the following file (MySubActivity): public class MySubActivity extends MySuperActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); myTextView.setText(getResources().getString(R.string.myString)); } } MySuperActivity: public class MySuperActivity extends Activity { protected TextView myTextView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_layout); myTextView = (TextView)findViewById(R.id.myTextViewid); } } The strange thing is that I have never seen this crash while testing the app. The page works fine when I test it. However I got a crash report from Google notifying me of the crash. I cannot reproduce it, and I have no idea under what scenario this crash could happen. Seeing as how it works for me, the resource ids and string names etc. must be correct. The only thing that came across my mind was that maybe the user had their phone set to a different language, so it couldn't properly pull the resources. However, there are default resources for all of them, and I tested changing the language of my emulator and it didn't crash. Any ideas?

    Read the article

  • Clear listview content?

    - by Slash
    I have a little problem with listview. How do i clear a listview content, knowing that it has a custom adapter? edit : the custom adapter class extends BaseAdapter, it looks like this : import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; public class MyAdapter extends BaseAdapter { private Activity activity; private String[] data; private static LayoutInflater inflater=null; public MyAdapter(Activity _a, String[] _str) { activity = _a; data = _str; inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public static class ViewHolder{ public TextView text; } @Override public int getCount() { return data.length; } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View view, ViewGroup parent) { View v = view; ViewHolder holder; if(v == null) { v = inflater.inflate(R.layout.rowa, null); holder=new ViewHolder(); holder.text=(TextView)v.findViewById(R.id.dexter); v.setTag(holder); }else{ holder=(ViewHolder)v.getTag(); } holder.text.setText(data[position]); return v; } }

    Read the article

  • How should I link two items with MouseMovementListeners?

    - by user1708810
    I'm working on a program that will display two "views" of the same set of items. So I need to have something set up so that when the top down view is changed, the side view is updated (and vice versa). Here's a brief outline of the relevant code so you can get an idea of my structure so far: public class DraggableComponent extends JComponent { //Contains code for MouseMovementListener that makes the item draggable } public class ItemGraphic extends DraggableComponent { //Code to render the graphic } public class Item { private ItemGraphic topGraphic; private ItemGraphic sideGraphic; } I'm able to get each graphic to display fine in my GUI. I can also independently drag each graphic. I'm missing the "linking." Some ideas I've been thinking about: Have one listener for the whole GUI. Loop through each Item and if the cursor is within the bounds of either graphic, move the other graphic. I'm concerned about the efficiency of this method. Multiple "paired" listeners (not quite sure how this would work, but the idea is that each graphic would have a listener for the other paired graphic)

    Read the article

  • Using an empty column as a divider in a JTable.

    - by Catalina Island
    I'm trying to use an empty column as a divider between pairs of columns in a JTable. Here's a picture and code for what I have so far. I know I can change the look using a custom TableCellRenderer. Before I go down that road, is there a better way to do this? Any ideas appreciated. import javax.swing.*; import javax.swing.table.*; public class TablePanel extends JPanel { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame f = new JFrame("TablePanel"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.add(new TablePanel()); f.pack(); f.setVisible(true); } }); } public TablePanel() { TableModel dataModel = new MyModel(); JTable table = new JTable(dataModel); table.getColumnModel().getColumn(MyModel.DIVIDER).setMaxWidth(0); JScrollPane jsp = new JScrollPane(table); jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); this.add(jsp); } private static class MyModel extends AbstractTableModel { private static final int DIVIDER = 2; private final String[] names = { "A1", "A2", "", "B1", "B2" }; @Override public int getRowCount() { return 32; } @Override public int getColumnCount() { return names.length; } @Override public String getColumnName(int col) { if (col == DIVIDER) return ""; return names[col]; } @Override public Object getValueAt(int row, int col) { if (col == DIVIDER) return ""; return (row + 1) / 10.0; } @Override public Class<?> getColumnClass(int col) { if (col == DIVIDER) return String.class; return Number.class; } } }

    Read the article

  • Issue with the Entity Manager and phpunit in Symfony 2

    - by rgazelot
    I have an issue with my Entity Manager in phpunit. This is my test : public function testValidChangeEmail() { $client = self::createAuthClient('user','password'); $crawler = $client->request('GET', '/user/edit/30'); $crawler = $client->submit($crawler->selectButton('submit')->form(array( 'form[email]' => '[email protected]', ))); /* * With this em, this work perfectly * $em = $client->getContainer()->get('doctrine.orm.entity_manager'); */ $user = self::$em->getRepository('MyBundle:User')->findUser('[email protected]'); die(var_dump($user->getEmail())); } and this is my WebTestCase which extends original WebTestCase : class WebTestCase extends BaseWebTestCase { static protected $container; static protected $em; static protected function createClient(array $options = array(), array $server = array()) { $client = parent::createClient($options, $server); self::$em = $client->getContainer()->get('doctrine.orm.entity_manager'); self::$container = $client->getContainer(); return $client; } protected function createAuthClient($user, $pass) { return self::createClient(array(), array( 'PHP_AUTH_USER' => $user, 'PHP_AUTH_PW' => $pass, )); } As you can see, I replace the self::$em when I created my client. My issue : In my test, the die() give me the old email and not the new email ([email protected]) which has registered in the test. However in my database, I have the [email protected] correctly saved. When I retrieve my user in the database, I use sefl::$em. If I use the $em in comments, I retrieve the right new email. I don't understand why in my WebTestCase, I can access to the new Entity Manager...

    Read the article

  • Android :WindowManager$BadTockenException on Spinner Click

    - by Miya
    Hi, I have a spinner in my home.class. When I click on the spinner, the process is stopped showing exception that WindowManager$BadTockenException is caught. I am calling this home.class from main.class which extends ActivityGroup. If I am simply run only the home.class, the spinner is showing all items. But the problem is only with calling home.class from main.class. The following are my code. Please tell me why this is happened. main.class public class main extends ActivityGroup { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent=new Intent(this,home.class); View view=getLocalActivityManager().startActivity("1", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView(); setContentView(view); } } home.class String[] country={"Please selects","US","INDIA","UK"}; Spinner s2 = (Spinner) findViewById(R.id.spinnerCountry); ArrayAdapter<CharSequence> adapterCountry=new ArrayAdapter(this,android.R.layout.simple_spinner_item,country); adapterCountry.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); s2.setAdapter(adapterCountry); s2.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected( AdapterView<?> parent, View view, int position, long id) { countryName=country[position]; } public void onNothingSelected(AdapterView<?> parent) { countryName=country[0]; } }); Stack Thread [<1 main] (Suspended (exception WindowManager$BadTokenException)) AlertDialog(Dialog).show() line: 245 AlertDialog$Builder.show() line: 802 Spinner.performClick() line: 260 View$PerformClick.run() line: 9080 ViewRoot(Handler).handleCallback(Message) line: 587 ViewRoot(Handler).dispatchMessage(Message) line: 92 Looper.loop() line: 123 ActivityThread.main(String[]) line: 3647 Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method] Method.invoke(Object, Object...) line: 507 ZygoteInit$MethodAndArgsCaller.run() line: 839 ZygoteInit.main(String[]) line: 597 NativeStart.main(String[]) line: not available [native method] Thank You....

    Read the article

  • Binding a value to one of two possibilities in Guice

    - by Kelvin Chung
    Suppose I have a value for which I have a default, which can be overridden if System.getProperty("foo") is set. I have one module for which I have bindConstant().annotatedWith(Names.named("Default foo")).to(defaultValue); I'm wondering what the best way of implementing a module for which I want to bind something annotated with "foo" to System.getProperty("foo"), or, if it does not exist, the "Default foo" binding. I've thought of a simple module like so: public class SimpleIfBlockModule extends AbstractModule { @Override public void configure() { requireBinding(Key.get(String.class, Names.named("Default foo"))); if (System.getProperties().containsKey("foo")) { bindConstant().annotatedWith(Names.named("foo")).to(System.getProperty("foo")); } else { bind(String.class).annotatedWith(Names.named("foo")).to(Key.get(String.class, Names.named("Default foo"))); } } } I've also considered creating a "system property module" like so: public class SystemPropertyModule extends PrivateModule { @Override public void configure() { Names.bindProperties(binder(), System.getProperties()); if (System.getProperties().contains("foo")) { expose(String.class).annotatedWith(Names.named("foo")); } } } And using SystemPropertyModule to create an injector that a third module, which does the binding of "foo". Both of these seem to have their downsides, so I'm wondering if there is anything I should be doing differently. I was hoping for something that's both injector-free and reasonably generalizable to multiple "foo" attributes. Any ideas?

    Read the article

  • How can i split up a component using cfinclude and still use inheritance?

    - by rip747
    Note: this is just a simplized example of what i'm trying to do to get the idea across. The problem I'm having is that I want to use cfinclude inside cfcomponent so that i can group like methods into separate files for more manageability. The problem I'm running into is when i try to extend another component that also uses cfinclude to manage it's method as demostrated below. Note that ComponentA extends ComponentB: ComponentA ========== <cfcomponent output="false" extends="componentb"> <cfinclude template="componenta/methods.cfm"> </cfcomponent> componenta/methods.cfm ====================== <cffunction name="a"><cfreturn "componenta-a"></cffunction> <cffunction name="b"><cfreturn "componenta-b"></cffunction> <cffunction name="c"><cfreturn "componenta-c"></cffunction> <cffunction name="d"><cfreturn super.a()></cffunction> ComponentB ========== <cfcomponent output="false"> <cfinclude template="componentb/methods.cfm"> </cfcomponent> componentb/methods.cfm ====================== <cffunction name="a"><cfreturn "componentb-a"></cffunction> <cffunction name="b"><cfreturn "componentb-b"></cffunction> <cffunction name="c"><cfreturn "componentb-c"></cffunction> The issue is that when i try to initialize ComponentA I get an the error: "Routines cannot be declared more than once. The routine a has been declared twice in different templates." The whole reason for this is because when you use cfinclude it's evaluated at RUN TIME instead of COMPILE TIME. Short of moving the methods into the components themselves and eliminating the use of cfinclude, how can i get around this or does someone have a better idea splitting up large components?

    Read the article

  • What would be a better implementation of shared variable among subclass

    - by Churk
    So currently I have a spring unit testing application. And it requires me to get a session cookie from a foreign authentication source. Problem what that is, this authentication process is fairly expensive and time consuming, and I am trying to create a structure where I am authenticate once, by any subclass, and any subsequent subclass is created, it will reuse this session cookie without hitting the authentication process again. My problem right now is, the static cookie is null each time another subclass is created. And I been reading that using static as a global variable is a bad idea, but I couldn't think of another way to do this because of Spring framework setting things during run time and how I would set the cookie so that all other classes can use it. Another piece of information. The variable is being use, but is change able during run time. It is not a single user being signed in and used across the board. But more like a Sub1 would call login, and we have a cookie. Then multiple test will be using that login until SubX will come in and say, I am using different credential, so I need to login as something else. And repeats. Here is a outline of my code: public class Parent implements InitializingBean { protected static String BASE_URL; public static Cookie cookie; ... All default InitializingBean methods ... afterPropertiesSet() { cookie = // login process returns a cookie } } public class Sub1 extends Parent { @resource public String baseURL; @PostConstruct public void init() { // set parents with my baseURL; BASE_URL = baseURL; } public void doSomething() { // Do something with cookie, because it should have been set by parent class } } public class Sub2 extends Parent { @resource public String baseURL; @PostConstruct public void init() { // set parents with my baseURL; BASE_URL = baseURL; } public void doSomethingElse() { // Do something with cookie, because it should have been set by parent class } }

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >