lamino | Bonsoir,
Ca fait des heures que je cherche a resoudre le pobleme, j'espere que vous pourriez m'aider a y voir plus clair.
Une image vaut 1000 discours.
Je cherche a afficher le JComboBox "encoding" avec une taille normale, tout en remontant vers le haut le JLabel "Encoding :" (de la meme maniere que le menu "Create an empty Project" apparait )
Je vous remercie d'avance pour votre aide.
Code :
- Toolkit tk = Toolkit.getDefaultToolkit();
- Dimension d = tk.getScreenSize();
- int screenHeight = d.height;
- int screenWidth = d.width;
- //int screenHeight = 750;
- //int screenWidth = 1000;
- setSize(screenWidth / 2, screenHeight / 2);
- setLocation(screenWidth / 4 + 30, screenHeight / 4 + 50);
- Container contentPane = getContentPane();
- GridBagLayout gbl = new GridBagLayout();
- contentPane.setLayout(gbl);
- GridBagConstraints gbc = new GridBagConstraints();
- //gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.insets.top = 15;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.anchor = GridBagConstraints.NORTH;
- //gbc.fill = GridBagConstraints.NONE;
- //gbc.anchor = GridBagConstraints.NORTHEAST;
- gbc.weightx = 0.1;
- add(new JLabel("Project name: " ), gbc, 0, 0, 1, 1);
- gbc.weightx = 0.9;
- add(projectName, gbc, 1, 0, 1, 1);
- gbc.weightx = 0.1;
- add(new JLabel("Project location: " ), gbc, 0, 1, 1, 1);
- gbc.weightx = 0.9;
- add(projectLocation, gbc, 1, 1, 1, 1);
- gbc.weightx = 0.1;
- add(new JLabel("Create an empty Project? " ), gbc, 0, 2, 1, 1);
- gbc.weightx = 0.9;
- add(emptyOpt, gbc, 1, 2, 1, 1);
- gbc.weightx = 0.1;
- add(new JLabel("Project input file: " ), gbc, 0, 3, 1, 1);
- gbc.weightx = 0.9;
- add(inputFileBrowse, gbc, 1, 3, 1, 1);
- add(inputFileName, gbc, 1, 4, 1, 1);
- //gbc.weightx = 100;
- //gbc.fill = GridBagConstraints.HORIZONTAL;
- //gbc.anchor = GridBagConstraints.NORTH;
- JComboBox encoding = new JComboBox();
- encoding.setEditable(false);
- encoding.addItem("UTF-8" );
- encoding.addItem("ISO8859-1" );
- encoding.setSelectedIndex(0);// Default is "not empty project".
- encoding.setSelectedItem("UTF-8" );
- gbc.weightx = 0.1;
- add(new JLabel("Encoding: " ), gbc, 0, 5, 1, 1);
- gbc.weightx = 0.9;
- add(encoding, gbc, 1, 5, 1, 1);
- JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 25, 25));
- okBT = new DHJButton(this, "OK" );
- okBT.setPreferredSize(new Dimension(75, 25));
- bottomPanel.add(okBT);
- JButton jb = new DHJButton(this, "Cancel" );
- jb.setPreferredSize(new Dimension(75, 25));
- bottomPanel.add(jb);
- gbc.weighty = 100;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.anchor = GridBagConstraints.SOUTH;
- add(bottomPanel, gbc, 0, 5, 2, 1);
- inputFileBrowse.setEnabled(!emptyProject);
|
Code :
- private void add(Component c, GridBagConstraints gbc, int x, int y, int w,
- int h) {
- gbc.gridx = x;
- gbc.gridy = y;
- gbc.gridwidth = w;
- gbc.gridheight = h;
- getContentPane().add(c, gbc);
- }
|
|