File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Frustrated at GridBagLayout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Frustrated at GridBagLayout" Watch "Frustrated at GridBagLayout" New topic

Frustrated at GridBagLayout

jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
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
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
That is all you add.
addComponent( title , 0 , 4 , 1 , 1 );
You don't change title to the component you want to add.
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
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
Don't get me started about those stupid light bulbs.
subject: Frustrated at GridBagLayout
It's not a secret anymore!