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 / General / February 2007

Tip: Looking for answers? Try searching our database.

Please suggest a layout manager

Thread view: 
On Ali - 17 Feb 2007 13:24 GMT
Hi,

Can anyone suggest a layout manager which would do the following:

- Stack the components one below the other (Not the way CardLayout
does, but like a grid layout with 1 column)
- Set the width of each component as that of the panel (minus insets)
- Set the height as the preferred height

The behavior I want is similar to the windows explorer details panel
on the left. (Some blocks can be opened or closed using arrow buttons)

Thanks in advance,

Regards,
On Ali
Eric Sosman - 17 Feb 2007 13:56 GMT
> Hi,
>
[quoted text clipped - 4 lines]
> - Set the width of each component as that of the panel (minus insets)
> - Set the height as the preferred height

    Perhaps you want BoxLayout with a vertical orientation?

> The behavior I want is similar to the windows explorer details panel
> on the left. (Some blocks can be opened or closed using arrow buttons)

    When you change the size of an already-painted component,
you'll probably need to re-pack() the container to inform the
layout manager of the change.

Signature

Eric Sosman
esosman@acm-dot-org.invalid

On Ali - 17 Feb 2007 14:12 GMT
> > Hi,
>
[quoted text clipped - 17 lines]
> Eric Sosman
> esos...@acm-dot-org.invalid

i am not very sure whether the box layout fulfills my second and third
requirements
Eric Sosman - 17 Feb 2007 14:24 GMT
>>> Hi,
>>> Can anyone suggest a layout manager which would do the following:
[quoted text clipped - 6 lines]
> i am not very sure whether the box layout fulfills my second and third
> requirements

    It does -- or so it seems to me; I may have misunderstood
your requirements.  Why not try it for yourself?

Signature

Eric Sosman
esosman@acm-dot-org.invalid

On Ali - 17 Feb 2007 14:33 GMT
> >>> Hi,
> >>> Can anyone suggest a layout manager which would do the following:
[quoted text clipped - 13 lines]
> Eric Sosman
> esos...@acm-dot-org.invalid

i have actually seen the screenshots on the sun site.... i takes the
preferred width of the component and not the total available width of
the container
a249@mailinator.com - 17 Feb 2007 16:17 GMT
> i am not very sure whether the box layout fulfills my second and third
> requirements

Why don't you try it?
Larry Barowski - 17 Feb 2007 17:30 GMT
> i am not very sure whether the box layout fulfills my second and third
> requirements

It depends on what you mean by the second one. For
a vertical orientation I believe it will make all the
components the same width, if they aren't restricted by
maximum width. If it's a column of buttons for example,
they will all be as wide as the largest preferred width.

If the panel is on one side of a split pane or something
and you want the components to fill the width of the
panel but for the panel still to have a meaningful
preferred width, then GridBagLayout would be easy
enough, or you could write your own layout to do this
in about ten minutes. For the simplest case (minimum
size == preferred size, tightly packed components,
align to top, no respect for maximum sizes) you could
do something like (untested, may contain errors):

public Dimension preferredLayoutSize(Container parent) {
  Component[] children = parent.getComponents();
  Dimension psize = new Dimension();
  for(int c = 0; c < children.length; c++) {
     Dimension child_psize = children[c].getPreferredSize();
     psize.height += child_psize.height;
     psize.width = Math.max(psize.width, child_psize.width); }
  Insets insets = parent.getInsets();
  psize.width += insets.left + insets.right;
  psize.height += insets.top + insets.bottom;
  return psize;
}

public Dimension minimumLayoutSize(Container parent) {
  return preferredLayoutSize(parent);
}

public void layoutContainer(Container parent) {
  Dimension msize = minimumLayoutSize(parent);
  Insets insets = parent.getInsets();
  int w = Math.max(parent.getSize().width, msize.width) -
        insets.left - insets.right;
  int x = insets.left;
  int y = insets.top;
  Component[] children = parent.getComponents();
  for(int c = 0; c < children.length; c++) {
     Component child = children[c];
     Dimension child_psize = child.getPreferredSize();
     child.setLocation(x, y);
     child.setSize(w, child_psize.height);
     y += child_psize.height;
  }
}

public void addLayoutComponent(String name,
  Component comp) {
}

public void removeLayoutComponent(Component comp) {
}
Alexander Schoelling - 17 Feb 2007 19:13 GMT
On Ali schrieb:
> The behavior I want is similar to the windows explorer details panel
> on the left. (Some blocks can be opened or closed using arrow buttons)

Hi,

it looks as if SwingLabs (http://swinglabs.org/) JXTaskPane does what
you want.

Yours,

Alexander
On Ali - 19 Feb 2007 04:24 GMT
On Feb 18, 12:13 am, Alexander Schoelling <aschoell...@arcor.de>
wrote:
> On Ali schrieb:
>
[quoted text clipped - 9 lines]
>
> Alexander

this is nice..! thank you


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



©2009 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.