Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanel using boxlayout  RSS feed

 
Chris Dancy
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!