|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectschmitzm.swing.SwingUtil
public class SwingUtil
Diese Klasse beinhaltet statische Hilfsfunktionen fuer das Arbeiten mit Swing-GUIs.
Field Summary | |
---|---|
static int |
BOUNDS_INNER
Modus "Innen". |
static int |
BOUNDS_OUTER
Modus "Aussen". |
static int |
CENTER
Ausrichtung zentriert. |
static Cursor |
CROSSHAIR_CURSOR
Cursor in Form einer geschlossenen Hand |
static int |
EAST
Ausrichtung mitte-rechts. |
static int |
NORTH
Ausrichtung oben-mitte. |
static int |
NORTHEAST
Ausrichtung oben-rechts. |
static int |
NORTHWEST
Ausrichtung oben-links. |
static Cursor |
PAN_CURSOR
Cursor in Form einer offenen Hand |
static Cursor |
PANNING_CURSOR
Cursor in Form einer geschlossenen Hand |
static ResourceProvider |
RESOURCE
ResourceProvider , der die Lokalisation fuer GUI-Komponenten des
Package schmitzm.swing zur Verfuegung stellt. |
static int |
SOUTH
Ausrichtung unten-mitte. |
static int |
SOUTHEAST
Ausrichtung unten-rechts. |
static int |
SOUTHWEST
Ausrichtung unten-links. |
static int |
WEST
Ausrichtung mitte-links. |
static Cursor |
ZOOM_CURSOR
Cursor in Form einer Lupe ohne Symbol |
static Cursor |
ZOOMIN_CURSOR
Cursor in Form einer Lupe mit Plus Symbol |
static Cursor |
ZOOMOUT_CURSOR
Cursor in Form einer Lupe mit Minus Symbol |
Constructor Summary | |
---|---|
SwingUtil()
|
Method Summary | |
---|---|
static void |
centerFrameOnScreen(Component comp)
Zentriert ein Fenster auf dem Monitor. |
static void |
centerFrameOnScreen(Window comp)
Zentriert ein Fenster auf dem Monitor. |
static void |
centerFrameOnScreenRandom(Component comp)
Zentriert ein Fenster auf dem Monitor, aber verrückt das Window per Zufall um 10 Prozenz |
static String |
convertColorToHex(Color color)
Versucht, aus einem String eine Farbe zu erstellen. |
static Cursor |
createCursorFromResourcePath(String imgPath,
int x,
int y,
String name)
Erzeugt einen Cursor auf Basis einer relativen Pfad-Angabe. |
static JFrame |
createFrame(Component comp,
String title,
Image icon)
Erzeugt ein neues Fenster mit BorderLayout und zeigt darin eine
Component an. |
static ImageIcon |
createImageIconFromResourcePath(Class resourceBase,
String imgPath,
String imgDesc)
Erzeugt ein Icon auf Basis einer relativen Pfad-Angabe. |
static ImageIcon |
createImageIconFromResourcePath(String imgPath,
String imgDesc)
Erzeugt ein Icon auf Basis einer relativen Pfad-Angabe. |
static void |
deiconify(JFrame frame)
This method deiconifies a frame; the maximized bits are not affected. |
static void |
expandAll(JTree tree,
boolean expand)
Copied from http://www.exampledepot.com/egs/javax.swing.tree/ExpandAll.html e1029. |
static void |
fixComponentSize(Component comp)
Fixiert die Groesse einer GUI-Komponente mit der aktuell bevorzugten Groesse. |
static void |
fixComponentSize(Component comp,
Dimension d)
Fixiert die Groesse einer GUI-Komponente. |
static String |
getNumberFormatPattern(double sample)
Erstellt das Pattern fuer ein NumberFormat . |
static String |
getNumberFormatPattern(int digits)
Erstellt das Pattern fuer ein NumberFormat . |
static Frame |
getParentFrame(Component comp)
Liefert den Frame , das eine Kompoenente beinhaltet. |
static Window |
getParentWindow(Component comp)
Liefert das Fenster, das eine GUI-Komponente beinhaltet. |
static Component |
getParentWindowComponent(Component comp)
Liefert das Fenster, das eine Kompoenente beinhaltet. |
static boolean |
isChildComponent(Component child,
Component parent)
Prueft, ob eine Komponente eine Kind-Komponente einer anderen Komponente ist. |
static void |
maximize(Frame frame)
This method maximizes a frame; the iconified bit is not affected Taken from e564. |
static boolean |
packParentWindow(Component comp)
Packt das Fenster, in dem eine Kompoenente plaziert ist. |
static Color |
parseColor(String colorStr)
Versucht, aus einem String eine Farbe zu erstellen. |
static String |
R(String key,
Object... values)
Convenience method to access the translation resources. |
static void |
resetCaption(Component comp,
Object newLabel)
Setzt das Label eine Componente neu. |
static void |
setAllBackground(Component comp,
Color color)
Setzt die Hintergrundfarbe einer Komponente und aller darin enthaltener Komponenten. |
static void |
setHeight(Component comp,
int h)
Aendert die Hoehe einer GUI-Komponente. |
static void |
setMaximumHeight(Component comp,
int h)
Aendert die maximal erlaubte Hoehe einer GUI-Komponente. |
static void |
setMaximumWidth(Component comp,
int w)
Aendert die maximal erlaubte Breite einer GUI-Komponente. |
static void |
setMinimumHeight(Component comp,
int h)
Aendert die minimal erlaubte Hoehe einer GUI-Komponente. |
static void |
setMinimumWidth(Component comp,
int w)
Aendert die minimal erlaubte Breite einer GUI-Komponente. |
static void |
setPreferredHeight(Component comp,
int h)
Aendert die bevorzugte Hoehe einer GUI-Komponente. |
static void |
setPreferredWidth(Component comp,
int w)
Aendert die bevorzugte Breite einer GUI-Komponente. |
static void |
setRelativeFramePosition(Component comp,
double relX,
double relY)
Positioniert ein Fenster auf dem Monitor, relativ zu dessen Groesse |
static void |
setRelativeFramePosition(Component comp,
Window relFrame,
double relX,
double relY)
Positioniert ein Fenster auf dem Monitor relativ zur Position eines anderen Fensters. (0.5/0.5) positioniert das Fenster z.B. genau in der Mitte anderen Fensters. (0.25/0.5) setzt das Fenster vertikal in die Mitte und horizontal auf ein Viertel des Referenz-Fensters. |
static void |
setRelativeFramePosition(Window window,
Window relWindow,
int type,
int position)
Positioniert ein Fenster auf dem Monitor relativ zur Position eines anderen Fensters. |
static void |
setWidth(Component comp,
int w)
Aendert die Breite einer GUI-Komponente. |
static JFrame |
showFrame(Component comp,
String title,
Image icon)
Zeigt ein neues Fenster einer Component an. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static ResourceProvider RESOURCE
ResourceProvider
, der die Lokalisation fuer GUI-Komponenten des
Package schmitzm.swing
zur Verfuegung stellt. Diese sind in
properties-Dateien unter schmitzm.swing.resource.locales
hinterlegt.
public static final Cursor ZOOMIN_CURSOR
public static final Cursor ZOOMOUT_CURSOR
public static final Cursor ZOOM_CURSOR
public static final Cursor PAN_CURSOR
public static final Cursor PANNING_CURSOR
public static final Cursor CROSSHAIR_CURSOR
public static final int BOUNDS_INNER
setRelativeFramePosition(Window,Window,int,int)
,
Constant Field Valuespublic static final int BOUNDS_OUTER
setRelativeFramePosition(Window,Window,int,int)
,
Constant Field Valuespublic static final int NORTH
public static final int NORTHWEST
public static final int NORTHEAST
public static final int SOUTH
public static final int SOUTHWEST
public static final int SOUTHEAST
public static final int CENTER
public static final int WEST
public static final int EAST
Constructor Detail |
---|
public SwingUtil()
Method Detail |
---|
public static String R(String key, Object... values)
public static ImageIcon createImageIconFromResourcePath(String imgPath, String imgDesc)
SwingUtil
verwendet.
imgPath
- relativer Pfad des IconsimgDesc
- Beschreibung fuer Icon
null
, wenn das Icon nicht gefunden wirdpublic static ImageIcon createImageIconFromResourcePath(Class resourceBase, String imgPath, String imgDesc)
resourceBase
- Klasse, deren Classpath als Basis-Verzeichnis verwendet wirdimgPath
- relativer Pfad des IconsimgDesc
- Beschreibung fuer Icon
null
, wenn das Icon nicht gefunden wirdpublic static Cursor createCursorFromResourcePath(String imgPath, int x, int y, String name)
Cursor
auf Basis einer relativen Pfad-Angabe. Als
Basis-Verzeichnis wird der Classpath von SwingUtil
verwendet.
imgPath
- relativer Pfad des Iconsx
- X-Position im Image, die den Hotspot des Cursors darstellen
solly
- Y-Position im Image, die den Hotspot des Cursors darstellen
sollname
- Bezeichnung fuer den Cursor
null
, wenn das Icon nicht gefunden wirdpublic static JFrame createFrame(Component comp, String title, Image icon)
BorderLayout
und zeigt darin eine
Component
an.
comp
- anzuzeigende Komponente (kann null
sein)title
- Titel des Fensters (kann null
sein)icon
- Icon-Image (kann null
sein)public static JFrame showFrame(Component comp, String title, Image icon)
Component
an.
comp
- anzuzeigende Komponente (kann null
sein)title
- Titel des Fensters (kann null
sein)icon
- Icon-Image (kann null
sein)createFrame(Component, String, Image)
public static Window getParentWindow(Component comp)
Window
ist, wird diese zurückgelifert.
comp
- eine GUI-Komponente
null
falls die Komponente in keinem Fenster
enthalten istpublic static Frame getParentFrame(Component comp)
Frame
, das eine Kompoenente beinhaltet.
comp
- eine GUI-Komponente
null
falls die Komponente in keinem Frame
enthalten istpublic static Component getParentWindowComponent(Component comp)
JInternalFrame
handelt.
comp
- eine GUI-Komponente
null
falls die Komponente in keinem Fenster
enthalten istpublic static boolean packParentWindow(Component comp)
comp
- eine GUI-Komponente
false
falls die Komponente in keinem Fenster
enthalten istWindow.pack()
public static boolean isChildComponent(Component child, Component parent)
child
- Componentparent
- Component
false
wenn child == null
, true
wenn
child == parent
, isChildComponent(child.getParent(),parent)
sonstpublic static void centerFrameOnScreen(Component comp)
window
- das zu zentrierende Fensterpublic static void centerFrameOnScreen(Window comp)
Window
eine Component
ist, ist diese
Methode eigentlich ueberfluessig. Es koennte
centerFrameOnScreen(Component)
verwendet werden.
Merkwuerdigerweise macht XULU beim Starten von der Console aus aber
Probleme, wenn die Methode centerFrameOnScreen(Window)
fehlt!!
TODO: Probleme beim Xulu-Start loesen.
window
- das zu zentrierende Fensterpublic static void centerFrameOnScreenRandom(Component comp)
comp
- Eine Componente des zu zentrierenden Fensters. Wenn comp kein
Window
ist, wird das Parent Window
ermittelt.public static void setRelativeFramePosition(Component comp, double relX, double relY)
comp
- Eine Komponente des zu positionierenden Fensters oder direckt
das Window
.relX
- Relationsfaktor fuer die horizontale Position (0 <
relX
< 1)relY
- Relationsfaktor fuer die vertikale Position (0 <
relX
< 1)public static void setRelativeFramePosition(Component comp, Window relFrame, double relX, double relY)
comp
- Eine Komponente des zu positionierenden Fensters oder direkt
das Window
.relFrame
- Fenster zu dem das Fenster in Relation gesetzt wird (wenn
null
wird der gesamte Monitor verwendet)relX
- Relationsfaktor fuer die horizontale Position (0 <
relX
< 1)relY
- Relationsfaktor fuer die vertikale Position (0 <
relY
< 1)public static void setRelativeFramePosition(Window window, Window relWindow, int type, int position)
window
- das zu positionierende FensterrelWindow
- Fenster zu dem das Fenster in Relation gesetzt wird (wenn
null
wird der gesamte Monitor verwendet)type
- bestimmt, ob das Fenster innerhalb oder ausserhalb des
relativen Fensters positioniert wird (BOUNDS_INNER
oder BOUNDS_OUTER
).position
- Positionierung des Fensters (NORTH
,
NORTHEAST
, ...)public static void setWidth(Component comp, int w)
comp
- GUI-Komponentew
- Breitepublic static void setHeight(Component comp, int h)
comp
- GUI-Komponenteh
- Hoehepublic static void setPreferredWidth(Component comp, int w)
comp
- GUI-Komponentew
- Breitepublic static void setPreferredHeight(Component comp, int h)
comp
- GUI-Komponenteh
- Hoehepublic static void setMinimumWidth(Component comp, int w)
comp
- GUI-Komponentew
- Breitepublic static void setMinimumHeight(Component comp, int h)
comp
- GUI-Komponenteh
- Hoehepublic static void setMaximumWidth(Component comp, int w)
comp
- GUI-Komponentew
- Breitepublic static void setMaximumHeight(Component comp, int h)
comp
- GUI-Komponenteh
- Hoehepublic static void fixComponentSize(Component comp, Dimension d)
comp
- GUI-Komponented
- Ausmasse (Hoehe und Breite)public static void fixComponentSize(Component comp)
comp
- GUI-Komponentepublic static void setAllBackground(Component comp, Color color)
comp
- Komponentecolor
- neue Hintergrund-Farbepublic static Color parseColor(String colorStr) throws IllegalArgumentException
"RGB(red,green,blue)"
Color.decode(..)
).Color
.
"RED"
fuer Color.RED
,
"darkGray"
fuer Color.darkGray
oder
"LIGHT_GRAY"
fuer Color.LIGHT_GRAY
IllegalArgumentException
- wenn der uebergebene String nicht interpretiert werden kann.public static String convertColorToHex(Color color)
"RGB(red,green,blue)"
Color.decode(..)
).Color
.
"RED"
fuer Color.RED
,
"darkGray"
fuer Color.darkGray
oder
"LIGHT_GRAY"
fuer Color.LIGHT_GRAY
IllegalArgumentException
- wenn der uebergebene String nicht interpretiert werden kann.public static void resetCaption(Component comp, Object newLabel)
newLabel
oder comp
den Wert null
hat.
comp
- JLabel
, AbstractButton
, JDialog
oder
Frame
newLabel
- neue Beschriftung
UnsupportedOperationException
- falls comp
nicht unterstuetzt wird.public static String getNumberFormatPattern(double sample)
NumberFormat
.
sample
- Beispiel-Wert, der die Anzahl der dargestellten
Nachkomma-Stellen bestimmtpublic static String getNumberFormatPattern(int digits)
NumberFormat
.
digits
- Anzahl der dargestellten Nachkomma-Stellenpublic static void expandAll(JTree tree, boolean expand)
tree
- JTree
to expand or collapsepublic static void maximize(Frame frame)
public static void deiconify(JFrame frame)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |