7,116 Posted Topics
Re: Looks like your input data has a value that is not one of your enum constants. Try printing str.substring(4,6) immediately before the switch. | |
Re: With multiple frames it's usually a good idea to have a separate controller class (instance) that has methods for opening frames, hiding frames, switching between frames etc. If that class creates and opens the frames it will have references to them that it can use for setting their visibility etc. … | |
Re: Have a look at JavaFX [url]http://www.javafx.com/about/overview/[/url] | |
Re: JFrames are invisible until you explicitly make them visible. You have 2 constructors. If you call the first it adds labels but not buttons. If you call the second it adds buttons but not labels. You can't call both constructors for the same instance. | |
Re: Most versions of most OSs will (quite rightly) prevent you from overriding the user and plastering your stuff across his current window whenever you want. A"correct" way would be to have a notification area icon for your app and display a pop-up message next to the icon. From Java 6 … | |
Re: Postcodes and telephone numbers need to be localised. Date: is WorkingDay / isHoliday (also localised). Credit card number check digit. Are all these going to extend an abstract Validation class, or implement a Validation interface? What will the calling protocol look like? Will you use a return code or an … | |
Re: You should use the GregorianCalendar class, which implements the Calendar methods, which include setting a date from yy,mm,dd, comparing dates etc. | |
Re: Try these for starters [url]http://www.java-tips.org/java-se-tips/java.lang/how-to-execute-a-command-from-code.html[/url] [url]http://devdaily.com/java/edu/pj/pj010016/[/url] | |
Re: What kind of object is cellLabel[]? If its an array of JLabels you can add an icon to a JLabel (and you can derive the icon - which can be any size - from a jpeg file) | |
Re: [QUOTE=chuppy;962367]i used the Main() but there's no syntax error..why is that so?? sorry im very new to java..[/QUOTE] You can call your method (almost) anything you like. But if you want the JRE to run your application, you have to have a method with [I]exactly [/I]the right signature (name - … | |
Re: It looks to me like your problem comes from the class structure itself. The normal way to do this would be to declare an abstract class (eg "AbstractNode") and make SimpleNode and TreeNode subclasses of it. Your subnodes collection should be a collection of AbstractNodes; that way you can add … | |
Re: As you get each number you need to compare it with the current max and min values. If it's less than the current min, it becomes the new min, ditto for max. You can use Math.max if you like, it needs TWO parameters and returns the larger of the two, … | |
Re: The DJProject... [url]http://djproject.sourceforge.net/ni/index.html[/url] "The main focus of the Native Integration is on making rich client Java applications first class programs of the operating system. Currently, the DJ Project integrates JAR files to the Windows platform, with icon support and proper process management." | |
Re: At a quick look its only when mouseMoved calls showPixel that you have a problem with a null image. Since you can't do anything without an image I'd suggest modifying mouseMoved so that if image is null it just returns without doing anything. | |
Re: Please clarify: Do you want to start the program in the jar, the start a second program that accesses objects from the jar program or do you want to write one program that includes and uses the classes in the jar ? | |
Re: Here's a good starting point, but you'll have to adapt it to your specific code... [CODE]public static Image getImageFromArray(int[] pixels, int width, int height) { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); WritableRaster raster = (WritableRaster) image.getData(); raster.setPixels(0,0,width,height,pixels); return image; }[/CODE] ( adjust the image type (INT_RGB etc) as required … | |
Re: First error: it's saying there is no createStatement in the Connection class that takes a String as its parameter. Strangely enough, when I look at the API for Connection, that's what I find as well! | |
Re: Just before you print each letter, check to see if its greater than 'J', if it is, you can exit your program immediately (exit is a method in the System class) | |
Re: Try System.getProperty("user.home") this should give you the user's home directory, which is a good place to start when you want to write a file somewhere. | |
Re: [short version]: Java applets can't access the local file system without special permissions. Your applet should load any files you need from the server. | |
Re: Look at the main(...) method in the ReadingPixels class. It is an example of how to call/use the class. | |
![]() | Re: You put your class files into a jar file along with an extra file called a manifest in which you specify which class's main method you want to start with. The jar file can then be double-clcked to run the program. There's loads of info on the web, now you … |
Re: Separate class for the graph is OK. This code f.getContentPane().add(new ChartPanel(values, names, "Principle/Interest")); is where you call your class to create the graph. You call it twice, and it looks like you only have data set up for the second call? I suggest you add a some temporary print statements … | |
Re: You can open your filewriter in "append" mode by changing it to new FileWriter("filename", true) | |
Re: It's [B]never [/B]a good idea to code Java using an ASCII table. Java is Unicode, and many countries regularly use letters that are not in the first 127 positions. To convert a character that may be anything such that any lower case letter is replaced by its upper case equivalent … | |
Re: Re above. Class names should begin with a capital letter. Class name and file name MUST match for a [B]public [/B]class. int num, temp, sum; is perfectly good Java. int num int temp int sum is not valid. It needs a semicolon at the end of each line. | |
Re: Here (basically unedited) is some code from an old program I wrote that allows an object to be dragged around the screen. Perhaps you can use it as a start point? [CODE=JAVA] private int startDragX, startDragY; private boolean draggable = false, dragging = false, dragged = false; public void mousePressed(MouseEvent … | |
Re: No semicolon between [I][B]public void init([/B][/I]) and [B][I]{[/I][/B] | |
Re: You will have to maintain 3 variables in which you keep the number of things actually stored in each array. This is one of the many reasons why people tend to use ArrayLists rather than naked arays. | |
Re: To understand this you need to be clear about the difference between an object and a reference variable. myConnection and myResultSet are not objects, they are reference variables. Either they hold a reference to an object of the appropriate type, or their value is null. There is no way you … | |
Re: map.put(new X(1,2),"some value") ...creates a new X and uses it as the key map.get(new X(1,2)) ...creates ANOTHER new X (uses the same values as the first one, but it's still a different instance, and therefore != the first one) and tries to find it in the map but (of course) … | |
Re: Your method calls need to be in some kind of method - maybe the constructor. You can't just have them lying around in the class definition like that. | |
Re: I don't think this is possible, but if you find a way please do post it here! | |
Re: grabPix = new GrabPixels(); BufferedImage img = GrabPixels.img; First line calls default constructor, which does nothing, so img is not initialised. Second line then tries to use img. | |
Re: [QUOTE=~s.o.s~;950062] [*]Why use Vectors when you have ArrayLists?[/QUOTE] Vectors are synchronised, and a bit shorter to type. Why use ArrayLists when you have Vectors? | |
Re: Your code will not display the database table because you have not even attempted to write any code to access the table. So read about how to access SQL data from Java (documented extensively on the net), give it a try. When you get stuck come back here with your … | |
Re: Maybe I don't understand your problem... but public static methods on public Classes can be referenced from anywhere; you dont need to pass anything. In C you can just say A.getData(); or B.getData(); whenever you want. | |
Re: I really don't like all these hacks based on the internal representation of chars, and what about the non-alphanumeric chars that sit in spaces between the alphabetics in ASCII/Unicode? Here's a good Java way to do it: Create a char array containing all the valid symbols you want to use … | |
Re: In reposnse to a the buttons actionevent, get the curently selected row's number, add 1, selec that row. See JTable and DefaultListSelectionModel in the API. | |
Re: This whole loop-with-a- sleep-in-it polling approach is a poor way to go, even if you get it to work. You want your thread to go into a wait state and wait passively until notified to exit the wait, which it should do without further dalay. Have a look at wait() … | |
Re: Try moving the declaration of x outside the if test; abc x = null; if(flag) { x = new abc(); } ... | |
Re: The exception tells you you have an unitialised variable on line 373 of ClientPanel (in method actionPerformed). Look at that line and work out which variable it is. If you're not sure, print them all to see which is null. | |
Re: [CODE]public void getMatrice(int row,int col,int[][] a) { int[][] b=new int[row][col]; for(int i=0;i<row;i++) for(int j=0;j<col;j++) { b[i][j]=readInt("Enter A["+i+","+j+"]: "); } }[/CODE] I don't know what you intended this to do, but it won't do it. You create a new array "b" (local to this method), carefully fill it with values, then … | |
Re: Most Java text components support HTML, so simply use HTML tags to control fonts, colors etc [url]http://java.sun.com/docs/books/tutorial/uiswing/components/html.html[/url] | |
Re: Use your IDE, or put print statements into your code so you can find out which methods are / are not being called when you expect. | |
Re: This comes up quite often, and keeping a list of open socket threads and broadcasting in a loop [B]is [/B]the right way to go. You'll need to remove socket threads from the list when the sockets close (or fail), and that's quite likely to happen when you try to send … | |
Re: Put a second identical JFrame directly underneath it, fill with black, make it 50% translucent, shift it 10 pixels down & right. See [url]http://www.pushing-pixels.org/?p=260[/url] for details on translucent windows. | |
Re: No, I don't think you can do that. I think you will need to create a Hashtable with all the valid String color names as the keys and the actual Color instances as the values. Then you can simply get(...) the Color instance associated with the String you have got … |
The End.