Thomas Mitchell
Thomas Mitchell

Reputation: 1071

Java multiple button size issue

I'm making a simple hobby piece that simply contains two buttons. When I try to set the size only one button, the work button, is set. This is true even if I comment out the play button code.

Here is the button creation code:

Container content = frame.getContentPane();
JButton workBtn = new JButton("Work");
JButton playBtn = new JButton("Play");
workBtn.setSize(100, 100);
playBtn.setSize(100, 100);
workBtn.setVisible(true);
playBtn.setVisible(true);
content.add(workBtn);
content.add(playBtn);

I'm guessing it's something simple but I just can't see what or find that out.

Upvotes: 1

Views: 133

Answers (1)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285405

JFrame contentPanes use BorderLayout by default. Read up on the layout managers to learn how to best use them to your advantage. You can find the link here.

Upvotes: 4

Related Questions