com.jaxfront.swing.ui.tools
Class GUITools

java.lang.Object
  extended by com.jaxfront.swing.ui.tools.GUITools

public class GUITools
extends java.lang.Object

This class provides methodes which helps to draw or create some gui component

Version:
1.60

Field Summary
static javax.swing.ImageIcon EMPTY_ICON
           
static byte[] NULL_IMAGE_DEF
           
static java.util.Random random
           
 
Method Summary
static boolean acceptAsFocus(javax.swing.JComponent comp)
           
static void applyDialogGUIPersistency(java.awt.Component containerComp, java.awt.Component contentComp)
           
static void applyDialogGUIPersistency(java.awt.Component containerComp, java.awt.Component contentComp, java.lang.String componentName)
           
static void applyDialogGUIPersistency(Type type, java.awt.Component containerComp, java.awt.Component contentComp, java.lang.String componentName)
           
static void applySWTSwingModalDialog(Document dom, javax.swing.JDialog dialog)
           
static void applySWTSwingModalDialog(javax.swing.JDialog dialog)
           
static void centerRelativeToParent(java.awt.Component parent, java.awt.Component component)
           
static void centerRelativeToParentFrame(java.awt.Component frame, java.awt.Component component)
          Centers a component relative to its parent frame.
static void centerRelativeToParentWindow(java.awt.Window window, java.awt.Dialog dialog)
          Centers a component relative to its parent frame.
static void centerWindow(java.awt.Window w)
          Centers a specified window on the screen.
static java.lang.String convertToISODate(java.util.Calendar cal)
          Converts a specified date (java.util.Calendar) into ISO date -> yyyy-mm-dd.
static java.lang.String convertToISODate(java.util.Date date)
          Converts a specified date (java.util.Calendar) into ISO date -> yyyy-mm-dd.
static java.util.Date createDateFromIso(java.lang.String isoDate)
          Converts a specified date (java.util.Calendar) into ISO date -> yyyy-mm-dd.
static javax.swing.JDialog createDialogFor(java.awt.Component component)
           
static javax.swing.JDialog createDialogFor(java.awt.Component component, boolean modal)
           
static JAXJDialog createDialogFor(java.awt.Component component, boolean modal, java.lang.String componentName)
           
static HeaderPanel createHeader(Type type, java.lang.String text)
          Creates a header with the specified text.
static HeaderPanel createHeader(Type type, java.lang.String text, int height, java.lang.String imageURL)
          Creates a header with the specified text.
static HeaderPanel createHeader(Type type, java.lang.String text, int height, java.lang.String imageURL, java.awt.Color textColor, java.awt.Color startColor, java.awt.Color endColor)
           
static HeaderPanel createHeader(Type type, java.lang.String text, java.lang.String imageURL)
          Creates a header with the specified text.
static javax.swing.JComponent createIndentedComponent(javax.swing.JComponent component, int topIndent, int bottomIndent, int leftIndent, int rightIndent)
           
static HeaderPanel createSeparatorClassic(Type type, java.lang.String text)
          Creates a classic seperator with the specified text.
static HeaderPanel createSeparatorClassic(Type type, java.lang.String text, int height)
          Creates a classic seperator with the specified text.
static HeaderPanel createSeparatorModern(Type type, java.lang.String text)
          Creates a modern seperator with the specified text.
static HeaderPanel createSeparatorModern(Type type, java.lang.String text, int height)
          Creates a modern seperator with the specified text.
static HeaderPanel createSeparatorVertical(Type type, java.lang.String text)
          Creates a modern seperator with the specified text.
static void draw3dRect(java.awt.Graphics g, int x, int y, int w, int h, boolean raised)
          Draws a 3d rectangle on the specified graphics at the specified position and size .
static void drawGradient(java.awt.Graphics graphics, java.awt.Color color1, java.awt.Color color2, int x1, int y1, int x2, int y2)
          Draw a horizontal gradient on the specified graphics at the specified position and size.
static void drawHorizontalGradient(java.awt.Graphics graphics, java.awt.Color color1, java.awt.Color color2, int x, int y, int width, int height)
          Draw a horizontal gradient on the specified graphics at the specified position and size.
static void drawImage(java.awt.Graphics graphics, javax.swing.ImageIcon icon, int x, int y)
          Draws a vertical gradient on the specified graphics at the specified position and size.
