7,116 Posted Topics

Member Avatar for Hanyouslayer

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.

Member Avatar for Dougnukem
1
173
Member Avatar for pvt_geeker

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. …

Member Avatar for Ezzaral
0
91
Member Avatar for sachin.h
Member Avatar for David Boon
0
160
Member Avatar for faithingod1970

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.

Member Avatar for JamesCherrill
0
101
Member Avatar for sbhavan

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 …

Member Avatar for sbhavan
0
557
Member Avatar for synplace

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 …

Member Avatar for ~s.o.s~
0
93
Member Avatar for scias23

You should use the GregorianCalendar class, which implements the Calendar methods, which include setting a date from yy,mm,dd, comparing dates etc.

Member Avatar for scias23
0
107
Member Avatar for BOONISRIDHAR

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]

Member Avatar for BOONISRIDHAR
0
79
Member Avatar for harshinianu

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)

Member Avatar for JamesCherrill
0
85
Member Avatar for chuppy

[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 - …

Member Avatar for JamesCherrill
0
112
Member Avatar for dazzyg

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 …

Member Avatar for JamesCherrill
0
106
Member Avatar for fullgl

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, …

Member Avatar for amitrail
0
105
Member Avatar for TheWhite

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."

Member Avatar for JamesCherrill
0
134
Member Avatar for jooa

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.

Member Avatar for JamesCherrill
0
83
Member Avatar for coud_ren_26
Member Avatar for llemes4011

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 ?

Member Avatar for llemes4011
0
174
Member Avatar for jooa

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 …

Member Avatar for jooa
0
864
Member Avatar for suretd

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!

Member Avatar for CameronBevis
0
2K
Member Avatar for Master Piece

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)

Member Avatar for JamesCherrill
0
163
Member Avatar for caierhui

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.

Member Avatar for JamesCherrill
0
169
Member Avatar for and12

[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.

Member Avatar for VernonDozier
0
221
Member Avatar for jooa

Look at the main(...) method in the ReadingPixels class. It is an example of how to call/use the class.

Member Avatar for jooa
0
111
Member Avatar for arcticM

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 …

Member Avatar for JamesCherrill
0
83
Member Avatar for kelela

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 …

Member Avatar for JamesCherrill
0
149
Member Avatar for shanakaprabath

You can open your filewriter in "append" mode by changing it to new FileWriter("filename", true)

Member Avatar for javaAddict
0
88
Member Avatar for latinajoyce

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 …

Member Avatar for JamesCherrill
0
195
Member Avatar for latinajoyce

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.

Member Avatar for latinajoyce
0
96
Member Avatar for jooa

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 …

Member Avatar for jooa
0
2K
Member Avatar for idgirl
Member Avatar for idgirl
0
151
Member Avatar for Laidler

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.

Member Avatar for Laidler
0
141
Member Avatar for Xessa

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 …

Member Avatar for JamesCherrill
0
371
Member Avatar for gowth08

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) …

Member Avatar for CrazyDieter
0
94
Member Avatar for Laidler

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.

Member Avatar for Laidler
0
91
Member Avatar for Zibo
Member Avatar for quuba
0
2K
Member Avatar for jooa

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.

Member Avatar for quuba
0
206
Member Avatar for ndoe
Member Avatar for llemes4011

[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?

Member Avatar for llemes4011
0
207
Member Avatar for fred2

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 …

Member Avatar for fred2
0
153
Member Avatar for applefat

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.

Member Avatar for applefat
0
2K
Member Avatar for surima

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 …

Member Avatar for JamesCherrill
0
152
Member Avatar for ashish2234

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.

Member Avatar for TheWhite
0
112
Member Avatar for toucan

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() …

Member Avatar for JamesCherrill
0
182
Member Avatar for jonny_java
Member Avatar for jonny_java
0
114
Member Avatar for get2tk

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.

Member Avatar for JamesCherrill
0
140
Member Avatar for sotvisal

[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 …

Member Avatar for JamesCherrill
0
164
Member Avatar for ChangBroot

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]

Member Avatar for ChangBroot
0
372
Member Avatar for beshoyatef

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.

Member Avatar for JamesCherrill
0
120
Member Avatar for TheWhite

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 …

Member Avatar for TheWhite
0
197
Member Avatar for llemes4011

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.

Member Avatar for JamesCherrill
0
280
Member Avatar for titosd

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 …

Member Avatar for JamesCherrill
0
3K

The End.