Re: Why use panels

From: FISH (joeking_at_merseymail.com)
Date: 06/25/04


Date: 25 Jun 2004 08:48:40 -0700

V S Rawat <vsrawat_no_reply_@hclinfinet.com> wrote in message news:<40DAAF9B.2000906@hclinfinet.com>...
> I have seen some programs in which components like,
> JButtons, JComboboxes, JLabels etc were first added on
> JPanels and then these panels were put in gridbaglayout.
>
> Does such placement provide some benefit or functionality
> that would not have been available if those components were
> directly put on the gridbaglayout without using JPanels?
>
> Regards and Thanks in advance.
> -Rawat

When building a complicated user interface, it is often easier to break
it up into sections. Gridbag is easily the most powerful layout manager
which comes with Java as standard, but it is also the most complex
(hardly surprising!). Quite often it is easier to build and maintain a
UI when different managers are mixed and nested - even when using some-
thing as powerful as gridbag (which could probably emulate most of the
other managers if given the correct options!)

Also, there are occasions when panels do more than just lay out
components. Back in the pre-Swing days the only way to add a border
around a section of your user interface was to create a panel which
displayed a border, for example. Swing too has its own specialist
containers, many of its 'Pane' components are (strictly speaking)
containers, for example JScrollPane and JSplitPane.

-FISH- ><>



Relevant Pages

  • Re: Why use panels
    ... > JButtons, JComboboxes, JLabels etc were first added on ... > JPanels and then these panels were put in gridbaglayout. ...
    (comp.lang.java.help)
  • Why use panels
    ... JButtons, JComboboxes, JLabels etc were first added on ... JPanels and then these panels were put in gridbaglayout. ...
    (comp.lang.java.help)
  • Re: Resizing a JFrame at runtime
    ... this is just a thought and it could take a little recoding to ... I think the fact that you are using JPanels (which have default ... If you want to control the size of these panels more strictly try ... mind isnt working well enough for me to be sure. ...
    (comp.lang.java.gui)
  • Re: Why use panels
    ... >You can not put components in a GridbagLayout. ... >Components (except top level Containers(Components)) go in Containers. ... This is taking pedantry too far. ... The advantage of panels is, you can change them without disturbing the ...
    (comp.lang.java.help)
  • Re: keystroke navigation between JPanels
    ... > I can't find any references how to navigate between those JPanels ... to implement it on the focusable components ... within the panels. ... ensure you tab arounf it in element order, ...
    (comp.lang.java.gui)