Results 1 to 5 of 5
Thread: JPanel / layout problems
- 06-03-2008, 09:45 PM #1
Member
- Join Date
- Jun 2008
- Posts
- 3
- Rep Power
- 0
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);
- 06-04-2008, 05:06 AM #2
Have you tried to set its layout to null? instead of Setting the LayoutManager to null(@ JPanel parameter)
eg.Java Code:this.setLayout(null);
freedom exists in the world of ideas
- 06-04-2008, 05:17 AM #3
Member
- Join Date
- Jun 2008
- Posts
- 3
- Rep Power
- 0
that would set the layout to the parent JFrame to null not the JPanel...
- 06-04-2008, 05:20 AM #4
i assumed you've created a class that extends JPanel....
Nice implementation if you did...
objectPanel.setLayout(null);freedom exists in the world of ideas
- 06-04-2008, 05:26 AM #5
Member
- Join Date
- Jun 2008
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Help with JButton and layout
By adlb1300 in forum AWT / SwingReplies: 1Last Post: 12-25-2007, 08:33 AM -
Problems while loading a JPanel to JApplet...
By Ananth Chellathurai in forum Java AppletsReplies: 0Last Post: 11-24-2007, 10:47 AM -
JPanel Problems
By Riftwalker in forum AWT / SwingReplies: 6Last Post: 10-15-2007, 11:16 PM -
Help with Grid Layout
By coco in forum AWT / SwingReplies: 1Last Post: 08-06-2007, 08:03 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks