Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Frustrated at GridBagLayout

 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing a GUI application that takes in two fractions and does a different mathmatical operations on them. I decided to give a shot at GridBagLayout, since I hadn't ever used it before. I pretty much followed an example in Deitel & Deitel for setting up the constraints, etc. Here is the relevant code:
The problem is when the application Frame comes up, all I get is one giant JLabel saying "Rational Math". No other components show up! I have been able to duplicate Sun's tutorial example of the layout, and it worked perfectly. I then went into the example and started changing things to match my application, and it worked as expected. I've sat here and compared line by line, and I can't see anything wrong.
Any ideas why this is happening?
Thanks in advance
Jason
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is all you add.
addComponent( title , 0 , 4 , 1 , 1 );
You don't change title to the component you want to add.
DOH
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OH MY GOD. I can't believe I totally did not see that. Well, there's a lesson for you, don't cut and paste your code, type the whole thing out!
Someone please slap me really hard. That's what I get for trying to code AND rebuild a crashed server at the same time. At least the server's working correctly. Too bad I care more about Java
Thanks Paul, I swear I kind of know what I am doing.
Jason "Who just saw Legally Blonde last night and doesn't think it's funny that his friends compare him to it" Adam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic