Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BoxLayout quirk

 
Eric Larsen
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does my my JLabel appear all the way on the right-hand side of my GUI?

The source code for the class:



Attached is a screenshot of the GUI output.

Wessenger_screen.JPG
The GUI and the offending JLabel at the top.
[Thumbnail for Wessenger_screen.JPG]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add these lines

usernamePane.setAlignmentX(0);
passwordPane.setAlignmentX(0);
buttonPane.setAlignmentX(0);

comment out this line
//buttonPane.add(Box.createHorizontalGlue());

and they'll all be left-aligned
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic