-
Replied To a Post in Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Did you really mean to add the same JPanel both to another JPanel and an JFrame? You seem to have a BorderLayout on your frame (see 82) yet I found … -
Replied To a Post in Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException:
99% of problems like this come down to Java looking for the file in the wrong place. (or at least not the place you expected). Check out the File API … -
Replied To a Post in Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException:
Don't you have any package specified for your code? -
Replied To a Post in Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException:
Almost certainly a problem with the path to the jpeg (assuming the jpeg itself is OK). That form of reference works well and requires a "resouces" folder to be in … -
Undeleted a Post in Checked and unchecked exceptions
I just showed how an IllegalArgumentException is created and thrown. Because it's an unchecked exception you can handle it (via `try`/`catch` or by declaring your method as `throws IllegalArgumentException`) or … -
Deleted a Post in Checked and unchecked exceptions
I just showed how an IllegalArgumentException is created and thrown. Because it's an unchecked exception you can handle it (via `try`/`catch` or by declaring your method as `throws IllegalArgumentException`) or … -
Replied To a Post in exception Message is not showing
The message is not showing because you have not written any code to show it. In your catch block, instead of printing "wrong" you should print the exception. -
Replied To a Post in Checked and unchecked exceptions
I just showed how an IllegalArgumentException is created and thrown. Because it's an unchecked exception you can handle it (via `try`/`catch` or by declaring your method as `throws IllegalArgumentException`) or … -
Replied To a Post in Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException:
Exactly which line does the error message point to? -
Replied To a Post in Checked and unchecked exceptions
void setPrice(double newPrice) throws IllegalArgumentException { if (price < 0.0) throw new IllegalArgumentException("Price must be >= 0.0"); ... ... } Now calling setPrice with a negative parameter will result in … -
Replied To a Post in Checked and unchecked exceptions
That has absolutely NOTHING to do with Exceptions. The method needs an `int` parameter, and you passsed a `double`. You use an IllegalArgumentException when the parameter is of the right … -
Replied To a Post in Checked and unchecked exceptions
Without seeing the program it's impossible to say. Post the code and the error message -
Gave Reputation to JeffGrigg in java exception handling
There is compile-time checking of your exception handling logic to verify that your code follows the rules of checked exception handling. If your code has clear and obvious errors in … -
Replied To a Post in Checked and unchecked exceptions
ArrayStoreException extends RuntimeException, so it's unchecked IllegalArgumentException extends RuntimeException, so it's unchecked Simply.... if it extends RuntimeException or Error it's unchecked, otherwize it's checked. > The unchecked exception classes are … -
Replied To a Post in increase/decrease text size
JTextField will fit to the text in it when you pack() its container (more precisely: it updates its preferred size to fit the text, and the layout manager uses that). -
Replied To a Post in Event handlers: which event class and which event listener interface
Yes, it's not easy to se the inherited members in particular. It would be great to have an (optional) mode in which all the available methods were listed (with parameters … -
Replied To a Post in java exception handling
Did you read my previous post??? An exception can only be thrown at run time. There is no such thing as a "compile time exception". Where did you read about … -
Replied To a Post in How to make a constructor visible?
No, they are package access by default, justlike ordinary methods. The error message refers to a constructor with a `long` parameter, but the only constructor takes an `int`. Creation or … -
Replied To a Post in Event handlers: which event class and which event listener interface
In the API doc look for adddXXXListener methods. Don't forget to check all the methods in the "Methods inherited from class XXX" sections. eg JButton has no such methods of … -
Replied To a Post in Server split message and save data on a text file
1. Multi-threaded server for multiple concurrent clients: see http://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html (don't miss the bit about multiple clients towards the end) 2. Splitting the message - just use String's `split` method. If … -
Replied To a Post in java exception handling
There's no such thing as a "compile time exception" in Java. There is no instance of that term anywhere in the Java language Specification. The compiler will check that your … -
Replied To a Post in Applet Paint Method
You cannot create an onbect of an abstarct class. The code I showed you earlier prints the actual class of the "g" parameter that was passed to you. In my … -
Replied To a Post in code wont compile right
"JohnDoe" and "CheckingAccount" are Strings, you have to enclose them in double quote marks. -
Replied To a Post in change content pane colour program, first stab
SELECTED is a public static variable in the ItemEvent class, so the second version is preferred. (You can access static members fromn an instance, but it's considered bad practice) -
Replied To a Post in change content pane colour program, first stab
Yes, although the ActionEvent solution avoids the if test, and is the one you will most often see in ordinary use. -
Replied To a Post in change content pane colour program, first stab
You can query the ItemEvent with getStateChange(), which returns ItemEvent.SELECTED or ItemEvent.DESELECTED If you use an ActionEvent it's just the same as responding to a click in an ordinary button … -
Replied To a Post in use threading to delay a page for 5 seconds
Everything to do with Swing (eg painting the screen, running actionPerformed methods) happens on a single thread - the "Event Dispatch Thread", or "EDT", or "Swing thread". That means that … -
Replied To a Post in im not a cheater
OK. Nobody here thinks you are a cheater, so don't worry. People suggested that the "complete solution" that someone else posted could be an encouragement to cheat, but nobody suggested … -
Replied To a Post in code wont compile right
Your getters & setters seem OK. Was he referring to lines 86, 90, 94? Those are hard-coded values where presumably you are expected to prompt the user to input a … -
Replied To a Post in returning a value from JButton
The problem is in the sequence of events... You check the inputs and set the boolean when the user clicks the button, but you check the value as part of … -
Replied To a Post in change content pane colour program, first stab
Beware of itemListener. You get two events, one for the previous button being de-selected and one for the new button being selected. Your code works becuase you receive those two … -
Replied To a Post in How to get all member varible values in bean class
`pd.getReadMethod()` gives you a `Method` object that represents a "get" method for the Bean. You can call the Method object's `invoke` method to execute the "get" method it represents and … -
Replied To a Post in Applet Paint Method
You can print the actual class of the Graphics parameter inside your paint method, eg System.out.println(g.getClass()); and you will see something like (using a JFrame under Windows) "class sun.java2d.SunGraphics2D", which … -
Replied To a Post in Applet Paint Method
Yes, you're right, It's really a subclass of Graphics2D -
Replied To a Post in Applet Paint Method
The actual parameter that is passed to your paint method will be an instance of `Graphics2D` - which is a concrete subclass of `Graphics`. ps: If you previous posts have … -
Replied To a Post in calculate the grades for a student using if..else statements.
Hi Rachelle, welcome to DaniWeb. Please take a moment to familiarise yourself with the site rules http://www.daniweb.com/community/rules in particular, don't hijack old threads - start your own for a new … -
Replied To a Post in Applet Confusion
class Location { double longitude, latitude; public Location(double longitude, double latitude) { this.longitude = longitude; this.latitude = latitude; } @Override public String toString() { return longitude + " " + … -
Gave Reputation to sepp2k in Applet Confusion
That's not really true. The compiler will know whether you're using `java.awt.Color` regardless of whether or not you use an import. All the import does is to allow you to … -
Replied To a Post in Applet Confusion
When the compiler is compiling the Component class, its source code will have an `import java.awt.Color;` or somesuch as part of its definition. That tells the compiler that Component class … -
Replied To a Post in Who call Applets methods
http://docs.oracle.com/javase/tutorial/java/concepts/inheritance.html http://docs.oracle.com/javase/tutorial/deployment/applet/index.html -
Replied To a Post in Who call Applets methods
Yes indeed. In fact the complete inheritance tree for JApplet is java.lang.Object java.awt.Component java.awt.Container java.awt.Panel java.applet.Applet javax.swing.JApplet ... and so JApplet inhertits methods from all those classes -
Replied To a Post in Need research material to allow connections and data transfer between comps
Hi Mike, welcome back! Hope you're fully better now. Did you see the Oracle tutorial on client/serve sockets? It's definitive... http://docs.oracle.com/javase/tutorial/networking/sockets/index.html JC -
Replied To a Post in Who call Applets methods
Remember also that your class extends JApplet, and you inherit all JApplet's methods and can call them directly. -
Replied To a Post in get the selected from jradiobutton
Did you add the action listener to your radio buttons? I can't see the code for that in what you posted. -
Replied To a Post in get the selected from jradiobutton
What exactly is your question? ps: You do not want to open a new database connection every time the user presses "next/suivant". Just do it once, as part of the … -
Replied To a Post in Need help
> constructs a Rectangle object Read the API documentation for the Rectangle class - especially its constructors > calls to translate and grow should ... these two methods are also … -
-
Replied To a Post in What are the prerequisites for learning Java?
Access to a computer and the internet. Reasonable logical intelligence. Willingness to work. Time. -
Replied To a Post in Writing an Opportunity card game
I know nothing of Opportunity, but for 10% chance you use Math.random() to get a random double >= 0.0 and < 1.0 Something like if (Math.random() < .10) // draw … -
Replied To a Post in String input through constructor
I just showed you the print so you could see how the split method returns its results (and see that it is working), that's all.
The End.