import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; public class Buttons extends JPanel { private static final long serialVersionUID = 1L; public Buttons() { JPanel buttons = new JPanel(new GridLayout(4,1)); buttons.setSize(100, 200); buttons.add(new JLabel("Typ:")); JButton kolkoButton = new JButton("Kolko"); kolkoButton.setToolTipText("Rysuj kolko"); kolkoButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ Paint.aktualnaFigura = Figura.KOLKO; } }); buttons.add(kolkoButton); JButton kreskaButton = new JButton("Kreska"); kreskaButton.setToolTipText("Rysuj kreske"); kreskaButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ Paint.aktualnaFigura = Figura.KRESKA; } }); buttons.add(kreskaButton); JButton prostokatButton = new JButton("Prostokat"); prostokatButton.setToolTipText("Rysuj prostokat"); prostokatButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ Paint.aktualnaFigura = Figura.PROSTOKAT; } }); buttons.add(prostokatButton); this.setSize(100,200); this.add(buttons); } }