import java.awt.*; import javax.swing.*; class PanelDemo2 extends JFrame { PanelDemo2() { setSize(400,200); JPanel northpanel = new JPanel(); northpanel.setLayout(new GridLayout(1,2)); JPanel buttons = new JPanel(); buttons.setLayout(new GridLayout(1,3)); buttons.add(new JButton("1")); buttons.add(new JButton("2")); buttons.add(new JButton("3")); northpanel.add(buttons); // add to left half of northpanel // put a TextField into the right part of northpanel northpanel.add(new TextField("Här kan man läsa och skriva")); add(northpanel, BorderLayout.NORTH); // all of northpanel is added to the frame JLabel test = new JLabel("$"); test.setOpaque(true); // to see the color test.setBackground(Color.yellow); add(test, BorderLayout.EAST); add(new JScrollBar(), BorderLayout.WEST); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public static void main(String[] a) { new PanelDemo2(); } }