|
JPanel / layout problems
Hey folks.. I am having a problem with using a few of the layouts within a JPanel. For some reason if I use flowlayout or gridlayout the components of the panel display. If i use springlayout, boxlayout, or absolute positioning the panel does not display. I have the panel embedded in a JFrame. Here is the code snippet for one of the panels in the application...
If i change the first line to modePanel = new JPanel(); it displays FYI
// Mode Panel Coding
modePanel = new JPanel(null);
lblModeSelect = new JLabel("Select a mode");
lblModeSelect.setFont(lblModeSelect.getFont().deri veFont(14.0f));
cmbModeSelect = new JComboBox(modeArray);
cmbModeSelect.setSelectedIndex(0);
// x, y, width, height
modePanel.add(lblModeSelect);
modePanel.add(cmbModeSelect);
lblModeSelect.setSize(lblModeSelect.getPreferredSi ze());
//lblModeSelect.setVisible(true);
modePanel.setSize(100,50);
System.out.println(lblModeSelect.getSize());
lblModeSelect.setBounds(1, 1, 55, 10);
cmbModeSelect.setBounds(1, 20, 55, 10);
content.add(modePanel);
content.validate();
//modePanel.setVisible(true);
content.layout.putConstraint(SpringLayout.WEST, modePanel,
1, SpringLayout.WEST, content);
content.layout.putConstraint(SpringLayout.NORTH, modePanel,
1, SpringLayout.NORTH, content);
cmbModeSelect.addActionListener(this);
|