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
|
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JList jListMCAE = new JList(new Object[]{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"});//lstMCAE);
JList jListMCAD = new JList();//lstMCAD);
jListMCAE.setVisibleRowCount(5);
jListMCAD.setVisibleRowCount(5);
jListMCAE.setFixedCellWidth(100);
jListMCAD.setFixedCellWidth(100);
jListMCAE.setFixedCellHeight(12);
jListMCAD.setFixedCellHeight(12);
JScrollPane jScrollMCAE = new JScrollPane(jListMCAE);
JScrollPane jScrollMCAD = new JScrollPane(jListMCAD);
JButton jBAddAboMsg = new JButton();
JButton jBSuppAbo = new JButton();
//positionnement
JPanel jPanelMCG = new JPanel();
JPanel jPanelMCD = new JPanel();
JPanel jPanelMCC = new JPanel();
JPanel jPanelMCCentre = new JPanel();
jPanelMCG.add(new JLabel("jLabelMCAD"), BorderLayout.NORTH);
jPanelMCG.add(jScrollMCAD, BorderLayout.CENTER);
jPanelMCD.add(new JLabel("jLabelMCAE"), BorderLayout.NORTH);
jPanelMCD.add(jScrollMCAE, BorderLayout.CENTER);
jPanelMCC.setPreferredSize(new Dimension(120, 12));
jPanelMCC.setMinimumSize(new Dimension(120, 12));
jPanelMCC.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE;
gbc.gridx = 0;
jPanelMCC.add(jBAddAboMsg, gbc);
jPanelMCC.add(new JLabel("\n"), gbc);
jPanelMCC.add(new JLabel("\n"), gbc);
jPanelMCC.add(jBSuppAbo, gbc);
gbc = new GridBagConstraints();
gbc.gridx = GridBagConstraints.RELATIVE; //incremente la colonne tout seul
gbc.gridy = GridBagConstraints.REMAINDER; //tjs sur la meme ligne
gbc.weighty = 1.0; //100% du y
gbc.weightx = 0.5; // 50% du x
gbc.fill = GridBagConstraints.BOTH; //etirable en x et en y
jPanelMCCentre.add(jPanelMCG, gbc);
gbc.weightx = 0.0; //taille fixe
gbc.fill = GridBagConstraints.VERTICAL; //etirable en y
jPanelMCCentre.add(jPanelMCC, gbc);
gbc.weightx = 0.5;
gbc.fill = GridBagConstraints.BOTH;
jPanelMCCentre.add(jPanelMCD, gbc);
frame.setContentPane(jPanelMCCentre);
frame.pack();
frame.setLocation(500, 500);
frame.setVisible(true);
} |
Partager