|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.ComponentTools
public class ComponentTools
Common tools for Swing gui components.
| Constructor Summary | |
|---|---|
ComponentTools()
|
|
| Method Summary | |
|---|---|
static GradientPaint |
applyThemedScheme(JComponent component,
Color reference,
boolean isPressed)
Applies a highly customized visual scheme based on the reference color. |
static void |
center(Window mover)
Centers a window within the center of the screen. |
static void |
center(Window mover,
Component target)
Moves a window to be concentric with another. |
static JDialog |
makeDialog(Component parent,
String title)
Generates a modal dialog capable of having either a Frame or Dialog parent. |
static JButton |
makeThemedButton(String text,
Color reference)
Provides a visually customized button utilizing the applyThemedScheme method that will update its theme accordingly when pressed. |
static void |
setKeyBinding(JButton button,
KeyStroke event)
Binds a given keystroke to click the button when the button's in the focused window. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ComponentTools()
| Method Detail |
|---|
public static GradientPaint applyThemedScheme(JComponent component,
Color reference,
boolean isPressed)
JButton button = new JButton(text) {
private static final long serialVersionUID = 0;
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setPaint(applyThemedScheme(this, reference, getModel().isArmed()));
g2.fillRect(0, 0, getWidth(), getHeight()); // Draws gradient background
super.paintComponent(g); // Draws button content
}
};
button.setContentAreaFilled(false); // Disables default background
component - component to which custom foreground and border is applied, if null then these
attributes aren't appliedreference - color on which background gradient and border are basedisPressed - determines if toggled scheme is applied for components that can be pressed
public static JButton makeThemedButton(String text,
Color reference)
text - message displayed by the buttonreference - color on which background gradient and border are based
public static void center(Window mover)
mover - window to be centered
public static void center(Window mover,
Component target)
mover - window to be centeredtarget - to be centered within
public static void setKeyBinding(JButton button,
KeyStroke event)
button - button to be bound to keystrokeevent - type of keyboard event that triggers the button
public static JDialog makeDialog(Component parent,
String title)
parent - the parent component of the dialogtitle - title of dialog
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||