org.tbee.swing
Class JPanelUtils

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

public class JPanelUtils
extends java.lang.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 javax.swing.JPanel addMarginAround(java.awt.Component component, int top, int left, int bottom, int right)
          Create a panel with an empty room around it
static javax.swing.JPanel addMarginAround(int top, int left, int bottom, int right, java.awt.Component component)
          Create a panel with an empty room around it
static javax.swing.JPanel addToEast(java.awt.Component center, java.awt.Component other)
           
static javax.swing.JPanel addToEast(java.awt.Component center, java.awt.Component other, boolean opaque)
           
static javax.swing.JPanel addToNorth(java.awt.Component center, java.awt.Component other)
           
static javax.swing.JPanel addToNorth(java.awt.Component center, java.awt.Component other, boolean opaque)
           
static javax.swing.JPanel addToSouth(java.awt.Component center, java.awt.Component other)
           
static javax.swing.JPanel addToSouth(java.awt.Component center, java.awt.Component other, boolean opaque)
           
static javax.swing.JPanel addToWest(java.awt.Component center, java.awt.Component other)
           
static javax.swing.JPanel addToWest(java.awt.Component center, java.awt.Component other, boolean opaque)
           
static javax.swing.JPanel createBorderLayoutPanel()
          Create a panel in which the components are laid out BorderLayout
static javax.swing.JPanel createBorderLayoutPanel(java.awt.Component center, java.awt.Component north, java.awt.Component east, java.awt.Component south, java.awt.Component west)
          Create a panel in which the components are laid out BorderLayout
static javax.swing.JPanel createBorderLayoutPanel(java.awt.Component center, java.awt.Component north, java.awt.Component east, java.awt.Component south, java.awt.Component west, boolean opaque)
          Create a panel in which the components are laid out by BorderLayout
static javax.swing.JPanel createGradientPanel()
          Create panel with gradient
static javax.swing.JPanel createGradientPanel(java.awt.Color c1, java.awt.Color c2, int direction)
          Create panel with gradient
