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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
public class Fenetre extends JFrame implements ActionListener {
private JMenuBar barreMenus;
private JMenu file, edit, help;
private JMenuItem open, close, cut, copy, about;
JLabel jLabelMatlab =new JLabel("Matlab",SwingConstants.LEFT);
JLabel jLabelEclipse =new JLabel("Eclipse",SwingConstants.LEFT);
JLabel jLabelQuartus =new JLabel("Quartus",SwingConstants.LEFT);
JLabel jLabelModelsim =new JLabel("ModelSim",SwingConstants.LEFT);
JLabel jLabelMestReC =new JLabel("MestReC",SwingConstants.LEFT);
JLabel jLabelMestReNova =new JLabel("MestReNova",SwingConstants.LEFT);
JLabel jLabelMbed =new JLabel("Mbed",SwingConstants.LEFT);
JButton BoutonMatlab = new JButton("MATLAB");
JButton BoutonEclipse = new JButton("ECLIPSE");
JButton BoutonQuartus = new JButton("QUARTUS");
JButton BoutonModelsim = new JButton("MODELSIM");
JButton BoutonMestReC = new JButton("MESTREC");
JButton BoutonMestReNova = new JButton("MESTRENOVA");
JButton BoutonMbed = new JButton("MBED");
ImageIcon IconVert = new ImageIcon("vert.png");
ImageIcon IconRouge = new ImageIcon("rouge.png");
public Fenetre(int tableau[], String nom_prog[]) {
super();
this.setTitle("Projet");
this.setSize(500, 600);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.InitComponent(tableau,nom_prog);
}
public void InitComponent(int[] tableau, String[] nom_prog)
{
//Panel Matlab
JPanel PanMatlab = new JPanel();
PanMatlab.setBackground(Color.white);
PanMatlab.setPreferredSize(new Dimension(300, 60));
PanMatlab.setBorder(BorderFactory.createTitledBorder("Matlab"));
PanMatlab.add(jLabelMatlab);
if(tableau[0]==1){
JLabel JMatlab = new JLabel(IconVert);
PanMatlab.add(JMatlab);
PanMatlab.add(BoutonMatlab);
BoutonMatlab.setEnabled(true);
BoutonMatlab.addActionListener(this);
}
else{
JLabel JMatlab = new JLabel(IconRouge);
PanMatlab.add(JMatlab);
PanMatlab.add(BoutonMatlab);
BoutonMatlab.setEnabled(false);
}
//meme code pour tous les autres Panel
...
...
//Container principal contenant les autres JPanels
JPanel container = new JPanel();
container.setBackground(Color.white);
container.add(PanMatlab);
container.add(PanEclipse);
container.add(PanQuartus);
container.add(PanModelsim);
container.add(PanMestReC);
container.add(PanMestReNova);
container.add(PanMbed);
this.getContentPane().add(container,BorderLayout.CENTER);
this.setContentPane(container);
...
...
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
JOptionPane jop1;
jop1 = new JOptionPane();
System.out.println("Action avec chaine de commande = " + e.getActionCommand());
if (source == close)
System.exit(0);
if (source == about)
JOptionPane.showMessageDialog(null,
"Projet Java- 04-07-2014", "About",
JOptionPane.INFORMATION_MESSAGE);
if (source == BoutonMatlab)
System.out.println("Action avec chaine de commande = " + e.getActionCommand());
if (source == BoutonEclipse)
System.out.println("Action avec chaine de commande = " + e.getActionCommand());
if (source == BoutonQuartus)
System.out.println("Action avec chaine de commande = " + e.getActionCommand());
if (source == BoutonModelsim)
System.out.println("Action avec chaine de commande = " + e.getActionCommand());
if (source == BoutonMbed){
System.out.println("Action avec chaine de commande = " + e.getActionCommand());
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec(new String[] {"C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", "https://mbed.org/"});
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
} |
Partager