Hey guys, I'm working on this small program. Just recently I started working on the GUI aspect of it. I have no idea what's going on, I'm using eclipse and it will randomly add the components correctly and sometimes it won't even add them. So I decided to make it add the panels and the JButtons in the methods that they were declared in. That fixed the issue for the panels and JButtons (I don't know why though). Now for the JComboBox's and the JLabel's. I still don't understand it will randomly work sometimes and sometimes it won't do anything with them. The program does run through every method correctly (I used a logger).
This is about as small as i could make it. IF you import this into your Eclipse (Just get rid of the packaging and add your own main() method). You'll see what I'm talking about.
We don't all use Eclipse or in fact an IDE in general.
add your own main() method
The code you post should be copy and paste which means you should add the main() method so we don't have to.
Without running the code I noticed the following:
Components should be added to the frame BEFORE the frame is made visible. Change the location of the createPanels() method. Also, I believe the setResizable should be done before the setVisible().
Generally you would also use pack() instead of setSize() so all components are displayed at their preferred sizes.
posted 9 years ago
1) I was just giving a recommendation if someone does use eclipse. They could get a better idea.
2) I suppose I guess adding a main() method would make it easier for you guys, just felt a little lazy considering the fact that it's about 3 lines of code. I'll add one next time.
I don't think there is anything in your code or your question that required use of, understanding of, or even mention of the IDE you are using or that others might use to sample the function of your code. The code should work the same no matter the process to get from *.java to *.class files. Sometimes there's too much focus on the programming process to the exclusion or confusion of the programming fundamentals by both those seeking help and those offering it.
Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad: