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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
public class ToolMenu extends JFrame implements ActionListener{
JPanel zone_outil= new JPanel();
JPanel zone_dyna = new JPanel();
JButton enregistrer = new JButton("ajouter personne");
JButton modifier = new JButton("modifier personne");
JButton chercher = new JButton("chercher personne");
JLabel clik_ajouter = new JLabel("EXECUTER AJOUTER");
JLabel clik_modifier = new JLabel("EXECUTER MODIFIER");
static Container contenu = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); // ou VERTICAL_SPLIT
public ToolMenu(String action)
{
this.setTitle("repertoire adresse");
this.setSize(800,600);
zone_outil.add(enregistrer);
zone_outil.add(modifier);
zone_outil.add(chercher);
enregistrer.addActionListener(this);
modifier.addActionListener(this);
chercher.addActionListener(this);
contenu.add(zone_outil);
zone_outil.setLayout(new GridLayout(3,5));
zone_dyna.setBackground(new Color(251, 222, 150));//couleur vert claire
zone_outil.setBackground(new Color(231, 247, 218));//couleur orange claire
contenu.add(zone_dyna);
if(action == "save")
{
this.a_cliquer();
}
if(action == "update")
{
this.a_modifier();
}
this.getContentPane().add(contenu);
// Ou juste this.add(contenu);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == enregistrer)
{
System.out.println("enregistrer le client");
zone_dyna.add(clik_ajouter);
}
if(e.getSource() == enregistrer)
{
System.out.println("enregistrer le client");
zone_dyna.add(clik_ajouter);
}
}
public void a_cliquer()
{
zone_dyna.add(clik_ajouter);
}
public void a_modifier()
{
zone_dyna.add(clik_modifier);
}
} |
Partager