p3j.misc.gui
Class GUI

java.lang.Object
  extended by p3j.misc.gui.GUI

public final class GUI
extends Object

Class to store static GUI helper functions. Created on 4 February 4, 2007

Author:
Roland Ewald

Field Summary
static int INPUT_COLUMN_INDEX
          The index of the column at which the input elements (textfields etc.) are added to the content panel (for stand-alone dialogs).
static int KEYS_COLUMN_INDEX
          The index of the column at which the keys are added to the content panel (for stand-alone dialogs).
static int ROW_SKIP_LAYOUT
          The number of rows used for a single 'content' row in the layout (for stand-alone dialogs).
static int STD_LAYOUT_GAP
          Number of pixels in the gaps of the standard border layout.
 
Method Summary
static int addRowToPanel(JPanel panel, String key, JComponent input, int currentRow)
          Adds a pair of key and input components to the given panel panel.
static void centerOnScreen(Window window)
          Centre a given window on the screen.
static JFileChooser getDirectoryChooser(String dialogTitle)
          Gets a file chooser configured to select a directory.
static JLabel getLabelToWait()
          Gets the label to wait.
static BorderLayout getStdBorderLayout()
          Get standard border layout.
static boolean isHeadless()
          Checks the headless mode.
static void printErrorMessage(Component parent, String title, Object message)
          Prints an error message.
static void printErrorMessage(Component parent, String title, Object message, Throwable throwable)
          Prints an error message and the stack trace of the corresponding exception.
static void printErrorMessage(String title, Throwable throwable)
          Prints an error message with the P3J main window as parent instance.
static void printMessage(Component parent, String title, Object message)
          Prints a message.
static boolean printQuestion(Component parent, String title, Object message)
          Prints a question message.
static void replaceListContents(DefaultListModel model, List<?> newContent)
          Replaces the contents o a default list model.
static void setHeadless(boolean headless)
          Sets the head-less mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STD_LAYOUT_GAP

public static final int STD_LAYOUT_GAP
Number of pixels in the gaps of the standard border layout.

See Also:
Constant Field Values

ROW_SKIP_LAYOUT

public static final int ROW_SKIP_LAYOUT
The number of rows used for a single 'content' row in the layout (for stand-alone dialogs).

See Also:
Constant Field Values

KEYS_COLUMN_INDEX

public static final int KEYS_COLUMN_INDEX
The index of the column at which the keys are added to the content panel (for stand-alone dialogs).

See Also:
Constant Field Values

INPUT_COLUMN_INDEX

public static final int INPUT_COLUMN_INDEX
The index of the column at which the input elements (textfields etc.) are added to the content panel (for stand-alone dialogs).

See Also:
Constant Field Values
Method Detail

getStdBorderLayout

public static BorderLayout getStdBorderLayout()
Get standard border layout. With 5 pixels gaps vertically/horizontally.

Returns:
standard border layout

centerOnScreen

public static void centerOnScreen(Window window)
Centre a given window on the screen.

Parameters:
window - a Window

setHeadless

public static void setHeadless(boolean headless)
Sets the head-less mode.

Parameters:
headless - the new head-less mode

isHeadless

public static boolean isHeadless()
Checks the headless mode.

Returns:
true if currently running head-less

printErrorMessage

public static void printErrorMessage(Component parent,
                                     String title,
                                     Object message)
Prints an error message.

Parameters:
parent - the parent component for the dialog
title - the title of the error dialog
message - the message to be displayed

printErrorMessage

public static void printErrorMessage(Component parent,
                                     String title,
                                     Object message,
                                     Throwable throwable)
Prints an error message and the stack trace of the corresponding exception.

Parameters:
parent - the parent component for the dialog
title - the title of the error dialog
message - the message to be displayed
throwable - the throwable (may provide additional info)

printErrorMessage

public static void printErrorMessage(String title,
                                     Throwable throwable)
Prints an error message with the P3J main window as parent instance. Uses P3J.getInstance() to retrieve it.

Parameters:
title - the title of the error dialog
throwable - the throwable (may provide additional info)

printMessage

public static void printMessage(Component parent,
                                String title,
                                Object message)
Prints a message.

Parameters:
parent - the parent component for the dialog
title - the title of the error dialog
message - the message to be displayed

printQuestion

public static boolean printQuestion(Component parent,
                                    String title,
                                    Object message)
Prints a question message.

Parameters:
parent - the parent component for the dialog
title - the title of the dialog
message - the question
Returns:
true, if user chose yes, otherwise false

replaceListContents

public static void replaceListContents(DefaultListModel model,
                                       List<?> newContent)
Replaces the contents o a default list model.

Parameters:
model - the list model to be filled
newContent - the list containing the content

getDirectoryChooser

public static JFileChooser getDirectoryChooser(String dialogTitle)
Gets a file chooser configured to select a directory.

Parameters:
dialogTitle - the dialog title
Returns:
the directory chooser

getLabelToWait

public static JLabel getLabelToWait()
Gets the label to wait.

Returns:
the label to wait

addRowToPanel

public static int addRowToPanel(JPanel panel,
                                String key,
                                JComponent input,
                                int currentRow)
Adds a pair of key and input components to the given panel panel.

Parameters:
panel - the panel
key - the name of the label to be used
input - the input component
currentRow - the current row in the layout
Returns:
the new row in the layout


Copyright © 2012. All Rights Reserved.