public class ComponentTools
extends java.lang.Object
Constructor and Description |
---|
ComponentTools() |
Modifier and Type | Method and Description |
---|---|
static java.awt.GradientPaint |
applyThemedScheme(javax.swing.JComponent component,
java.awt.Color reference,
boolean isPressed)
Applies a highly customized visual scheme based on the reference color.
|
static void |
center(java.awt.Window mover)
Centers a window within the center of the screen.
|
static void |
center(java.awt.Window mover,
java.awt.Component target)
Moves a window to be concentric with another.
|
static javax.swing.JDialog |
makeDialog(java.awt.Component parent,
java.lang.String title)
Generates a modal dialog capable of having either a Frame or Dialog parent.
|
static javax.swing.JButton |
makeThemedButton(java.lang.String text,
java.awt.Color reference)
Provides a visually customized button utilizing the applyThemedScheme method that will update
its theme accordingly when pressed.
|
static void |
setKeyBinding(javax.swing.JButton button,
javax.swing.KeyStroke event)
Binds a given keystroke to click the button when the button's in the focused window.
|
public static java.awt.GradientPaint applyThemedScheme(javax.swing.JComponent component, java.awt.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 pressedpublic static javax.swing.JButton makeThemedButton(java.lang.String text, java.awt.Color reference)
text
- message displayed by the buttonreference
- color on which background gradient and border are basedpublic static void center(java.awt.Window mover)
mover
- window to be centeredpublic static void center(java.awt.Window mover, java.awt.Component target)
mover
- window to be centeredtarget
- to be centered withinpublic static void setKeyBinding(javax.swing.JButton button, javax.swing.KeyStroke event)
button
- button to be bound to keystrokeevent
- type of keyboard event that triggers the buttonpublic static javax.swing.JDialog makeDialog(java.awt.Component parent, java.lang.String title)
parent
- the parent component of the dialogtitle
- title of dialog
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.