org.tbee.swing
Class JPanelUtils

java.lang.Object
  extended by org.tbee.swing.JPanelUtils

public class JPanelUtils
extends Object


Field Summary
static int DIRECTION_DIAGONAL_LTBR
           
static int DIRECTION_DIAGONAL_RTBL
           
static int DIRECTION_HORIZONTAL
           
static int DIRECTION_VERTICAL
           
 
Constructor Summary
JPanelUtils()
           
 
Method Summary
static JPanel addMarginAround(Component component, int top, int left, int bottom, int right)
          Create a panel with an empty room around it
static JPanel addMarginAround(int top, int left, int bottom, int right, Component component)
          Create a panel with an empty room around it
static JPanel addToEast(Component center, Component other)
           
static JPanel addToEast(Component center, Component other, boolean opaque)
           
static JPanel addToNorth(Component center, Component other)
           
static JPanel addToNorth(Component center, Component other, boolean opaque)
           
static JPanel addToSouth(Component center, Component other)
           
static JPanel addToSouth(Component center, Component other, boolean opaque)
           
static JPanel addToWest(Component center, Component other)
           
static JPanel addToWest(Component center, Component other, boolean opaque)
           
static JPanel createBorderLayoutPanel()
           
static JPanel createBorderLayoutPanel(Component center, Component north, Component east, Component south, Component west)
          Create a panel in which the components are laid out BorderLayout
static JPanel createBorderLayoutPanel(Component center, Component north, Component east, Component south, Component west, boolean opaque)
           
static JPanel createBorderLayoutPanel(Component center, Component north, Component east, Component south, Component west, boolean opaque, int hgap, int vgap)
          Create a panel in which the components are laid out by BorderLayout
static JPanel createBorderLayoutPanel(Component center, Component north, Component east, Component south, Component west, int hgap, int vgap)
           
static JPanel createBorderLayoutPanel(int hgap, int vgap)
          Create a panel in which the components are laid out BorderLayout
static JPanel createGradientPanel()
          Create panel with gradient
static JPanel createGradientPanel(Color c1, Color c2, int direction)
          Create panel with gradient
