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
|
public class MainWindows extends JFrame {
private JLabel labelCategory;
private JComboBox comboCategory;
private JLabel labelSearch;
private JTextField jTextSearch;
private MainMenu mm = new MainMenu();
private JPanel panelTop = new JPanel();
public MainWindows(){
build();
setJMenuBar(mm.createMenu());
}
private void build(){
//Création de la fenêtre
JFrame mainJf = new JFrame("Ma première fenêtre");
mainJf.setSize(600, 800);
mainJf.setLocationRelativeTo(null);
//On affiche les différents composants grâce au cardLayout manager
CardLayout cardL = new CardLayout();
JPanel clPanel = new JPanel(cardL);
mainJf.getContentPane().add(clPanel);
//JPanel panelTable = new JPanel();
MainWindows.createJLabel(labelCategory, panelTop, "choisir une catégorie");
MainWindows.createJcomboBox(comboCategory, true, panelTop);
MainWindows.createJLabel(labelSearch, panelTop, "Rechercher");
MainWindows.createJTextField(jTextSearch, panelTop, 10);
panelTop.setPreferredSize(new Dimension(0,panelTop.getPreferredSize().height*2));
mainJf.getContentPane().add(panelTop, BorderLayout.NORTH);
mainJf.setVisible(true);
mainJf.setResizable(true);
mainJf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
...............Méthode en dessous
} |
Partager