I have a sample code :
import java.awt.*;
import javax.swing.*;
import javax.swing.border.BevelBorder;
public class AWT extends JFrame {
public static void main(String[] args) {
final JFrame frame = new JFrame();
frame.setPreferredSize(new Dimension(600, 450));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBackground(Color.green.darker());
Button btn_1 = new Button("Button 1");
btn_1.setBackground(Color.green.darker());
btn_1.setSize(40, 100);
Button btn_2 = new Button("Button 2");
btn_2.setBackground(Color.green.darker());
btn_2.setSize(40, 100);
Button btn_3 = new Button("Button 3");
btn_3.setBackground(Color.green.darker());
btn_3.setSize(40, 100);
JPanel players = new JPanel(new GridLayout(1, 3));
players.add(btn_1);
players.add(btn_2);
players.add(btn_3);
players.setBackground(Color.green.darker());
players.setPreferredSize(new Dimension(450, 80));
JPanel game = new JPanel();
game.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
game.setBackground(Color.green);
game.setPreferredSize(new Dimension(600, 370));
JPanel content = new JPanel();
content.setLayout(new BorderLayout());
frame.setContentPane(content);
content.add(players, BorderLayout.NORTH);
content.add(game, BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true);
}
}
This as a result gives me such a window :
, while it should result in something more like this :
Why it is not rendering in this way ?