static JPanel createGradientPanelAerith()
          Use the Aerith colors (http://aerith.dev.java.net/), which is a more classy black / grey look
static JPanel createGradientPanelAerith(Component c)
           
static JPanel createGridPanel(int cols)
           
static JPanel createGridPanel(int cols, Component... components)
           
static JPanel createHorizontalButtonPanel()
           
static JPanel createHorizontalButtonPanel(Component... components)
           
static JPanel createHorizontalPanel()
          Create a panel in which the components are laid out horizontally You can also use Box.createHorizontalBox()
static JPanel createHorizontalPanel(Component... components)
          Create a panel in which the components are laid out horizontally.
static JPanel createHorizontalPanel(int spacing, Component... components)
          Create a panel in which the components are laid out horizontally.
static JPanel createHorizontalSplitterPanel()
          Create a panel that support SplitterBars
static JPanel createHorizontalSplitterPanel(Object... components)
          Create a panel that support SplitterBars
static JPanel createPanel()
          Create a transparent panel
static JPanel createPanel(LayoutManager layout)
          Create a panel and set the layout manager
static JPanel createPortletLookPanel(JLabel title, Color borderColor, JComponent component)
          create a panel with title, border and shadow
static JPanel createPortletLookPanel(String title, JComponent component)
          create a panel with title, border and shadow
static JPanel createVerticalButtonPanel()
           
static JPanel createVerticalButtonPanel(Component... components)
           
static JScrollPane createVerticalFlowJScrollPane()
          Create a scrollpane that only has a vertical scrollbar and will layout components in lines and then down.
static JScrollPane createVerticalFlowJScrollPane(Component... components)
          Create a scrollpane that only has a vertical scrollbar and will layout components in lines and then down.
static JPanel createVerticalPanel()
          Create a panel in which the components are laid out vertically You can also use Box.createVerticalBox(), this will only have no inner spacing.
static JPanel createVerticalPanel(Component... components)
          Create a panel in which the components are laid out vertically Each component is given a small empty border to make sure it is a few pixels apart from the other (BoxLayout does not have a spacing).
static JPanel createVerticalPanel(int spacing, Component... components)
          Create a panel in which the components are laid out vertically Each component is given a small empty border to make sure it is a few pixels apart from the other (BoxLayout does not have a spacing).
static JPanel createVerticalSplitterPanel()
          Create a panel that support SplitterBars
static JPanel createVerticalSplitterPanel(Object... components)
          Create a panel that support SplitterBars
static Container makeItTheBackground(Container container, JPanel panel)
          A small utility function that adds the panel as the only component to the container and then returns the panel as the new container.
static Container makeItTheBackground(Container container, JPanel panel, int top, int left, int bottom, int right)
          A small utility function that adds the panel as the only component to the container, insert an second panel inside that has a border, and then returns the inner most panel as the new container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTION_HORIZONTAL

public static final int DIRECTION_HORIZONTAL
See Also:
Constant Field Values

DIRECTION_VERTICAL

public static final int DIRECTION_VERTICAL
See Also:
Constant Field Values

DIRECTION_DIAGONAL_LTBR

public static final int DIRECTION_DIAGONAL_LTBR
See Also:
Constant Field Values

DIRECTION_DIAGONAL_RTBL

public static final int DIRECTION_DIAGONAL_RTBL
See Also:
Constant Field Values
Constructor Detail

JPanelUtils

public JPanelUtils()
Method Detail

createPanel

public static JPanel createPanel()
Create a transparent panel

Returns:

addMarginAround

public static JPanel addMarginAround(Component component,
                                     int top,
                                     int left,
                                     int bottom,
                                     int right)
Create a panel with an empty room around it

Parameters:
component -
top -
left -
bottom -
right -
Returns:

addMarginAround

public static JPanel addMarginAround(int top,
                                     int left,
                                     int bottom,
                                     int right,
                                     Component component)
Create a panel with an empty room around it

Parameters:
component -
top -
left -
bottom -
right -
Returns:

createPanel

public static JPanel createPanel(LayoutManager layout)
Create a panel and set the layout manager

Returns:

createHorizontalPanel

public static JPanel createHorizontalPanel()
Create a panel in which the components are laid out horizontally You can also use Box.createHorizontalBox()

Returns:

createHorizontalPanel

public static JPanel createHorizontalPanel(Component... components)
Create a panel in which the components are laid out horizontally. Each component is given a small empty border to make sure it is a few pixels apart from the other (BoxLayout does not have a spacing).

Returns:

createHorizontalPanel

public static JPanel createHorizontalPanel(int spacing,
                                           Component... components)
Create a panel in which the components are laid out horizontally. Each component is given a small empty border to make sure it is a few pixels apart from the other (BoxLayout does not have a spacing).

Returns:

createVerticalPanel

public static JPanel createVerticalPanel()
Create a panel in which the components are laid out vertically You can also use Box.createVerticalBox(), this will only have no inner spacing.

Returns:

createVerticalPanel

public static JPanel createVerticalPanel(Component... components)
Create a panel in which the components are laid out vertically Each component is given a small empty border to make sure it is a few pixels apart from the other (BoxLayout does not have a spacing).

Returns:

createVerticalPanel

public static JPanel createVerticalPanel(int spacing,
                                         Component... components)
Create a panel in which the components are laid out vertically Each component is given a small empty border to make sure it is a few pixels apart from the other (BoxLayout does not have a spacing).

Returns:

createBorderLayoutPanel

public static JPanel createBorderLayoutPanel(int hgap,
                                             int vgap)
Create a panel in which the components are laid out BorderLayout

Parameters:
center -
north -
east -
south -
west -
Returns:

createBorderLayoutPanel

public static JPanel createBorderLayoutPanel()

createBorderLayoutPanel

public static JPanel createBorderLayoutPanel(Component center,
                                             Component north,
                                             Component east,
                                             Component south,
                                             Component west)
Create a panel in which the components are laid out BorderLayout

Parameters:
center -
north -
east -
south -
west -
Returns:

createBorderLayoutPanel

public static JPanel createBorderLayoutPanel(Component center,
                                             Component north,
                                             Component east,
                                             Component south,
                                             Component west,
                                             boolean opaque,
                                             int hgap,
                                             int vgap)
Create a panel in which the components are laid out by BorderLayout

Parameters:
center -
north -
east -
south -
west -
opaque -
Returns:

createBorderLayoutPanel

public static JPanel createBorderLayoutPanel(Component center,
                                             Component north,
                                             Component east,
                                             Component south,
                                             Component west,
                                             int hgap,
                                             int vgap)

createBorderLayoutPanel

public static JPanel createBorderLayoutPanel(Component center,
                                             Component north,
                                             Component east,
                                             Component south,
                                             Component west,
                                             boolean opaque)

addToEast

public static JPanel addToEast(Component center,
                               Component other,
                               boolean opaque)

addToNorth

public static JPanel addToNorth(Component center,
                                Component other,
                                boolean opaque)

addToWest

public static JPanel addToWest(Component center,
                               Component other,
                               boolean opaque)

addToSouth

public static JPanel addToSouth(Component center,
                                Component other,
                                boolean opaque)

addToEast

public static JPanel addToEast(Component center,
                               Component other)

addToNorth

public static JPanel addToNorth(Component center,
                                Component other)

addToWest

public static JPanel addToWest(Component center,
                               Component other)

addToSouth

public static JPanel addToSouth(Component center,
                                Component other)

createVerticalFlowJScrollPane

public static JScrollPane createVerticalFlowJScrollPane()
Create a scrollpane that only has a vertical scrollbar and will layout components in lines and then down. Use "getViewport().getView()" to get to the JPanel

Returns:

createVerticalFlowJScrollPane

public static JScrollPane createVerticalFlowJScrollPane(Component... components)
Create a scrollpane that only has a vertical scrollbar and will layout components in lines and then down. Use "getViewport().getView()" to get to the JPanel

Returns:

createHorizontalSplitterPanel

public static JPanel createHorizontalSplitterPanel()
Create a panel that support SplitterBars

Returns:

createHorizontalSplitterPanel

public static JPanel createHorizontalSplitterPanel(Object... components)
Create a panel that support SplitterBars

Returns:

createVerticalSplitterPanel

public static JPanel createVerticalSplitterPanel()
Create a panel that support SplitterBars

Returns:

createVerticalSplitterPanel

public static JPanel createVerticalSplitterPanel(Object... components)
Create a panel that support SplitterBars

Returns:

createVerticalButtonPanel

public static JPanel createVerticalButtonPanel()

createVerticalButtonPanel

public static JPanel createVerticalButtonPanel(Component... components)

createHorizontalButtonPanel

public static JPanel createHorizontalButtonPanel()

createHorizontalButtonPanel

public static JPanel createHorizontalButtonPanel(Component... components)

createGridPanel

public static JPanel createGridPanel(int cols)

createGridPanel

public static JPanel createGridPanel(int cols,
                                     Component... components)

makeItTheBackground

public static Container makeItTheBackground(Container container,
                                            JPanel panel)
A small utility function that adds the panel as the only component to the container and then returns the panel as the new container. So instead of writing: JPanel lJPanel = new JPanelWithBackground(); lContainer.add(lJPanel); lContainer = lJPanel; You can write: lContainer = makeItTheBackground(lContainer, new JPanelWithBackground());

Parameters:
container -
panel -
Returns:
the new container

makeItTheBackground

public static Container makeItTheBackground(Container container,
                                            JPanel panel,
                                            int top,
                                            int left,
                                            int bottom,
                                            int right)
A small utility function that adds the panel as the only component to the container, insert an second panel inside that has a border, and then returns the inner most panel as the new container. So instead of writing: JPanel lJPanel = new JPanelWithBackground(); lContainer.add(lJPanel); lContainer = lJPanel; lJPanel = JPanelUtils.createBorderLayoutPanel(); lContainer.add(JPanelUtils.addMarginAround(lJPanel, 10, 10, 10, 10), BorderLayout.CENTER ); lContainer = lJPanel; You can write: lContainer = makeItTheBackground(lContainer, new JPanelWithBackground(), 10, 10, 10, 10);

Parameters:
container -
panel -
top -
left -
bottom -
right -
Returns:
the new container

createGradientPanel

public static JPanel createGradientPanel()
Create panel with gradient


createGradientPanel

public static JPanel createGradientPanel(Color c1,
                                         Color c2,
                                         int direction)
Create panel with gradient


createGradientPanelAerith

public static JPanel createGradientPanelAerith()
Use the Aerith colors (http://aerith.dev.java.net/), which is a more classy black / grey look

Returns:

createGradientPanelAerith

public static JPanel createGradientPanelAerith(Component c)

createPortletLookPanel

public static JPanel createPortletLookPanel(String title,
                                            JComponent component)
create a panel with title, border and shadow


createPortletLookPanel

public static JPanel createPortletLookPanel(JLabel title,
                                            Color borderColor,
                                            JComponent component)
create a panel with title, border and shadow



Copyright © 2011 KnowledgePlaza. All Rights Reserved.