TsBiff 1.3


ts.biff
Class Util

java.lang.Object
  |
  +--ts.biff.Util

public final class Util
extends java.lang.Object

A collection of tutti-frutti utility methods for tildeslash biff.

Version:
$Id: Util.java,v 1.2 1999/06/03 21:52:27 hauk Exp $
Author:
Jan-Henrik Haukeland <hauk@tildeslash.com>

Method Summary
static void beep()
          Beep, FIXME: play a real sound clip instead.
static void center(java.awt.Window window)
          Center a window on the screen
static java.lang.String colorEncode(java.awt.Color c)
          Encode a Color and return a String representation of it.
static java.lang.Object[] convertToArray(java.util.Vector aVector)
          Returns an object array with the same values as the submitted vector
static java.util.Vector convertToVector(java.lang.Object[] anArray)
           
static java.lang.String fontEncode(java.awt.Font f)
          Encode a Font and return a String representation of it.
static java.lang.String[] fontParts(java.awt.Font f)
          Return a string array with font parts.
static javax.swing.plaf.TableHeaderUI getNullTableHeaderUI()
          Returns a TableHeaderUI object with zero Dimension.
static java.io.File getUserConfigFile()
          Returns a users local controlfile or null if it does not exist.
static void setMargin(javax.swing.JComponent comp, int m)
          Set margins for a JComponent
static void setTitleBorder(javax.swing.JComponent c, java.lang.String t)
          Set a Title border for a Component, with default margin.
static void setUniversalFont(java.awt.Font f)
          Hack to set application universal font for every widget.
static void showAbout()
          Show TsBiff about-dialog with an animated gif.
static void showError(java.awt.Component comp, java.lang.String msg)
          Show an application model dialog with the submitted error message and with a parent.
static void showError(java.lang.String msg)
          Show an application model dialog with the submitted error message
static void showInfo(java.awt.Component comp, java.lang.String msg)
          Show an application model dialog with the submitted information message and a parent component
static void showInfo(java.lang.String msg)
          Show an application model dialog with the submitted information message
static boolean showYesNo(java.awt.Component comp, java.lang.String title, java.lang.String message)
          Show a Yes/No dialog with the submitted message if it has already been sent.
static boolean showYesNo(java.lang.String title, java.lang.String message)
          Show a Yes/No dialog with the submitted message if it has already been sent.
static java.lang.String slurp(java.lang.String filename)
          Returns the content of a file in a String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

beep

public static void beep()
Beep, FIXME: play a real sound clip instead.

getUserConfigFile

public static java.io.File getUserConfigFile()
                                      throws ConfigException
Returns a users local controlfile or null if it does not exist. If the file is unreachable or not a regular file(!) throw a ConfigException with an appropriate error message.
Returns:
User local controlfile or null
Throws:
ConfigException - On error

convertToArray

public static java.lang.Object[] convertToArray(java.util.Vector aVector)
Returns an object array with the same values as the submitted vector
Returns:
an Object array that contains the same objects as the vector

convertToVector

public static java.util.Vector convertToVector(java.lang.Object[] anArray)
Returns:
a Vector that contains the same objects as the array

setUniversalFont

public static void setUniversalFont(java.awt.Font f)
Hack to set application universal font for every widget. An application will normally override some of these. But this method sets the baselevel.
Parameters:
f - a Font that will be application universal

center

public static final void center(java.awt.Window window)
Center a window on the screen
Parameters:
window - A Window

getNullTableHeaderUI

public static javax.swing.plaf.TableHeaderUI getNullTableHeaderUI()
Returns a TableHeaderUI object with zero Dimension. This object is used for turning off titles in a JTable
Returns:
a null size TableHeaderUI object

showError

public static void showError(java.lang.String msg)
Show an application model dialog with the submitted error message
Parameters:
msg - Error message to display

showError

public static void showError(java.awt.Component comp,
                             java.lang.String msg)
Show an application model dialog with the submitted error message and with a parent. The method search upward in the component hierarchy to find the parents frame.
Parameters:
comp - A parent to find the frame for
msg - Error message to display

showAbout

public static void showAbout()
Show TsBiff about-dialog with an animated gif.

showInfo

public static void showInfo(java.awt.Component comp,
                            java.lang.String msg)
Show an application model dialog with the submitted information message and a parent component
Parameters:
comp - A parent to find the frame for
msg - Info message to display

showInfo

public static void showInfo(java.lang.String msg)
Show an application model dialog with the submitted information message
Parameters:
msg - Info message to display

showYesNo

public static boolean showYesNo(java.awt.Component comp,
                                java.lang.String title,
                                java.lang.String message)
Show a Yes/No dialog with the submitted message if it has already been sent.
Parameters:
parent - parent component to center the dialog over
title - for the dialog
message - to display
Returns:
true if user pressed yes

showYesNo

public static boolean showYesNo(java.lang.String title,
                                java.lang.String message)
Show a Yes/No dialog with the submitted message if it has already been sent.
Parameters:
title - for the dialog
message - to display
Returns:
true if user pressed yes

setTitleBorder

public static void setTitleBorder(javax.swing.JComponent c,
                                  java.lang.String t)
Set a Title border for a Component, with default margin. The title is placed in a TOP position
Parameters:
c - component
t - a Title

setMargin

public static void setMargin(javax.swing.JComponent comp,
                             int m)
Set margins for a JComponent
Parameters:
margin - the margin will apply to all sides

colorEncode

public static java.lang.String colorEncode(java.awt.Color c)
Encode a Color and return a String representation of it. I.e. this method is the oposite of Color.decode()
Parameters:
c - the Color to encode
Returns:
a string representation of a Color suitable for Color.decode() or an empty string if the given color was null
See Also:
Color.decode(java.lang.String)

fontEncode

public static java.lang.String fontEncode(java.awt.Font f)
Encode a Font and return a String representation of it. I.e. this method is the oposite of Font.decode()
Parameters:
f - the Font to encode
Returns:
a string representation of a Font suitable for Font.decode() or an empty string if the given font was null
See Also:
Font.decode(java.lang.String)

fontParts

public static java.lang.String[] fontParts(java.awt.Font f)
Return a string array with font parts.
Parameters:
f - the Font to split into parts
Returns:
an array of font-parts, name+style+size e.g. [serif,plain,10]

slurp

public static java.lang.String slurp(java.lang.String filename)
Returns the content of a file in a String
Parameters:
filename - Name of file to read (including path)
Returns:
A string with the content of the file, or null if for some reason the file could not be loaded.

TsBiff 1.3