static javax.swing.JPanel createGradientPanelAerith()
          Use the Aerith colors (http://aerith.dev.java.net/), which is a more classy black / grey look
static javax.swing.JPanel createGradientPanelAerith(java.awt.Component c)
           
static javax.swing.JPanel createGridPanel(int cols)
           
static javax.swing.JPanel createGridPanel(int cols, java.awt.Component... components)
           
static javax.swing.JPanel createHorizontalButtonPanel()
           
static javax.swing.JPanel createHorizontalButtonPanel(java.awt.Component... components)
           
static javax.swing.JPanel createHorizontalPanel()
          Create a panel in which the components are laid out horizontally You can also use Box.createHorizontalBox()
static javax.swing.JPanel createHorizontalPanel(java.awt.Component... components)
          Create a panel in which the components are laid out horizontally.
static javax.swing.JPanel createHorizontalPanel(int spacing, java.awt.Component... components)
          Create a panel in which the components are laid out horizontally.
static javax.swing.JPanel createHorizontalSplitterPanel()
          Create a panel that support SplitterBars
static javax.swing.JPanel createHorizontalSplitterPanel(java.lang.Object... components)
          Create a panel that support SplitterBars
static javax.swing.JPanel createPanel()
          Create a transparent panel
static javax.swing.JPanel createPanel(java.awt.LayoutManager layout)
          Create a panel and set the layout manager
static javax.swing.JPanel createPortletLookPanel(javax.swing.JLabel title, java.awt.Color borderColor, javax.swing.JComponent component)
          create a panel with title, border and shadow
static javax.swing.JPanel createPortletLookPanel(java.lang.String title, javax.swing.JComponent component)
          create a panel with title, border and shadow
static javax.swing.JPanel createVerticalButtonPanel()
           
static javax.swing.JPanel createVerticalButtonPanel(java.awt.Component... components)
           
static javax.swing.JScrollPane createVerticalFlowJScrollPane()
          Create a scrollpane that only has a vertical scrollbar and will layout components in lines and then down.
static javax.swing.JScrollPane createVerticalFlowJScrollPane(java.awt.Component... components)
          Create a scrollpane that only has a vertical scrollbar and will layout components in lines and then down.
static javax.swing.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 javax.swing.JPanel createVerticalPanel(java.awt.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 javax.swing.JPanel createVerticalPanel(int spacing, java.awt.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 javax.swing.JPanel createVerticalSplitterPanel()
          Create a panel that support SplitterBars
static javax.swing.JPanel createVerticalSplitterPanel(java.lang.Object... components)
          Create a panel that support SplitterBars
static java.awt.Container makeItTheBackground(java.awt.Container container, javax.swing.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 java.awt.Container makeItTheBackground(java.awt.Container container, javax.swing.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 javax.swing.JPanel createPanel()
Create a transparent panel

Returns:

addMarginAround

public static javax.swing.JPanel addMarginAround(java.awt.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 javax.swing.JPanel addMarginAround(int top,
                                                 int left,
                                                 int bottom,
                                                 int right,
                                                 java.awt.Component component)
Create a panel with an empty room around it

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

createPanel

public static javax.swing.JPanel createPanel(java.awt.LayoutManager layout)
Create a panel and set the layout manager

Returns:

createHorizontalPanel

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

Returns:

createHorizontalPanel

public static javax.swing.JPanel createHorizontalPanel(java.awt.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 javax.swing.JPanel createHorizontalPanel(int spacing,
                                                       java.awt.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 javax.swing.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 javax.swing.JPanel createVerticalPanel(java.awt.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 javax.swing.JPanel createVerticalPanel(int spacing,
                                                     java.awt.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 javax.swing.JPanel createBorderLayoutPanel()
Create a panel in which the components are laid out BorderLayout

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

createBorderLayoutPanel

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

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

createBorderLayoutPanel

public static javax.swing.JPanel createBorderLayoutPanel(java.awt.Component center,
                                                         java.awt.Component north,
                                                         java.awt.Component east,
                                                         java.awt.Component south,
                                                         java.awt.Component west,
                                                         boolean opaque)
Create a panel in which the components are laid out by BorderLayout

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

addToEast

public static javax.swing.JPanel addToEast(java.awt.Component center,
                                           java.awt.Component other,
                                           boolean opaque)

addToNorth

public static javax.swing.JPanel addToNorth(java.awt.Component center,
                                            java.awt.Component other,
                                            boolean opaque)

addToWest

public static javax.swing.JPanel addToWest(java.awt.Component center,
                                           java.awt.Component other,
                                           boolean opaque)

addToSouth

public static javax.swing.JPanel addToSouth(java.awt.Component center,
                                            java.awt.Component other,
                                            boolean opaque)

addToEast

public static javax.swing.JPanel addToEast(java.awt.Component center,
                                           java.awt.Component other)

addToNorth

public static javax.swing.JPanel addToNorth(java.awt.Component center,
                                            java.awt.Component other)

addToWest

public static javax.swing.JPanel addToWest(java.awt.Component center,
                                           java.awt.Component other)

addToSouth

public static javax.swing.JPanel addToSouth(java.awt.Component center,
                                            java.awt.Component other)

createVerticalFlowJScrollPane

public static javax.swing.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 javax.swing.JScrollPane createVerticalFlowJScrollPane(java.awt.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 javax.swing.JPanel createHorizontalSplitterPanel()
Create a panel that support SplitterBars

Returns:

createHorizontalSplitterPanel

public static javax.swing.JPanel createHorizontalSplitterPanel(java.lang.Object... components)
Create a panel that support SplitterBars

Returns:

createVerticalSplitterPanel

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

Returns:

createVerticalSplitterPanel

public static javax.swing.JPanel createVerticalSplitterPanel(java.lang.Object... components)
Create a panel that support SplitterBars

Returns:

createVerticalButtonPanel

public static javax.swing.JPanel createVerticalButtonPanel()

createVerticalButtonPanel

public static javax.swing.JPanel createVerticalButtonPanel(java.awt.Component... components)

createHorizontalButtonPanel

public static javax.swing.JPanel createHorizontalButtonPanel()

createHorizontalButtonPanel

public static javax.swing.JPanel createHorizontalButtonPanel(java.awt.Component... components)

createGridPanel

public static javax.swing.JPanel createGridPanel(int cols)

createGridPanel

public static javax.swing.JPanel createGridPanel(int cols,
                                                 java.awt.Component... components)

makeItTheBackground

public static java.awt.Container makeItTheBackground(java.awt.Container container,
                                                     javax.swing.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 java.awt.Container makeItTheBackground(java.awt.Container container,
                                                     javax.swing.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 javax.swing.JPanel createGradientPanel()
Create panel with gradient


createGradientPanel

public static javax.swing.JPanel createGradientPanel(java.awt.Color c1,
                                                     java.awt.Color c2,
                                                     int direction)
Create panel with gradient


createGradientPanelAerith

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

Returns:

createGradientPanelAerith

public static javax.swing.JPanel createGradientPanelAerith(java.awt.Component c)

createPortletLookPanel

public static javax.swing.JPanel createPortletLookPanel(java.lang.String title,
                                                        javax.swing.JComponent component)
create a panel with title, border and shadow


createPortletLookPanel

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



Copyright © 2010. All Rights Reserved.