static void drawLabel(java.awt.Graphics g, java.lang.String caption, int x, int y, java.awt.Color fg, java.awt.Color bg)
          Draw a text on the specified graphics at the specified position with the specified color.
static void drawLight3dRect(java.awt.Graphics g, int x, int y, int w, int h, boolean raised)
          Draws a rectangle on the specified graphics at the specified position and size.
static void drawVerticalGradient(java.awt.Graphics graphics, java.awt.Color color1, java.awt.Color color2, int x, int y, int width, int height)
          Draws a vertical gradient on the specified graphics at the specified position and size.
static java.util.Stack getAllParents(java.awt.Component c)
           
static java.util.Vector getAllParentsAsVector(java.awt.Component c)
           
static java.awt.Rectangle getComponentPositionRelativeToFrame(javax.swing.JComponent component)
          Determine the relative x,y position to the Frame of a component
static double getDefaultComponentHeight()
          Returns the default height of a textField.
static java.awt.Component getFirstListParent(java.awt.Component c)
           
static Visualizer getParentVisualizer(java.awt.Component c)
           
static java.awt.Color getRandomColor()
           
static java.awt.Color getRandomGrayColor()
           
static void resizeFullscreen(java.awt.Window w, boolean removeBorder)
          Resizes a specified window to full screen.
static void scrollToTopComponent(javax.swing.JComponent component, javax.swing.JScrollPane scrollPane, javax.swing.JPanel innerPanel)
           
static void searchFocusableComponents(javax.swing.JComponent comp, java.util.List result)
           
static void setBoundRelativeToParent(java.awt.Component component, java.awt.Rectangle relativeBounds)
           
static void setToolTip(javax.swing.JComponent c, java.lang.String text)
          Sets the specified text to the specified component as tool tip.
static void showAsModal(java.awt.Frame frame, java.awt.Frame owner)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_IMAGE_DEF

public static final byte[] NULL_IMAGE_DEF

EMPTY_ICON

public static final javax.swing.ImageIcon EMPTY_ICON

random

public static final java.util.Random random
Method Detail

centerWindow

public static void centerWindow(java.awt.Window w)
Centers a specified window on the screen.

Parameters:
w - a window to be centered on the screen

centerRelativeToParentFrame

public static void centerRelativeToParentFrame(java.awt.Component frame,
                                               java.awt.Component component)
Centers a component relative to its parent frame.

Parameters:
frame - a given frame
component - a given component that should be centered within the parent frame

centerRelativeToParent

public static void centerRelativeToParent(java.awt.Component parent,
                                          java.awt.Component component)

centerRelativeToParentWindow

public static void centerRelativeToParentWindow(java.awt.Window window,
                                                java.awt.Dialog dialog)
Centers a component relative to its parent frame.

Parameters:
window - a given frame
dialog - a given dialog that should be centered within the parent frame

convertToISODate

public static java.lang.String convertToISODate(java.util.Calendar cal)
Converts a specified date (java.util.Calendar) into ISO date -> yyyy-mm-dd.

Parameters:
cal - a java.util.Calendar instance with the date
Returns:
the converted date as a string

setBoundRelativeToParent

public static void setBoundRelativeToParent(java.awt.Component component,
                                            java.awt.Rectangle relativeBounds)

convertToISODate

public static java.lang.String convertToISODate(java.util.Date date)
Converts a specified date (java.util.Calendar) into ISO date -> yyyy-mm-dd.

Parameters:
cal - a java.util.Calendar instance with the date
Returns:
the converted date as a string

createDateFromIso

public static java.util.Date createDateFromIso(java.lang.String isoDate)
Converts a specified date (java.util.Calendar) into ISO date -> yyyy-mm-dd.

Parameters:
cal - a java.util.Calendar instance with the date
Returns:
the converted date as a string

getParentVisualizer

public static Visualizer getParentVisualizer(java.awt.Component c)

getAllParents

public static java.util.Stack getAllParents(java.awt.Component c)

getRandomColor

public static java.awt.Color getRandomColor()

getRandomGrayColor

public static java.awt.Color getRandomGrayColor()

getAllParentsAsVector

public static java.util.Vector getAllParentsAsVector(java.awt.Component c)

getFirstListParent

public static java.awt.Component getFirstListParent(java.awt.Component c)

