Reputation: 109
I have two JPanel's that i was to be in the top left corner but for some reason they are half way down the y axis (but still left, so 0 in x axis). I'll post my code here anyway, i think its easier to understand my problem then. Thanks in advance for any help.
JFrame scrabbleBoard = new JFrame();
scrabbleBoard.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container topPane = scrabbleBoard.getContentPane();
topPane.setLayout(new BoxLayout(topPane, BoxLayout.X_AXIS));
JButton done = new JButton ("Done");
JLabel player1 = new JLabel ("Player 1");
topPane.add(player1);
topPane.add(done);
scrabbleBoard.pack();
scrabbleBoard.setVisible(true);
Upvotes: 1
Views: 65
Reputation: 159784
Use:
done.setAlignmentY(Component.TOP_ALIGNMENT);
player1.setAlignmentY(Component.TOP_ALIGNMENT);
See: Fixing Alignment Problems
Upvotes: 4