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
|
import javax.swing.*;
import java.awt.*;
public class EditeurCartes {
public void construireIhm() {
/* La fenetre principale */
JFrame cadre=new JFrame("Editeur de cartes");
cadre.setSize(800,600);
cadre.getContentPane().setLayout(new BoxLayout(cadre.getContentPane(),BoxLayout.Y_AXIS));
/* Les text Areas representant les 2 faces de la carte */
JTextArea carteQuestion = new JTextArea(6,20);
JTextArea carteReponse = new JTextArea(6,20);
carteQuestion.setLineWrap(true);
carteReponse.setLineWrap(true);
/* Les ascenseur pour les text areas */
JScrollPane ascenseurQuestion=new JScrollPane(carteQuestion);
ascenseurQuestion.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
ascenseurQuestion.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JScrollPane ascenseurReponse=new JScrollPane(carteReponse);
/* Les labels Question : et Reponse : */
JLabel question = new JLabel("Question : ");
JLabel reponse = new JLabel("Reponse : ");
/* Le bouton carte suivante */
JButton boutton = new JButton("Carte suivante");
/* Ajout de tous les composant dans la fenetre principale */
cadre.getContentPane().add(question);
cadre.getContentPane().add(ascenseurQuestion);
cadre.getContentPane().add(reponse);
cadre.getContentPane().add(ascenseurReponse);
cadre.getContentPane().add(boutton);
cadre.setVisible(true);
}
public static void main(String[] args) {
EditeurCartes editeur = new EditeurCartes();
editeur.construireIhm();
}
} |
Partager