458 lines
18 KiB
Java
458 lines
18 KiB
Java
|
/*
|
||
|
* To change this license header, choose License Headers in Project Properties.
|
||
|
* To change this template file, choose Tools | Templates
|
||
|
* and open the template in the editor.
|
||
|
*/
|
||
|
package ihm;
|
||
|
|
||
|
import java.awt.Color;
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* @author therbron
|
||
|
*/
|
||
|
public class FenPrinc extends javax.swing.JFrame {
|
||
|
|
||
|
/**
|
||
|
* Creates new form FenPrinc
|
||
|
*/
|
||
|
public FenPrinc() {
|
||
|
initComponents();
|
||
|
comboEntree.setBackground(Color.CYAN);
|
||
|
getContentPane().setBackground(new java.awt.Color(204, 255, 204));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* This method is called from within the constructor to initialize the form.
|
||
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||
|
* regenerated by the Form Editor.
|
||
|
*/
|
||
|
@SuppressWarnings("unchecked")
|
||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||
|
private void initComponents() {
|
||
|
|
||
|
jMenuItem5 = new javax.swing.JMenuItem();
|
||
|
jMenuItem6 = new javax.swing.JMenuItem();
|
||
|
grOS = new javax.swing.ButtonGroup();
|
||
|
etiSaisieCode = new javax.swing.JLabel();
|
||
|
zoneSaisie = new javax.swing.JTextField();
|
||
|
etiChoixSE = new javax.swing.JLabel();
|
||
|
comboEntree = new javax.swing.JComboBox();
|
||
|
etiListeSE = new javax.swing.JLabel();
|
||
|
jScrollPane1 = new javax.swing.JScrollPane();
|
||
|
listeEntree = new javax.swing.JList();
|
||
|
boxLin = new javax.swing.JCheckBox();
|
||
|
boxWin = new javax.swing.JCheckBox();
|
||
|
boxMac = new javax.swing.JCheckBox();
|
||
|
grLin = new javax.swing.JRadioButton();
|
||
|
grWin = new javax.swing.JRadioButton();
|
||
|
grMac = new javax.swing.JRadioButton();
|
||
|
jLabel1 = new javax.swing.JLabel();
|
||
|
etiEventEnCours = new javax.swing.JLabel();
|
||
|
menuBarPrinc = new javax.swing.JMenuBar();
|
||
|
menuPrinc = new javax.swing.JMenu();
|
||
|
itemC = new javax.swing.JMenuItem();
|
||
|
menuPoubelle = new javax.swing.JMenu();
|
||
|
itemPython = new javax.swing.JMenuItem();
|
||
|
itemBrainFuck = new javax.swing.JMenuItem();
|
||
|
menuObject = new javax.swing.JMenu();
|
||
|
itemJava = new javax.swing.JMenuItem();
|
||
|
itemCPlusPlus = new javax.swing.JMenuItem();
|
||
|
jSeparator1 = new javax.swing.JPopupMenu.Separator();
|
||
|
menuSecond = new javax.swing.JMenu();
|
||
|
itemPHP = new javax.swing.JMenuItem();
|
||
|
itemJavascript = new javax.swing.JMenuItem();
|
||
|
|
||
|
jMenuItem5.setText("jMenuItem5");
|
||
|
|
||
|
jMenuItem6.setText("jMenuItem6");
|
||
|
|
||
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||
|
setTitle("exemple d'IHM");
|
||
|
setMinimumSize(new java.awt.Dimension(250, 400));
|
||
|
setResizable(false);
|
||
|
getContentPane().setLayout(null);
|
||
|
|
||
|
etiSaisieCode.setText("Entrez votre code");
|
||
|
getContentPane().add(etiSaisieCode);
|
||
|
etiSaisieCode.setBounds(10, 20, 140, 15);
|
||
|
|
||
|
zoneSaisie.addKeyListener(new java.awt.event.KeyAdapter() {
|
||
|
public void keyPressed(java.awt.event.KeyEvent evt) {
|
||
|
zoneSaisieKeyPressed(evt);
|
||
|
}
|
||
|
});
|
||
|
getContentPane().add(zoneSaisie);
|
||
|
zoneSaisie.setBounds(150, 20, 70, 30);
|
||
|
|
||
|
etiChoixSE.setText("Choix");
|
||
|
getContentPane().add(etiChoixSE);
|
||
|
etiChoixSE.setBounds(10, 60, 38, 15);
|
||
|
|
||
|
comboEntree.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Linux", "Windows", "Unix", "Solaris", "Mac OS" }));
|
||
|
comboEntree.addActionListener(new java.awt.event.ActionListener() {
|
||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||
|
comboEntreeActionPerformed(evt);
|
||
|
}
|
||
|
});
|
||
|
getContentPane().add(comboEntree);
|
||
|
comboEntree.setBounds(80, 60, 120, 24);
|
||
|
|
||
|
etiListeSE.setText("Liste");
|
||
|
getContentPane().add(etiListeSE);
|
||
|
etiListeSE.setBounds(10, 140, 35, 15);
|
||
|
|
||
|
listeEntree.setModel(new javax.swing.AbstractListModel() {
|
||
|
String[] strings = { "Linux", "Windows", "Unix", "Solaris", "Mac OS" };
|
||
|
public int getSize() { return strings.length; }
|
||
|
public Object getElementAt(int i) { return strings[i]; }
|
||
|
});
|
||
|
listeEntree.addMouseListener(new java.awt.event.MouseAdapter() {
|
||
|
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||
|
listeEntreeMouseClicked(evt);
|
||
|
}
|
||
|
});
|
||
|
jScrollPane1.setViewportView(listeEntree);
|
||
|
|
||
|
getContentPane().add(jScrollPane1);
|
||
|
jScrollPane1.setBounds(80, 100, 120, 110);
|
||
|
|
||
|
boxLin.setText("Linux");
|
||
|
boxLin.addMouseListener(new java.awt.event.MouseAdapter() {
|
||
|
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||
|
boxLinMouseClicked(evt);
|
||
|
}
|
||
|
});
|
||
|
getContentPane().add(boxLin);
|
||
|
boxLin.setBounds(0, 220, 70, 23);
|
||
|
|
||
|
boxWin.setText("Windows");
|
||
|
boxWin.addMouseListener(new java.awt.event.MouseAdapter() {
|
||
|
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||
|
boxWinMouseClicked(evt);
|
||
|
}
|
||
|
});
|
||
|
getContentPane().add(boxWin);
|
||
|
boxWin.setBounds(70, 220, 90, 23);
|
||
|
|
||
|
boxMac.setText("Mac OS");
|
||
|
boxMac.addMouseListener(new java.awt.event.MouseAdapter() {
|
||
|
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||
|
boxMacMouseClicked(evt);
|
||
|
}
|
||
|
});
|
||
|
getContentPane().add(boxMac);
|
||
|
boxMac.setBounds(160, 220, 90, 23);
|
||
|
|
||
|
grOS.add(grLin);
|
||
|
grLin.setText("Linux");
|
||
|
grLin.addMouseListener(new java.awt.event.MouseAdapter() {
|
||
|
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||
|
grLinMouseClicked(evt);
|
||
|
}
|
||
|
});
|
||
|
getContentPane().add(grLin);
|
||
|
grLin.setBounds(0, 250, 70, 23);
|
||
|
|
||
|
grOS.add(grWin);
|
||
|
grWin.setText("Windows");
|
||
|
grWin.addMouseListener(new java.awt.event.MouseAdapter() {
|
||
|
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||
|
grWinMouseClicked(evt);
|
||
|
}
|
||
|
});
|
||
|
getContentPane().add(grWin);
|
||
|
grWin.setBounds(70, 250, 90, 23);
|
||
|
|
||
|
grOS.add(grMac);
|
||
|
grMac.setText("Mac OS");
|
||
|
grMac.addMouseListener(new java.awt.event.MouseAdapter() {
|
||
|
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||
|
grMacMouseClicked(evt);
|
||
|
}
|
||
|
});
|
||
|
getContentPane().add(grMac);
|
||
|
grMac.setBounds(160, 250, 77, 23);
|
||
|
|
||
|
jLabel1.setText("Source de l'événement :");
|
||
|
getContentPane().add(jLabel1);
|
||
|
jLabel1.setBounds(10, 280, 180, 15);
|
||
|
|
||
|
etiEventEnCours.setText(" ");
|
||
|
getContentPane().add(etiEventEnCours);
|
||
|
etiEventEnCours.setBounds(10, 300, 230, 15);
|
||
|
|
||
|
menuBarPrinc.setMaximumSize(new java.awt.Dimension(83000, 32769));
|
||
|
|
||
|
menuPrinc.setText("Langages");
|
||
|
|
||
|
itemC.setText("C");
|
||
|
itemC.addActionListener(new java.awt.event.ActionListener() {
|
||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||
|
itemCActionPerformed(evt);
|
||
|
}
|
||
|
});
|
||
|
menuPrinc.add(itemC);
|
||
|
|
||
|
menuPoubelle.setText("La poubelle");
|
||
|
|
||
|
itemPython.setText("Python");
|
||
|
itemPython.setToolTipText("");
|
||
|
itemPython.addActionListener(new java.awt.event.ActionListener() {
|
||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||
|
itemPythonActionPerformed(evt);
|
||
|
}
|
||
|
});
|
||
|
menuPoubelle.add(itemPython);
|
||
|
|
||
|
itemBrainFuck.setText("BrainFuck");
|
||
|
itemBrainFuck.addActionListener(new java.awt.event.ActionListener() {
|
||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||
|
itemBrainFuckActionPerformed(evt);
|
||
|
}
|
||
|
});
|
||
|
menuPoubelle.add(itemBrainFuck);
|
||
|
|
||
|
menuPrinc.add(menuPoubelle);
|
||
|
|
||
|
menuObject.setText("Objet");
|
||
|
|
||
|
itemJava.setText("Java");
|
||
|
itemJava.setToolTipText("");
|
||
|
itemJava.addActionListener(new java.awt.event.ActionListener() {
|
||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||
|
itemJavaActionPerformed(evt);
|
||
|
}
|
||
|
});
|
||
|
menuObject.add(itemJava);
|
||
|
|
||
|
itemCPlusPlus.setText("C++");
|
||
|
itemCPlusPlus.addActionListener(new java.awt.event.ActionListener() {
|
||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||
|
itemCPlusPlusActionPerformed(evt);
|
||
|
}
|
||
|
});
|
||
|
menuObject.add(itemCPlusPlus);
|
||
|
|
||
|
menuPrinc.add(menuObject);
|
||
|
menuPrinc.add(jSeparator1);
|
||
|
|
||
|
menuSecond.setText("Web");
|
||
|
|
||
|
itemPHP.setText("php");
|
||
|
itemPHP.addActionListener(new java.awt.event.ActionListener() {
|
||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||
|
itemPHPActionPerformed(evt);
|
||
|
}
|
||
|
});
|
||
|
menuSecond.add(itemPHP);
|
||
|
|
||
|
itemJavascript.setText("javascript");
|
||
|
itemJavascript.addActionListener(new java.awt.event.ActionListener() {
|
||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||
|
itemJavascriptActionPerformed(evt);
|
||
|
}
|
||
|
});
|
||
|
menuSecond.add(itemJavascript);
|
||
|
|
||
|
menuPrinc.add(menuSecond);
|
||
|
menuSecond.getAccessibleContext().setAccessibleParent(menuSecond);
|
||
|
|
||
|
menuBarPrinc.add(menuPrinc);
|
||
|
|
||
|
setJMenuBar(menuBarPrinc);
|
||
|
|
||
|
pack();
|
||
|
setLocationRelativeTo(null);
|
||
|
}// </editor-fold>//GEN-END:initComponents
|
||
|
|
||
|
private void zoneSaisieKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_zoneSaisieKeyPressed
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Code entré : " + evt.getKeyChar());
|
||
|
etiEventEnCours.setText("Code entré : " + evt.getKeyChar());
|
||
|
}//GEN-LAST:event_zoneSaisieKeyPressed
|
||
|
|
||
|
private void comboEntreeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboEntreeActionPerformed
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Entree combo : " + comboEntree.getSelectedItem());
|
||
|
etiEventEnCours.setText("Entree combo : " + comboEntree.getSelectedItem());
|
||
|
}//GEN-LAST:event_comboEntreeActionPerformed
|
||
|
|
||
|
private void listeEntreeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listeEntreeMouseClicked
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Entree choix multiple : " + listeEntree.getSelectedValue());
|
||
|
etiEventEnCours.setText("Entree choix multiple : " + listeEntree.getSelectedValue());
|
||
|
}//GEN-LAST:event_listeEntreeMouseClicked
|
||
|
|
||
|
private void boxLinMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_boxLinMouseClicked
|
||
|
// TODO add your handling code here:
|
||
|
if(boxLin.isSelected())
|
||
|
{
|
||
|
System.out.println("Case Linux cochée");
|
||
|
etiEventEnCours.setText("Case Linux cochée");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
System.out.println("Case Linux décochée");
|
||
|
etiEventEnCours.setText("Case Linux décochée");
|
||
|
}
|
||
|
}//GEN-LAST:event_boxLinMouseClicked
|
||
|
|
||
|
private void boxWinMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_boxWinMouseClicked
|
||
|
// TODO add your handling code here:
|
||
|
if(boxWin.isSelected())
|
||
|
{
|
||
|
System.out.println("Case Windows cochée");
|
||
|
etiEventEnCours.setText("Case Windows cochée");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
System.out.println("Case Windows décochée");
|
||
|
etiEventEnCours.setText("Case Windows décochée");
|
||
|
}
|
||
|
}//GEN-LAST:event_boxWinMouseClicked
|
||
|
|
||
|
private void boxMacMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_boxMacMouseClicked
|
||
|
// TODO add your handling code here:
|
||
|
if(boxMac.isSelected())
|
||
|
{
|
||
|
System.out.println("Case Mac cochée");
|
||
|
etiEventEnCours.setText("Case Mac cochée");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
System.out.println("Case Mac décochée");
|
||
|
etiEventEnCours.setText("Case Mac décochée");
|
||
|
}
|
||
|
}//GEN-LAST:event_boxMacMouseClicked
|
||
|
|
||
|
private void grLinMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_grLinMouseClicked
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Entree bouton radio : Linux");
|
||
|
etiEventEnCours.setText("Entree bouton radio : Linux");
|
||
|
}//GEN-LAST:event_grLinMouseClicked
|
||
|
|
||
|
private void grWinMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_grWinMouseClicked
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Entree bouton radio : Windows");
|
||
|
etiEventEnCours.setText("Entree bouton radio : Windows");
|
||
|
}//GEN-LAST:event_grWinMouseClicked
|
||
|
|
||
|
private void grMacMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_grMacMouseClicked
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Entree bouton radio : Mac");
|
||
|
etiEventEnCours.setText("Entree bouton radio : Mac");
|
||
|
}//GEN-LAST:event_grMacMouseClicked
|
||
|
|
||
|
private void itemCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemCActionPerformed
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Choix menu : C");
|
||
|
etiEventEnCours.setText("Choix menu : C");
|
||
|
}//GEN-LAST:event_itemCActionPerformed
|
||
|
|
||
|
private void itemPythonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemPythonActionPerformed
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Choix menu : Python");
|
||
|
etiEventEnCours.setText("Choix menu : Python");
|
||
|
}//GEN-LAST:event_itemPythonActionPerformed
|
||
|
|
||
|
private void itemBrainFuckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemBrainFuckActionPerformed
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Choix menu : Brainfuck");
|
||
|
etiEventEnCours.setText("Choix menu : Brainfuck");
|
||
|
}//GEN-LAST:event_itemBrainFuckActionPerformed
|
||
|
|
||
|
private void itemJavaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemJavaActionPerformed
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Choix menu : Java");
|
||
|
etiEventEnCours.setText("Choix menu : Java");
|
||
|
}//GEN-LAST:event_itemJavaActionPerformed
|
||
|
|
||
|
private void itemCPlusPlusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemCPlusPlusActionPerformed
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Choix menu : C++");
|
||
|
etiEventEnCours.setText("Choix menu : C++");
|
||
|
}//GEN-LAST:event_itemCPlusPlusActionPerformed
|
||
|
|
||
|
private void itemPHPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemPHPActionPerformed
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Choix menu : php");
|
||
|
etiEventEnCours.setText("Choix menu : php");
|
||
|
}//GEN-LAST:event_itemPHPActionPerformed
|
||
|
|
||
|
private void itemJavascriptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemJavascriptActionPerformed
|
||
|
// TODO add your handling code here:
|
||
|
System.out.println("Choix menu : javascript");
|
||
|
etiEventEnCours.setText("Choix menu : javascript");
|
||
|
}//GEN-LAST:event_itemJavascriptActionPerformed
|
||
|
|
||
|
/**
|
||
|
* @param args the command line arguments
|
||
|
*/
|
||
|
public static void main(String args[]) {
|
||
|
/* Set the Nimbus look and feel */
|
||
|
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||
|
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||
|
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||
|
*/
|
||
|
try {
|
||
|
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||
|
if ("Nimbus".equals(info.getName())) {
|
||
|
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
} catch (ClassNotFoundException ex) {
|
||
|
java.util.logging.Logger.getLogger(FenPrinc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||
|
} catch (InstantiationException ex) {
|
||
|
java.util.logging.Logger.getLogger(FenPrinc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||
|
} catch (IllegalAccessException ex) {
|
||
|
java.util.logging.Logger.getLogger(FenPrinc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||
|
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||
|
java.util.logging.Logger.getLogger(FenPrinc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||
|
}
|
||
|
//</editor-fold>
|
||
|
|
||
|
/* Create and display the form */
|
||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||
|
public void run() {
|
||
|
new FenPrinc().setVisible(true);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||
|
private javax.swing.JCheckBox boxLin;
|
||
|
private javax.swing.JCheckBox boxMac;
|
||
|
private javax.swing.JCheckBox boxWin;
|
||
|
private javax.swing.JComboBox comboEntree;
|
||
|
private javax.swing.JLabel etiChoixSE;
|
||
|
private javax.swing.JLabel etiEventEnCours;
|
||
|
private javax.swing.JLabel etiListeSE;
|
||
|
private javax.swing.JLabel etiSaisieCode;
|
||
|
private javax.swing.JRadioButton grLin;
|
||
|
private javax.swing.JRadioButton grMac;
|
||
|
private javax.swing.ButtonGroup grOS;
|
||
|
private javax.swing.JRadioButton grWin;
|
||
|
private javax.swing.JMenuItem itemBrainFuck;
|
||
|
private javax.swing.JMenuItem itemC;
|
||
|
private javax.swing.JMenuItem itemCPlusPlus;
|
||
|
private javax.swing.JMenuItem itemJava;
|
||
|
private javax.swing.JMenuItem itemJavascript;
|
||
|
private javax.swing.JMenuItem itemPHP;
|
||
|
private javax.swing.JMenuItem itemPython;
|
||
|
private javax.swing.JLabel jLabel1;
|
||
|
private javax.swing.JMenuItem jMenuItem5;
|
||
|
private javax.swing.JMenuItem jMenuItem6;
|
||
|
private javax.swing.JScrollPane jScrollPane1;
|
||
|
private javax.swing.JPopupMenu.Separator jSeparator1;
|
||
|
private javax.swing.JList listeEntree;
|
||
|
private javax.swing.JMenuBar menuBarPrinc;
|
||
|
private javax.swing.JMenu menuObject;
|
||
|
private javax.swing.JMenu menuPoubelle;
|
||
|
private javax.swing.JMenu menuPrinc;
|
||
|
private javax.swing.JMenu menuSecond;
|
||
|
private javax.swing.JTextField zoneSaisie;
|
||
|
// End of variables declaration//GEN-END:variables
|
||
|
}
|