1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class MenuDep extends JFrame{
private PanneauDep container = new PanneauDep();
private JButton bouton1 = new JButton("Ajouter");
private JButton bouton2 = new JButton("Visualiser");
JOptionPane jop = new JOptionPane(), jop2 = new JOptionPane();
public MenuDep(){
this.setTitle("Départements");
this.setSize(400, 300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.add(container, BorderLayout.CENTER);
container.setLayout(new BorderLayout());
JPanel south = new JPanel();
south.add(bouton1);
south.add(bouton2);
container.add(south, BorderLayout.SOUTH);
this.setContentPane(container);
bouton1.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e){
String nom = JOptionPane.showInputDialog(null, "Veuillez décliner un département", "Ajouter un département", JOptionPane.QUESTION_MESSAGE);
JOptionPane.showMessageDialog(null, "Le département ajouté est " + nom, "Départements", JOptionPane.INFORMATION_MESSAGE);
}
});
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.setVisible(true);
}
} |
Partager