package frameformetest;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MyFrameForme extends JFrame implements ActionListener {
private JButton fine;
private JButton b1;
private JButton b2;
private MyPanelForme disegno;
private static final long serialVersionUID = 1L;
public MyFrameForme () {
setTitle("Finestra con area con disegno");
setLayout(new BorderLayout());
fine = new JButton("Fine");
b1 = new JButton("Prossima");
b2 = new JButton("Precedente");
disegno = new MyPanelForme();
fine.addActionListener(this);
b1.addActionListener(this);
b2.addActionListener(this);
add(disegno, BorderLayout.CENTER);
JPanel bottoni = new JPanel();
bottoni.setLayout(new FlowLayout());
bottoni.add(b1);
bottoni.add(b2);
bottoni.add(fine);
add(bottoni, BorderLayout.SOUTH);
pack();
}
@Override
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() == b1) {
disegno.eseguiAzione1();
} else if (evt.getSource() == b2) {
disegno.eseguiAzione2();
} else if (evt.getSource() == fine) {
dispose();
}
}
}