Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-03-2008, 10:45 PM
Member
 
Join Date: Jun 2008
Posts: 3
Warhorsei is on a distinguished road
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);
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-04-2008, 06:06 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 526
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Have you tried to set its layout to null? instead of Setting the LayoutManager to null(@ JPanel parameter)

eg.
Code:
this.setLayout(null);
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-04-2008, 06:17 AM
Member
 
Join Date: Jun 2008
Posts: 3
Warhorsei is on a distinguished road
that would set the layout to the parent JFrame to null not the JPanel...
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-04-2008, 06:20 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 526
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
i assumed you've created a class that extends JPanel....

Nice implementation if you did...

objectPanel.setLayout(null);
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 06-04-2008, 06:26 AM
Member
 
Join Date: Jun 2008
Posts: 3
Warhorsei is on a distinguished road
no change with that, thx for the suggestion. I can gladly make a new class for each panel but I don't see any benefit to doin that in this app
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SWT Layout JavaForums Java Blogs 0 12-31-2007 05:53 PM
Help with JButton and layout adlb1300 AWT / Swing 1 12-25-2007 09:33 AM
Problems while loading a JPanel to JApplet... Ananth Chellathurai Java Applets 0 11-24-2007 11:47 AM
JPanel Problems Riftwalker AWT / Swing 6 10-16-2007 12:16 AM
Help with Grid Layout coco AWT / Swing 1 08-06-2007 09:03 PM


All times are GMT +3. The time now is 12:11 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org