createHeader

public static HeaderPanel createHeader(Type type,
                                       java.lang.String text)
Creates a header with the specified text.

Parameters:
text - the text that should be displayed
Returns:
a panel that contains the header

createHeader

public static HeaderPanel createHeader(Type type,
                                       java.lang.String text,
                                       int height,
                                       java.lang.String imageURL,
                                       java.awt.Color textColor,
                                       java.awt.Color startColor,
                                       java.awt.Color endColor)

createHeader

public static HeaderPanel createHeader(Type type,
                                       java.lang.String text,
                                       int height,
                                       java.lang.String imageURL)
Creates a header with the specified text.

Parameters:
text - the text that should be displayed
Returns:
a panel that contains the header

createDialogFor

public static JAXJDialog createDialogFor(java.awt.Component component,
                                         boolean modal,
                                         java.lang.String componentName)

applyDialogGUIPersistency

public static void applyDialogGUIPersistency(java.awt.Component containerComp,
                                             java.awt.Component contentComp)

applyDialogGUIPersistency

public static void applyDialogGUIPersistency(java.awt.Component containerComp,
                                             java.awt.Component contentComp,
                                             java.lang.String componentName)

applyDialogGUIPersistency

public static void applyDialogGUIPersistency(Type type,
                                             java.awt.Component containerComp,
                                             java.awt.Component contentComp,
                                             java.lang.String componentName)

createHeader

public static HeaderPanel createHeader(Type type,
                                       java.lang.String text,
                                       java.lang.String imageURL)
Creates a header with the specified text.

Parameters:
text - the text that should be displayed
Returns:
a panel that contains the header

createSeparatorClassic

public static HeaderPanel createSeparatorClassic(Type type,
                                                 java.lang.String text)
Creates a classic seperator with the specified text.

Parameters:
text - the text that should be displayed
Returns:
a panel that contains the seperator

createSeparatorClassic

public static HeaderPanel createSeparatorClassic(Type type,
                                                 java.lang.String text,
                                                 int height)
Creates a classic seperator with the specified text.

Parameters:
text - the text that should be displayed
Returns:
a panel that contains the seperator

createSeparatorModern

public static HeaderPanel createSeparatorModern(Type type,
                                                java.lang.String text)
Creates a modern seperator with the specified text.

Parameters:
text - the text that should be displayed
Returns:
a panel that contains the seperator

createSeparatorModern

public static HeaderPanel createSeparatorModern(Type type,
                                                java.lang.String text,
                                                int height)
Creates a modern seperator with the specified text.

Parameters:
text - the text that should be displayed
Returns:
a panel that contains the seperator

createSeparatorVertical

public static HeaderPanel createSeparatorVertical(Type type,
                                                  java.lang.String text)
Creates a modern seperator with the specified text.

Parameters:
text - the text that should be displayed
Returns:
a panel that contains the seperator

draw3dRect

public static void draw3dRect(java.awt.Graphics g,
                              int x,
                              int y,
                              int w,
                              int h,
                              boolean raised)
Draws a 3d rectangle on the specified graphics at the specified position and size .

Parameters:
g - the graphics object to draw the rectangle
x - the start position of the rectangle in pixel
y - the start position of the rectangle in pixel
w - the width of the rectangle in pixel
h - the height of the rectangle in pixel

drawHorizontalGradient

public static void drawHorizontalGradient(java.awt.Graphics graphics,
                                          java.awt.Color color1,
                                          java.awt.Color color2,
                                          int x,
                                          int y,
                                          int width,
                                          int height)
Draw a horizontal gradient on the specified graphics at the specified position and size. The color of the gradient starts with color1 and fade to color2.

Parameters:
graphics - the graphics object to draw the gradient
color1 - start color
color2 - end color
x - the start position of the gradient in pixel
y - the start position of the gradient in pixel
width - the width of the gradient in pixel
height - the height of the gradient in pixel

drawGradient

public static void drawGradient(java.awt.Graphics graphics,
                                java.awt.Color color1,
                                java.awt.Color color2,
                                int x1,
                                int y1,
                                int x2,
                                int y2)
Draw a horizontal gradient on the specified graphics at the specified position and size. The color of the gradient starts with color1 and fade to color2.

