Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / April 2004

Tip: Looking for answers? Try searching our database.

jpanel wont' extend horizontally in tabbedpane

Thread view: 
Willian Irving Zumwalt - 28 Apr 2004 20:13 GMT
Hey all,

I'm having a problem with the layout management of a JPanel. The panel
is not extending the full width horizontally of the tabbedpane in
which it is placed and all the controls are all bunched up together
inside the titled border of this JPanel.

Ideally, I'd like for my titled border of the JPanel to extend
horizontally the full width of the tabbed pane, and the controls
within that titled border/jpanel to be proportionatly across.

Any help/ideas much appreciated.

---
...
// the components of 'myPane' are the problem, they are
// not layed out horizontally, but rather, bunched up in the center
// and my titled border does not stretch across the entire pane, only
// around the controls.

myPane = new MyPane();
tabbedPane.addTab("myTopPanel", myPane);
...
rightSplitPanel.add(tabbedPane, BoderLayout.NORTH);

---

public class MyPane extends JPanel implements ..., ... {
...
  public void createTopPanel() {
     JComponent comp = new JPanel(new GridBagLayout());
     GridBagConstraints c = new GridBagConstraints();
     c.fill = GridBagConstraints.HORIZONTAL;
     c.gridwidth = 1;
     ...
     // lots of JTextFields, Combo's, Labels, etc... here
     ...
     comp.setBorder(BorderFactory.createTitledBorder("blah"));
     this.add(comp, BorderLayout.PAGE_START);
     ...
  }
}
ak - 28 Apr 2004 23:57 GMT
> I'm having a problem with the layout management of a JPanel. The panel
> is not extending the full width horizontally of the tabbedpane in
> which it is placed and all the controls are all bunched up together
> inside the titled border of this JPanel

to laid out things horizontally use Box or BoxLayout

--
____________

http://reader.imagero.com the best java image reader.
Willian Irving Zumwalt - 29 Apr 2004 19:31 GMT
No, I don't want to lay them out horizontally, I want them to expand
in proportion horizontally. The GridBagLayout provides the flexibility
I need. Problem is the controls in each panel bunch up together in the
center inside the titledborder which doesn't extend all the way
across. I end up w/ three panels of different sizes in the correct
vertical order (i.e. topPanel, midPanel, bottomPanel), but they just
don't extend horizontally the full width.
---

myPane = new MyPane();
tabbedPane.addTab("myTopPanel", myPane);
...
rightSplitPanel.add(tabbedPane, BoderLayout.NORTH);

---

public class MyPane extends JPanel implements ..., ... {
...
  public void createTopPanel() {
     JComponent comp = new JPanel(new GridBagLayout());
     GridBagConstraints c = new GridBagConstraints();
     c.fill = GridBagConstraints.HORIZONTAL;
     c.gridwidth = 1;
     ...
     // lots of JTextFields, Combo's, Labels, etc... here
     ...
     comp.setBorder(BorderFactory.createTitledBorder("blah"));
     this.add(comp, BorderLayout.PAGE_START);
     ...
  }

  public void createMiddlePanel() {
     JComponent comp = new JPanel(new GridBagLayout());
     GridBagConstraints c = new GridBagConstraints();
     c.fill = GridBagConstraints.HORIZONTAL;
     c.gridwidth = 1;
     ...
     // lots of JTextFields, Combo's, Labels, etc... here
     ...
     comp.setBorder(BorderFactory.createTitledBorder("blah"));
     this.add(comp, BorderLayout.PAGE_START);
     ...
  }

  public void createBottomPanel() {
     JComponent comp = new JPanel(new GridBagLayout());
     GridBagConstraints c = new GridBagConstraints();
     c.fill = GridBagConstraints.HORIZONTAL;
     c.gridwidth = 1;
     ...
     // lots of JTextFields, Combo's, Labels, etc... here
     ...
     comp.setBorder(BorderFactory.createTitledBorder("blah"));
     this.add(comp, BorderLayout.PAGE_END);
     ...
  }
}


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.