public class SGUI extends Object
Modifier and Type | Field and Description |
---|---|
static String |
AUTO_ADJUST
This property can be set on components to be automatically adjusted to equal sizes.
|
static boolean |
HAS_GUI
This is set to true if the VM has a working GUI environment available.
|
Constructor and Description |
---|
SGUI() |
Modifier and Type | Method and Description |
---|---|
static void |
adjustComponentSizes(Container parent)
Adjust all marked components to equal sizes according to their
miminum, maximum, and preferred sizes.
|
static void |
adjustComponentSizes(JComponent[] components)
Adjust components to equal sizes according to their
miminum, maximum, and preferred sizes.
|
static Point |
calculateMiddlePosition(Window win)
Calculate the middle position of a window relativ to
|
static Point |
calculateMiddlePosition(Window outer,
Window win)
Calculate the middle position of a window relativ to
|
static String |
colorToHTML(Color color)
Convert a color to an html representation.
|
static Action |
createAction(String name,
Icon icon,
ActionListener listener)
Create an action.
|
static JMenuBar |
createMenuBar(Action[] actions)
Create a menu bar, given a list of actions.
|
static JTable |
createReadOnlyTable()
Create a table that displays its contents using nto editable text fields.
|
static JToolBar |
createToolBar(String name,
Action[] actions)
Create a tool bar, given a list of actions.
|
static String |
fontToHTML(Font font)
Convert a font to an html representation.
|
static double |
getProportionalDividerLocation(JSplitPane pane)
Get the proportional split location.
|
static Window |
getWindowParent(Component comp)
Get the window parent if any.
|
static Image |
imageFromBytes(byte[] data,
Class<?> clazz) |
static byte[] |
imageToStandardBytes(Image image,
String mimeType)
Convert image to bytes.
|
static void |
invokeLater(Runnable runnable)
Use SwingUtilities to put the given runnable in the AWT Event queue.
|
static Object |
makeIcon(Class baseclass,
String imgloc)
Utility method that creates a UIDefaults.LazyValue that creates
an ImageIcon for the specified
gifFile filename. |
static void |
renderObject(Graphics g,
Component comp,
double cellw,
double cellh,
int x,
int y,
int gridwidth)
Render an object on a grid.
|
static BufferedImage |
scaleImage(Image src,
int w,
int h,
int type)
Scale an image.
|
static void |
showError(Component parent,
String errortitle,
String errormessage,
Exception exception)
Display an error dialog.
|
static void |
showMessageDialog(Component parent,
Object message,
String title,
int msgtype)
Show an non-model message dialog.
|
static Color |
stringToColor(String str)
Color conversion method for "web-style" color definitions.
|
public static final String AUTO_ADJUST
public static boolean HAS_GUI
public static JMenuBar createMenuBar(Action[] actions)
actions
- The actions (null is mapped to separator).public static JToolBar createToolBar(String name, Action[] actions)
name
- The name of the toolbar.actions
- The actions (null is mapped to separator).public static Action createAction(String name, Icon icon, ActionListener listener)
name
- The name.icon
- The path to the icon.listener
- The action listener.public static Object makeIcon(Class baseclass, String imgloc)
gifFile
filename.public static void renderObject(Graphics g, Component comp, double cellw, double cellh, int x, int y, int gridwidth)
g
- The graphics object.comp
- The object to render.cellw
- The cell width.cellh
- The cell height.public static Point calculateMiddlePosition(Window win)
public static Point calculateMiddlePosition(Window outer, Window win)
public static Window getWindowParent(Component comp)
comp
- The component.public static void showMessageDialog(Component parent, Object message, String title, int msgtype)
public static void showError(Component parent, String errortitle, String errormessage, Exception exception)
errortitle
- The title to use for an error dialog (required).errormessage
- An optional error message displayed before the exception.exception
- The exception (if any).public static void adjustComponentSizes(JComponent[] components)
public static void adjustComponentSizes(Container parent)
AUTO_ADJUST
property
to an arbitrary value.public static JTable createReadOnlyTable()
public static byte[] imageToStandardBytes(Image image, String mimeType)
public static double getProportionalDividerLocation(JSplitPane pane)
public static Color stringToColor(String str)
public static String colorToHTML(Color color)
color
- The color.public static String fontToHTML(Font font)
font
- The font.public static BufferedImage scaleImage(Image src, int w, int h, int type)
scr
- The src image.w
- The width.h
- The height.type
- The type (Image.SCALE_XYZ).public static void invokeLater(Runnable runnable)
runnable
- Copyright © 2012. All Rights Reserved.