Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes FlowLayout manager wont work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "FlowLayout manager wont work" Watch "FlowLayout manager wont work" New topic
Author

FlowLayout manager wont work

Ben Hultin
Ranch Hand

Joined: Aug 17, 2009
Posts: 135
I am trying to build multiple JFrames and give them a layout of FlowLayout but I am not able to get the FlowLayout to work. The JFrames are working fine but not the flowlayout. The JTextField also works but not the JLabel.

here is the code I have:



I am not getting any compilation errors so all objects and variables are initialized and found. I am not getting any nullPointerException either.

I appreciate the help
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

The code you have posted won't even compile and you expect us to figure out what's going wrong? Wow!

ItDoesntWorkIsUseless
TellTheDetails
PostRealCode

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ben Hultin
Ranch Hand

Joined: Aug 17, 2009
Posts: 135
ok i'll give you all the code, like I said, it does compile without any errors or exceptions.


Driver file:


Driven file:


I appreciate the help
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2177
    
    7
but I am not able to get the FlowLayout to work


Read the Swing tutorial on "How to Use Flow Layout" for a working example.

The FlowLayout is the easiest layout manager to use. We are not going to debug your program for you. Start by adding one component to the panel and add the panel to the frame. Once that works you add the second component. Once that works add the third.

Don't write your entire program up front. Do it one step at a time and make it more complex as each step works.

This is basic debugging.

To increase your chances of getting help you should create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour. (What you posted is NOT a SSCCE).
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

What Rob said.

In your oneJFrame() you got two mistakes.
1) You are calling the set visible and then adding the child components
2) You are not setting the layout to frame1
Ben Hultin
Ranch Hand

Joined: Aug 17, 2009
Posts: 135
Maneesh Godbole wrote:What Rob said.

In your oneJFrame() you got two mistakes.
1) You are calling the set visible and then adding the child components
2) You are not setting the layout to frame1



Thanks for the help, I already had one JFrame working just fine, but couldnt understand why the others wouldnt work. So thanks again for pointing out my problems.
 
jQuery in Action, 2nd edition
 
subject: FlowLayout manager wont work