File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JPanel using boxlayout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPanel using boxlayout" Watch "JPanel using boxlayout" New topic
Author

JPanel using boxlayout

Chris Dancy
Ranch Hand

Joined: Feb 14, 2006
Posts: 136
i cant seem to figure this out, or why it does this.

panel3 = new JPanel(new BoxLayout(panel3,BoxLayout.Y_AXIS));

This line of code does not work, it makes a awt error. yet when i type it this way:
panel3 = new JPanel();
panel3.setLayout(new BoxLayout(panel3, BoxLayout.Y_AXIS));

this works.
i dont get it. Can someone please explain this to me.


("Anger is not an emotion, its a symptom of fear.")
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
I don't think your Panel3 is instansiated on the first exampel. On the second example it works fine cause it has been instansiated.

// Mathias


SCJP1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPanel using boxlayout
 
Similar Threads
Problem adding JPanels to a box layout
Box.createVerticalGlue() not working! Help?
Why are my JFrames closing?
unable to remove spaces between buttons(making a calculator)
Alignment of RadioButtons