Parameters:
graphics - the graphics object to draw the gradient
color1 - start color
color2 - end color
x - the start position of the gradient in pixel
y - the start position of the gradient in pixel
width - the width of the gradient in pixel
height - the height of the gradient in pixel

drawImage

public static void drawImage(java.awt.Graphics graphics,
                             javax.swing.ImageIcon icon,
                             int x,
                             int y)
Draws a vertical gradient on the specified graphics at the specified position and size. The color of the gradient starts with color1 and fade to color2.

Parameters:
graphics - the graphics object to draw the gradient
color1 - start color
color2 - end color
x - the start position of the gradient in pixel
y - the start position of the gradient in pixel
width - the width of the gradient in pixel
height - the height of the gradient in pixel

drawLabel

public static void drawLabel(java.awt.Graphics g,
                             java.lang.String caption,
                             int x,
                             int y,
                             java.awt.Color fg,
                             java.awt.Color bg)
Draw a text on the specified graphics at the specified position with the specified color.

Parameters:
g - the graphics object to draw the rectangle
caption - the graphics object to draw the rectangle
x - the start position of the rectangle in pixel
y - the start position of the rectangle in pixel
fg - the width of the rectangle in pixel
bg - the height of the rectangle in pixel

drawLight3dRect

public static void drawLight3dRect(java.awt.Graphics g,
                                   int x,
                                   int y,
                                   int w,
                                   int h,
                                   boolean raised)
Draws a rectangle on the specified graphics at the specified position and size.

Parameters:
g - the graphics object to draw the rectangle
x - the start position of the rectangle in pixel
y - the start position of the rectangle in pixel
w - the width of the rectangle in pixel
h - the height of the rectangle in pixel
raised - if true the ractangle is raised

drawVerticalGradient

public static void drawVerticalGradient(java.awt.Graphics graphics,
                                        java.awt.Color color1,
                                        java.awt.Color color2,
                                        int x,
                                        int y,
                                        int width,
                                        int height)
Draws a vertical gradient on the specified graphics at the specified position and size. The color of the gradient starts with color1 and fade to color2.

Parameters:
graphics - the graphics object to draw the gradient
color1 - start color
color2 - end color
x - the start position of the gradient in pixel
y - the start position of the gradient in pixel
width - the width of the gradient in pixel
height - the height of the gradient in pixel

resizeFullscreen

public static void resizeFullscreen(java.awt.Window w,
                                    boolean removeBorder)
Resizes a specified window to full screen.

Parameters:
w - the window to be resized
removeBorder - if true the border from specified window would be removed

setToolTip

public static void setToolTip(javax.swing.JComponent c,
                              java.lang.String text)
Sets the specified text to the specified component as tool tip.

Parameters:
c - the component with the new tool tip
text - the text that schuld be displayed

getDefaultComponentHeight

public static double getDefaultComponentHeight()
Returns the default height of a textField.

Returns:
the default height of a textField

getComponentPositionRelativeToFrame

public static java.awt.Rectangle getComponentPositionRelativeToFrame(javax.swing.JComponent component)
Determine the relative x,y position to the Frame of a component

Parameters:
component - the component, which position should be determine
Returns:
rectangle with x,y position

scrollToTopComponent

public static void scrollToTopComponent(javax.swing.JComponent component,
                                        javax.swing.JScrollPane scrollPane,
                                        javax.swing.JPanel innerPanel)

createIndentedComponent

public static javax.swing.JComponent createIndentedComponent(javax.swing.JComponent component,
                                                             int topIndent,
                                                             int bottomIndent,
                                                             int leftIndent,
                                                             int rightIndent)

showAsModal

public static void showAsModal(java.awt.Frame frame,
                               java.awt.Frame owner)

createDialogFor

public static javax.swing.JDialog createDialogFor(java.awt.Component component,
                                                  boolean modal)

createDialogFor

public static javax.swing.JDialog createDialogFor(java.awt.Component component)

acceptAsFocus

public static boolean acceptAsFocus(javax.swing.JComponent comp)

searchFocusableComponents

public static void searchFocusableComponents(javax.swing.JComponent comp,
                                             java.util.List result)

applySWTSwingModalDialog

public static void applySWTSwingModalDialog(javax.swing.JDialog dialog)

applySWTSwingModalDialog

public static void applySWTSwingModalDialog(Document dom,
                                            javax.swing.JDialog dialog)