• Post Reply Bookmark Topic Watch Topic
  • New Topic

JLabel and JTextField not showing up

 
Gulshan Singh
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing a simulation for thin lenses and their magnification properties. After I completed the basics of the simulation, I used the GUI Builder of Netbeans 6.9.1 to put in a JLabel and JTextField so the user can set the focal length of the lens (if you don't get the physics, don't worry about it. That's not the issue.) So Netbeans generated the code, but it doesn't show up on the screen. Here are my two classes:

LensSimulation - http://gsingh2011.pastebin.com/Sda2gMB5
DisplayCanvas - http://gsingh2011.pastebin.com/Y3v4TXbp

Why aren't the label and textfield showing up? Do I need to make a new panel?
 
Rob Spoor
Sheriff
Posts: 20816
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've modified that auto-created class manually, didn't you?
1) initComponents creates your GUI but it isn't called anywhere.
2) that method is missing the calls that actually add (hint: that's a method name) the text field and label to the panel.
 
Gulshan Singh
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:You've modified that auto-created class manually, didn't you?
1) initComponents creates your GUI but it isn't called anywhere.
2) that method is missing the calls that actually add (hint: that's a method name) the text field and label to the panel.


Wow, that was dumb. Yup, I modified it and accidentally deleted that part. Thanks, it works now.
 
Paper has not yet been outlawed – so let your Java Swing application print with wild abandon: JPDF
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!