public Gui2() { setTitle("My First Gui"); setSize(600, 600); setLocation(100, 100); setDefaultCloseOperation(EXIT_ON_CLOSE); pane = getContentPane(); // pane.setLayout(new GridLayout(3,3)); pane.setLayout(new FlowLayout()); b1 = new JButton("Click me"); b1.addActionListener(this); pane.add(b1); b2 = new JButton("exit"); b2.addActionListener(this); pane.add(b2); labeler = new JButton("Labeler"); labeler.addActionListener(this); pane.add(labeler); label = new JLabel("The Label:"); pane.add(label); box = new JCheckBox("Cap"); pane.add(box); text = new JTextArea(); text.setColumns(40); text.setRows(5); text.setBorder(BorderFactory.createLineBorder(Color.red, 2)); text.addKeyListener(new Key()); pane.add(text); canvas = new Canvas(); canvas.setPreferredSize(new Dimension(300, 300)); canvas.setBorder(BorderFactory.createLineBorder(Color.blue, 2)); pane.add(canvas); }