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 124 125 126 127 128 129 130
| public class FenetrePrincipale extends JFrame implements ActionListener {
public static int x[] = { 0, 0, 1 };
public static int y[] = { 0, 1, 0 };
public static int larg[] = { 1, 1, 3 };
public static int haut[] = { 1, 2, 3 };
public static int px[] = { 20, 20, 60 };
public static int py[] = { 20, 40, 60 };
public static JPanel pan1;
public static JPanel pan2;
public static JPanel pan3;
private JPanel containerHaut = null;
private FlowLayout layout = null;
private JButton bouton = null;
private JLabel texteGamme = null;
private JLabel texteAccord = null;
private JComboBox listNotes = null;
private JComboBox listCouleurs = null;
private JComboBox listTons = null;
private JComboBox listModes = null;
private Object[] notes = new Object[] { "Do", "Do#", "Ré", "Ré#", "Mi", "Fa", "Fa#", "Sol", "Sol#", "La", "Si", "Si#" };
private Object[] couleurs = new Object[] { "- - 3 SONS - -","Majeur","Mineur","sus4","b5","Augmenté","Diminué","- - 4 SONS - -","7","7(#5)","7(sus4)","Maj7","Maj7(#5)","Maj7(b5)","Min7","Min(Maj7)","Min7(b5)","6","Min6","Dim7","Add9","Min(Add9)","- - 5 SONS - -","9","7(b9)","7(#9)","Maj7(9)","Min7(9)","6(9)","Min6(9)" };
private Object[] tons = new Object[] { "Do", "Do#", "Ré", "Ré#", "Mi", "Fa", "Fa#", "Sol", "Sol#", "La", "Si", "Si#" };
private Object[] modes = new Object[] { "Pentatonique mineure","Pentatonique majeure","- - MAJEURE - -","Ionien (gamme majeure)","Dorien","Phrygien","Lydien","Mixolydien","Eolien (gamme mineure)","Locrien","- -MINEURE HARMONIQUE- -","Mineure harmonique","Locrien #13","Ionien #5","Dorien #11","Phrygien #3","Lydien #9","Superlocrien bb7","- - MINEURE MELODIQUE - -","Mineur mélodique","Dorien b9","Lydien augmenté","Lydien dominante","Mixolydien b13","Locrien #9","Altéré superlocrien","- - SYMETRIQUE - -","Arpèges diminuée","Augmentée","Chromatique","Diminuée ton/demi-ton","Diminuée demi-ton/ton","Par ton","- - EXOTIQUE - -","Arabe","Balinaise","Dominante pentatonique","Double harmonique","Enigmatique","Espagnole","Gypsy","Japonaise","Kokin Joshi","Orientale","Persan","Promethée" };
private int nombre = 0; // Déclaration du chiffre
public FenetrePrincipale() {
super();
build();
}
private void build() {
setTitle("Apprendre les gammes de la guitare");
setSize(800, 500);
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container contenu = getContentPane();
GridBagLayout g = new GridBagLayout();
contenu.setLayout(g);
GridBagConstraints c = new GridBagConstraints();
c.fill = c.BOTH;
pan1 = getContainerSelection();
pan1.setBorder(new TitledBorder(" Selectionner "));
pan2 = new AccordPanel();
pan2.setBackground(Color.white);
// ici je ne peux pas appeler de méthode particuliere de pan2, je veux modifier la liste gammes
for (int i = 0; i < x.length; i++) {
c.gridx = x[i];
c.gridy = y[i];
c.gridwidth = larg[i];
c.gridheight = haut[i];
c.weightx = px[i];
c.weighty = py[i];
switch (i) {
case 0:
contenu.add(pan1, c);
break;
case 1:
contenu.add(pan2, c);
break;
/*case 2:
contenu.add(pan3, c);
break;*/
}
}
}
private JPanel getContainerSelection() {
layout = new FlowLayout();
layout.setAlignment(FlowLayout.LEFT);
containerHaut = new JPanel();
containerHaut.setLayout(layout);
texteGamme = new JLabel();
texteGamme.setPreferredSize(new Dimension(70, 25));
texteGamme.setText("Gamme :");
listNotes = new JComboBox(notes);
listNotes.setPreferredSize(new Dimension(50, 25));
listCouleurs = new JComboBox(couleurs);
listCouleurs.setPreferredSize(new Dimension(100, 25));
texteAccord = new JLabel();
texteAccord.setPreferredSize(new Dimension(70, 25));
texteAccord.setText("Accord :");
listTons = new JComboBox(tons);
listTons.setPreferredSize(new Dimension(50, 25));
listModes = new JComboBox(modes);
listModes.setPreferredSize(new Dimension(150, 25));
bouton = new JButton();
bouton.setPreferredSize(new Dimension(70, 25));
bouton.setText("Valider");
bouton.addActionListener(this);
containerHaut.add(texteGamme);
containerHaut.add(listNotes);
containerHaut.add(listCouleurs);
containerHaut.add(texteAccord);
containerHaut.add(listTons);
containerHaut.add(listModes);
containerHaut.add(bouton);
return containerHaut;
}
public void actionPerformed(ActionEvent e) {
// Si l'action émane bien du bouton
if (e.getSource() == bouton) {
nombre++;
//texte.setText("Vous avez cliqué " + nombre + " fois sur le bouton");
}
}
} |
Partager