Forum: Java 26 Days Ago |
| Replies: 7 Views: 587 Right now you don't have your Listener(s) set up to do anything. You need to either have:
One listener for both buttons. Within that listener, use getSource() to figure out which button... |
Forum: Java 26 Days Ago |
| Replies: 7 Views: 587 Then you need another JTextField, unless you are using the same JTextField for both the answer and the question (which is fine). Right now you only have one JTextField. So decide where the input... |
Forum: Java 26 Days Ago |
| Replies: 7 Views: 587 Frame and Panel are Java classes. You may want to rename your classes to make it less confusing, or at least be careful and make sure you don't get them mixed up.
What do you want to have done... |
Forum: Java 29 Days Ago |
| Replies: 4 Views: 322 I see nothing in the spec that requires any long-term non-volatile data storage. You enter the input every time you run the program. When the program is over, the input data is gone and the output... |
Forum: Java 33 Days Ago |
| Replies: 4 Views: 322 Yes, many here can solve it. But you need to show your attempt and ask a specific question. If you do, many people will be happy to help.
http://www.daniweb.com/forums/announcement9-2.html |
Forum: Java 34 Days Ago |
| Replies: 4 Views: 276 One, your class is named Main3, not Main1, so make sure your html file points to the actual class file. I renamed the class to Main1 and compiled it. When I did, it created Main1.class, but it also... |
Forum: Java 34 Days Ago |
| Replies: 4 Views: 276 Looks fine to me. You need to get the error message. Does it work when you run it on a local machine? Try putting Main2.class and the html page in the same folder on your local hard drive and... |
Forum: Java Oct 14th, 2009 |
| Replies: 6 Views: 238 Yes to all of the above. Java can do all of this, or at least it probably can since I don't know what GST is. I don't know that it's worth learning Java just to do that, but you could certainly... |
Forum: Java Oct 5th, 2009 |
| Replies: 4 Views: 206 You can combine the top code and the bottom code and get...
for (int i = 0; i < cdList.length; i++)
System.out.println(cdList[i].getArtist() + " " + cdList[i].getTitle() + " " +... |
Forum: Java Oct 5th, 2009 |
| Replies: 3 Views: 349 http://www.daniweb.com/forums/thread227475.html |
Forum: Java Oct 4th, 2009 |
| Replies: 10 Views: 394 Define "value". Your CD class doesn't have a data member called "value". It has "Cost". Is that "value"?
If you're adding up all the Costs, you can have a static variable in your CD class. You... |
Forum: Java Sep 27th, 2009 |
| Replies: 28 Views: 1,124 ONE for-loop. ONE do-while loop inside of that for-loop. Here's a skeleton:
// create an output file and open it.
int numTrials = 20;
for (int i = 0; i < numTrials; i++) // this is... |
Forum: Java Sep 27th, 2009 |
| Replies: 28 Views: 1,124 You have an infinite loop here. counter never gets adjusted.
You need to step back and look at your program and do a redesign. For 20 trials, you will generate far more than 20 random numbers. ... |
Forum: Java Sep 27th, 2009 |
| Replies: 28 Views: 1,124 From your assignment spec:
Create a new project called 5.06 Monte Carlo Method in the
Mod05 Assignments folder.
Create a class called BottleCapPrize in the newly created
project folder.
... |
Forum: Java Sep 26th, 2009 |
| Replies: 12 Views: 898 I take this quote from post 5 back (can't edit it - darn you, 30 minute limit!). This loop isn't going to work.
for(int side1 = 0; counterTrials <= numberOfRolls; counterTrials++)
You... |
Forum: Java Sep 26th, 2009 |
| Replies: 12 Views: 898 The example in my last post doesn't use arrays. You could turn a regular for-loop into a nested for-loop like this:
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
//... |
Forum: Java Sep 26th, 2009 |
| Replies: 12 Views: 898 That's better. The whole program can be redesigned significantly. One, use arrays.
Two,
The probability of any given side of the die being face-up after a single roll is one divided by the... |
Forum: Java Sep 23rd, 2009 |
| Replies: 4 Views: 250 If you intend to use the sqrt function from the Math class, the compiler has no idea that that is what you intend unless you specify that. Otherwise, it looks for a sqrt function in the class that... |
Forum: Java Sep 23rd, 2009 |
| Replies: 4 Views: 250 Lines 9, 13, 17 - These functions are not void. They must return something.
Line 21 - I assume that TestComplex is not intended to be an inner class. If not, you need a bracket to end the... |
Forum: Java Sep 22nd, 2009 |
| Replies: 2 Views: 251 Well, not seeing the rest of the code, it's speculation, but I imagine you want to make the row variable a global class variable rather than a local variable, initialize it to 0 ONCE in your... |
Forum: Java Sep 22nd, 2009 |
| Replies: 7 Views: 444 public class Hotel {
// Dinamic size(array)
private room[] array_of_rooms;
// Class constructor
public Hotel(int size)
{
// Here is all OK
array_of_rooms = new room[size];
//... |
Forum: Java Sep 20th, 2009 |
| Replies: 3 Views: 329 Well, you know ahead of time that for a 6 letter word, you have 2^6 = 64 possibilities. You could have the function return an array of Strings. Have a loop that goes from 0 to 63 (or 127, 255,... |
Forum: Java Sep 19th, 2009 |
| Replies: 7 Views: 444 I don't understand what <...CLASS CONSTRUCTOR...> and <... END OF CLASS CONSTRUCTOR...> refer to. You have a room constructor inside of a static function that returns an array of room? |
Forum: Java Sep 16th, 2009 |
| Replies: 3 Views: 375 It's been a while for me, but I imagine NumberFormat might be helpful, as well as printf from the Console class.
http://java.sun.com/docs/books/tutorial/i18n/format/numberintro.html... |
Forum: Java Sep 15th, 2009 |
| Replies: 3 Views: 284 You have no System.out.println statements in either the functions themselves or the calling statements. You create the String you want to display to the screen, but never display the String. Since... |
Forum: Java Sep 13th, 2009 |
| Replies: 4 Views: 460 Well, if putting it in the inner loop gives you too many lines, try putting it in the outer loop instead. Step back and look. How many lines do you want? How many times does it go through the... |
Forum: Java Sep 13th, 2009 |
| Replies: 4 Views: 460 Code tags:
// paste code here
//for loop
for (line=1; line <=height; line++) |
Forum: Java Sep 8th, 2009 |
| Replies: 2 Views: 728 This is a perfect candidate for a 4 x 4 GridLayout.
http://java.sun.com/docs/books/tutorial/uiswing/layout/grid.html
http://java.sun.com/javase/6/docs/api/java/awt/GridLayout.html |
Forum: Java Sep 5th, 2009 |
| Replies: 2 Views: 408 private static int ageCalc(int mm, int dd, int yyyy){
// code
birthDate.set(yyyy, mm, dd);
I'd have to see the function call, but if you are doing this:
ageCalc (9, 3, 1991) |
Forum: Java Aug 31st, 2009 |
| Replies: 4 Views: 383 One, doubling the capacity of an array should have its own function. Display should be in a separate function. Makes things easier to follow. Two, you don't double the array's capacity anywhere in... |
Forum: Java Aug 31st, 2009 |
| Replies: 4 Views: 469 I can't imagine that these two lines in red are doing anything good:
void display(String string) {
phrase = string;
pan.display(phrase);
add(pan);
repaint();
} |
Forum: Java Aug 30th, 2009 |
| Replies: 9 Views: 617 When in doubt, try it out. Does it compile? Does it run? Does it give good results? |
Forum: Java Aug 30th, 2009 |
| Replies: 4 Views: 383 Here's your main function. Nothing happens because your main function creates an array and does nothing with it. You never actually CALL your function, which you would need to do if you want that... |
Forum: Java Aug 29th, 2009 |
| Replies: 9 Views: 617 It's gotta be the Driver/Tester/main function code. Make it obvious and take it all the way out of your class and put it in another class:
public class Driver
{
public static void... |
Forum: Java Aug 29th, 2009 |
| Replies: 9 Views: 617 Code tags:
// paste code here |
Forum: Java Aug 27th, 2009 |
| Replies: 4 Views: 547 I imagine you want to use drawString from Graphics.
http://java.sun.com/javase/6/docs/api/java/awt/Graphics.html
You'll need to turn what you want to display into a String and pass that String,... |
Forum: Java Aug 23rd, 2009 |
| Replies: 5 Views: 309 If your website server is unreliable, you can always test/run your applet locally on your own computer. Getting the syntax correct can be a major hassle till you get the hang of it (not sure I... |
Forum: Java Aug 22nd, 2009 |
| Replies: 4 Views: 341 You're welcome. Sorry you didn't notice it in time.
Regarding the Layout, I looked at it, but couldn't figure out how to give good advice that didn't require a complete overhaul of the program. ... |
Forum: Java Aug 21st, 2009 |
| Replies: 7 Views: 816 Set up a Key Listener and have that Key Listener look out for that Hot Key and then do whatever (in your case, minimize)? Notsure if that's what you have in mind.
... |
Forum: Java Aug 19th, 2009 |
| Replies: 4 Views: 341 Put this line at the bottom of actionPerformed:
validate ();
That way you want have to minimize, maximize, etc.
Regarding the Layout, I haven't had a chance to look at that yet. |