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
| package com.psv.test;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class MyFrame extends JFrame{
public MyFrame() {
super();
setSize(200, 200);
// On initialise les composants
JTextField myTextField = new JTextField(9);
MyComboBox myComboBox = new MyComboBox(myTextField);
// On initialise les valeurs de la conbobox
myComboBox.addItem("Lundi");
myComboBox.addItem("Mardi");
myComboBox.addItem("Mercredi");
myComboBox.addItem("Jeudi");
myComboBox.addItem("Vendredi");
myComboBox.addItem("Samedi");
myComboBox.addItem("Dimanche");
// On se charge de l'affichage
JPanel mainPanel = new JPanel();
mainPanel.add(myTextField);
mainPanel.add(myComboBox);
getContentPane().add(mainPanel);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setResizable(false);
setVisible(true);
}
/**
* @param args
*/
public static void main(String[] args) {
new MyFrame();
}
} |
Partager