util
Class Util

java.lang.Object
  extended byutil.Util

public class Util
extends java.lang.Object

Defines a class containing commonly used utility methods.

Author:
Mikael Jönsson & Per Klingnäs

Field Summary
static int BUTTON_HEIGHT
           
static int BUTTON_WIDTH
           
static int FONT_LARGE
           
static int FONT_MEDIUM
           
static int FONT_SMALL
           
static int FONT_XSMALL
           
static int HORIZONTAL_BUTTON_DISTANCE
           
static int VERTICAL_BUTTON_DISTANCE
           
 
Constructor Summary
Util()
           
 
Method Summary
static void centerJFrame(javax.swing.JFrame jFrame)
          Makes sure that the frame is opened in the middle of the screen.
static void setFont(javax.swing.JComponent comp, boolean bold, int size)
          Sets the font for the specific JComponent
static void setJComponentSize(javax.swing.JComponent c, int width, int height)
          Forces the size of a JComponent.
static java.lang.String shortString(java.lang.String str, int length, int nbrOfRows)
          Cuts off a String to the desired length ending it with "...".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUTTON_WIDTH

public static final int BUTTON_WIDTH
See Also:
Constant Field Values

BUTTON_HEIGHT

public static final int BUTTON_HEIGHT
See Also:
Constant Field Values

FONT_XSMALL

public static final int FONT_XSMALL
See Also:
Constant Field Values

FONT_SMALL

public static final int FONT_SMALL
See Also:
Constant Field Values

FONT_MEDIUM

public static final int FONT_MEDIUM
See Also:
Constant Field Values

FONT_LARGE

public static final int FONT_LARGE
See Also:
Constant Field Values

HORIZONTAL_BUTTON_DISTANCE

public static final int HORIZONTAL_BUTTON_DISTANCE
See Also:
Constant Field Values

VERTICAL_BUTTON_DISTANCE

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

Util

public Util()
Method Detail

setJComponentSize

public static void setJComponentSize(javax.swing.JComponent c,
                                     int width,
                                     int height)
Forces the size of a JComponent.

Parameters:
c - the component to set the size on
width - the width to set
height - the height to set

setFont

public static void setFont(javax.swing.JComponent comp,
                           boolean bold,
                           int size)
Sets the font for the specific JComponent

Parameters:
comp - the current JComponent
bold - true if font should be set to bould, plain if false
size - the size of the font

centerJFrame

public static void centerJFrame(javax.swing.JFrame jFrame)
Makes sure that the frame is opened in the middle of the screen.

Parameters:
jFrame - the frame to center

shortString

public static java.lang.String shortString(java.lang.String str,
                                           int length,
                                           int nbrOfRows)
Cuts off a String to the desired length ending it with "...". If rows > 1 the method will return a String where each row has the desired length.

Parameters:
str - the String to be shortened
length - the desired length
nbrOfRows - number of rows (line breaks) in the returned string
Returns:
the shortened String