|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tbee.swing.SwingUtilities
public class SwingUtilities
Some swing utilities waitForThreadToFinish has been moved to the FoxtrotUtils
| Field Summary | |
|---|---|
static Insets |
EMPTY_INSETS
|
static String |
SOURCECODE_VERSION
Standard variable for determining version of a class file. |
| Constructor Summary | |
|---|---|
SwingUtilities()
|
|
| Method Summary | ||
|---|---|---|
static void |
addEnterAsClick(JButton button)
|
|
static void |
addEnterAsFocusTravelsalKey()
As you've noticed, when you press Enter on fields like JTextField et al, an ActionEvent is generated, and focus is not transferred to the next field in the focus cycle. |
|
static void |
addEnterAsFocusTravelsalKey(Component component)
Same but per component |
|
static void |
centerOnScreen(Window jwindow)
Center a frame to the screen |
|
static Component |
cloneComponent(Component component)
Create a clone of a component |
|
static Border |
createCompoundedBorder(Border... borders)
Merge borders using CompoundBorders; first border is outside, last border is inside |
|
static BufferedImage |
createDesktopImage()
Convenience method to create a BufferedImage of the desktop |
|
static BufferedImage |
createImage(Component component)
Create a BufferedImage for AWT components. |
|
static BufferedImage |
createImage(JComponent component)
|
|
static BufferedImage |
createImage(JComponent component,
Rectangle region)
|
|
static BufferedImage |
createImage(Rectangle region)
Create a BufferedImage from a rectangular region on the screen. |
|
static BufferedImage |
createImageFromComponent(Component comp)
Create an image of a component, by having the component paint onto the image |
|
static JDialog |
createJDialog(Component owner)
create a JDialog |
|
static JDialog |
createJDialog(Component owner,
boolean modal)
create a JDialog |
|
static JDialog |
createJDialog(Component owner,
boolean modal,
Container container)
create a JDialog |
|
static JDialog |
createJDialog(Component owner,
Container container)
create a JDialog |
|
static JDialog |
createJDialog(Component owner,
Dialog.ModalityType modal)
create a JDialog |
|
static JDialog |
createJDialog(Component owner,
String title)
create a JDialog |
|
static JDialog |
createJDialog(Component owner,
String title,
boolean modal)
create a JDialog |
|
static JDialog |
createJDialog(Component owner,
String title,
boolean modal,
Container container)
create a JDialog |
|
static JDialog |
createJDialog(Component owner,
String title,
Container container)
create a JDialog |
|
static JDialog |
createJDialog(Component owner,
String title,
Dialog.ModalityType modality)
|
|
static JDialog |
createJDialog(Component owner,
String title,
Dialog.ModalityType modality,
boolean maximize)
create a JDialog |
|
static JDialog |
createJDialog(Component owner,
String title,
Dialog.ModalityType modal,
Container container)
create a JDialog |
|
static JFrame |
createJFrame()
|
|
static JFrame |
createJFrame(Component... component)
|
|
static JFrame |
createJFrame(Component component,
int width,
int height)
|
|
static JFrame |
createJFrame(Container container)
|
|
static JFrame |
createJFrame(Container container,
int width,
int height)
|
|
static JFrame |
createJFrame(String name,
Component... component)
|
|
static JFrame |
createJFrame(String name,
Component component,
int width,
int height)
|
|
static JFrame |
createJFrame(String name,
Container container)
|
|
static JFrame |
createJFrame(String name,
Container container,
int width,
int height)
|
|
static JScrollPane |
createTransparentJScrollpane()
|
|
static JScrollPane |
createTransparentJScrollpane(Component c)
|
|
static String |
describe(Component c)
|
|
static Thread |
detachFromAwt(Runnable runnable)
Detach from AWT thread; if already detached, just run. |
|
static Thread |
detachFromAwtShowExceptions(Component c,
Runnable runnable)
|
|
static void |
disableAllComponents(Container container)
Disable all components in a container (recusively) |
|
static ActionListener |
exceptionsAsJOptionPane(ActionListener actionListener)
Show IllegalArgumentExceptions and IllegalStateExceptions in a JOptionPane and then discard |
|
static Runnable |
exceptionsAsJOptionPane(Component component,
Runnable runnable)
Show IllegalArgumentExceptions and IllegalStateExceptions in a JOptionPane and then discard |
|
static Runnable |
exceptionsAsStatusBarAndJOptionPane(Component component,
StatusBar statusBar,
Runnable runnable)
Show IllegalArgumentExceptions and IllegalStateExceptions in a JOptionPane and then discard |
|
static ActionListener |
exceptionsAsStatusBarAndJOptionPane(StatusBar statusBar,
ActionListener actionListener)
Show IllegalArgumentExceptions and IllegalStateExceptions in a JOptionPane and then discard |
|
static JComponent |
findByName(JComponent container,
String name)
Find a JComponent by its name |
|
static Container |
findContainer(Component c,
Class containerClass)
Find the toplevel container, whether that is a dialog or frame |
|
static Container |
findToplevelContainer(Component c)
Find the toplevel container, whether that is a dialog or frame |
|
static void |
fitInScreen(Window window)
|
|
static void |
fix16DialogMemoryLeak()
In java 1.6 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6497929 |
|
static JDialog |
fixDecoratedJDialogProblem(JDialog dialog)
This is something that should be hooked in to the "new JFrame" with AOP? |
|
static JFrame |
fixDecoratedJFrameProblem(JFrame frame)
This is something that should be hooked in to the "new JFrame" with AOP? |
|
static List<Component> |
flattenComponentTree(JComponent c)
Flatten the whole component tree into a list, so it is easily possible to search if some component is present |
|
static Component |
forceRefresh(Component c)
Code to force a component to refresh its contents |
|
static Component |
forceRelayout(Component c)
Code to force a component to relayout |
|
static int |
getBorderSizeBottom(JComponent c)
|
|
static int |
getBorderSizeLeft(JComponent c)
|
|
static int |
getBorderSizeRight(JComponent c)
|
|
static int |
getBorderSizeTop(JComponent c)
return the border size |
|
static Dimension |
getScreenSize(Window window)
Gets the maximum working screen size. |
|
static boolean |
hasFocusElseRequestAndReclick(JButton button)
When a keyboard shortcut is used to trigger a button, the focus is not moved. |
|
static void |
invokeAndWait(Runnable runnable)
Run a runnable as part of the EDT; if already on the EDT just run try { SwingUtilities.invokeAndWait( new Runnable() { public void run() { ... } } ); } catch (InvocationTargetException e) {e.printStackTrace(); } catch (InterruptedException e) {e.printStackTrace(); } |
|
static
|
invokeAndWait2(Callable<E> callable)
InvokeAndWait with return value |
|
static void |
invokeAndWait2(Runnable runnable)
Run a runnable as part of the EDT; if already on the EDT just run This method also catches the exceptions and dumps them to stderr. SwingUtilities.invokeAndWait2( new Runnable() { public void run() { ... } } ); |
|
static void |
invokeAndWait2ShowExceptions(Component c,
Runnable runnable)
|
|
static void |
invokeLater(int milliseconds,
Runnable runnable)
Execute in swing thread after a delay |
|
static void |
invokeLater(Runnable runnable)
Run later in the EDT; if already on the EDT just run |
|
static void |
invokeLaterShowExceptions(Component c,
Runnable runnable)
|
|
static boolean |
isComponentVisibleToUser(Component c)
See if this container is still visible to the user (any component in the path toward a window or applet must be visible). |
|
static void |
jumpTo(JComponent component,
JScrollPane jscrollpane)
|
|
static void |
jumpToComponentInScrollpane(JComponent component)
|
|
static void |
makeWindowAtLeastTheWidthOfComponent(Window window,
Component component)
Make a window at least the size of the component (combined with placeAtComponent you can make popups) |
|
static void |
paintImmediately(JComponent c)
Force a repaint within the EDT (normally a repaint places a new event on the EDT queue). |
|
static void |
placeAtComponent(Window window,
Component component)
Place a window at the same position as a component |
|
static void |
placeBelowComponent(Window window,
Component component)
Place a window at the same position as a component |
|
static boolean |
pointIsInComponent(Component c,
Point p)
Check to see if a point falls within the component's boundary |
|
static boolean |
print(Component component)
print a component TODO: the print now printers in the length over multiple pages, we also need a way to print in the width |
|
static void |
quickKeybind(JComponent c,
KeyStroke k,
Action a)
Quickly bind a keystroke to an action |
|
static void |
setAntiAlias(boolean value)
Tell swing to anti alias text |
|
static void |
setDefaultFont(String fontname)
Change the default font on all swing components |
|
static void |
setDefaultFont(String fontname,
double scale)
Change the default font on all swing components |
|
static void |
setEnableAll(Container container,
boolean enable)
|
|
static void |
setEnableAll(Container container,
List ignoredComponents,
boolean enable)
enable all components in a container (recusively) |
|
static void |
setHorizontalAlignment(JSpinner spinner,
int aligment)
Set the alignment of a spinner |
|
static void |
setup()
Some generic setup (must be called immediatly in the main) |
|
static void |
setupLAF()
Setup the JVM to do full LAF |
|
static Runnable |
showExceptions(Component c,
Runnable runnable)
Any exception throw in the runnable's run() will be shown in an error optionpane |
|
static ProgressMonitor |
showProgressMonitorImmediately(ProgressMonitor progressMonitor)
|
|
static void |
synchronizeTwoScrollbars(JScrollBar sb1,
JScrollBar sb2)
Two scrollbars scrolling simultaniously. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String SOURCECODE_VERSION
public static final Insets EMPTY_INSETS
| Constructor Detail |
|---|
public SwingUtilities()
| Method Detail |
|---|
public static void setup()
public static void fix16DialogMemoryLeak()
public static void setupLAF()
public static void setAntiAlias(boolean value)
fontname - public static void setDefaultFont(String fontname)
fontname -
public static void setDefaultFont(String fontname,
double scale)
fontname - scale - public static void invokeLater(Runnable runnable)
runnable -
public static void invokeLaterShowExceptions(Component c,
Runnable runnable)
public static void invokeLater(int milliseconds,
Runnable runnable)
milliseconds - runnable -
public static void invokeAndWait(Runnable runnable)
throws InvocationTargetException,
InterruptedException
InvocationTargetException
InterruptedExceptionpublic static void invokeAndWait2(Runnable runnable)
public static void invokeAndWait2ShowExceptions(Component c,
Runnable runnable)
public static <E> E invokeAndWait2(Callable<E> callable)
callable -
public static Thread detachFromAwt(Runnable runnable)
public static Thread detachFromAwtShowExceptions(Component c,
Runnable runnable)
public static Runnable showExceptions(Component c,
Runnable runnable)
c - runnable -
public static Dimension getScreenSize(Window window)
Toolkit.getScreenSize() by allowing for the space
that any permanent fixtures
that native application windows do not have access to in a given OS. As
an example, the space for the toolbar in Windows - native applications do
not get that pixel area for their use.
window - the window that will use the screen
public static void fitInScreen(Window window)
window - public static Container findToplevelContainer(Component c)
c -
public static Container findContainer(Component c,
Class containerClass)
c -
public static boolean isComponentVisibleToUser(Component c)
c -
public static List<Component> flattenComponentTree(JComponent c)
c -
public static Component forceRelayout(Component c)
public static Component forceRefresh(Component c)
public static void centerOnScreen(Window jwindow)
jwindow -
public static void placeAtComponent(Window window,
Component component)
window - component -
public static void placeBelowComponent(Window window,
Component component)
window - component -
public static void makeWindowAtLeastTheWidthOfComponent(Window window,
Component component)
window - component - public static JFrame fixDecoratedJFrameProblem(JFrame frame)
public static JFrame createJFrame()
public static JFrame createJFrame(Container container)
public static JFrame createJFrame(String name,
Container container)
public static JFrame createJFrame(String name,
Container container,
int width,
int height)
public static JFrame createJFrame(Container container,
int width,
int height)
public static JFrame createJFrame(String name,
Component... component)
public static JFrame createJFrame(Component... component)
public static JFrame createJFrame(String name,
Component component,
int width,
int height)
public static JFrame createJFrame(Component component,
int width,
int height)
public static JDialog fixDecoratedJDialogProblem(JDialog dialog)
public static JDialog createJDialog(Component owner)
owner - the component of which the container will be the owner of this dialog
public static JDialog createJDialog(Component owner,
Container container)
owner - the component of which the container will be the owner of this dialogcontainer - the content of the dialog
public static JDialog createJDialog(Component owner,
boolean modal)
owner - the component of which the container will be the owner of this dialogmodal - is the dialog modal
public static JDialog createJDialog(Component owner,
Dialog.ModalityType modal)
owner - the component of which the container will be the owner of this dialogmodal - is the dialog modal
public static JDialog createJDialog(Component owner,
boolean modal,
Container container)
owner - the component of which the container will be the owner of this dialogmodal - is the dialog modalcontainer - the content of the dialog
public static JDialog createJDialog(Component owner,
String title)
owner - the component of which the container will be the owner of this dialogtitle - dialog title
public static JDialog createJDialog(Component owner,
String title,
Container container)
owner - the component of which the container will be the owner of this dialogtitle - dialog titlecontainer - the content of the dialog
public static JDialog createJDialog(Component owner,
String title,
boolean modal)
owner - the component of which the container will be the owner of this dialogtitle - dialog titlemodal - is the dialog modal
public static JDialog createJDialog(Component owner,
String title,
boolean modal,
Container container)
owner - the component of which the container will be the owner of this dialogtitle - dialog titlemodal - is the dialog modalcontainer - the content of the dialog
public static JDialog createJDialog(Component owner,
String title,
Dialog.ModalityType modal,
Container container)
owner - the component of which the container will be the owner of this dialogtitle - dialog titlemodal - is the dialog modalcontainer - the content of the dialog
public static JDialog createJDialog(Component owner,
String title,
Dialog.ModalityType modality,
boolean maximize)
owner - the component of which the container will be the owner of this dialog
public static JDialog createJDialog(Component owner,
String title,
Dialog.ModalityType modality)
public static int getBorderSizeTop(JComponent c)
public static int getBorderSizeLeft(JComponent c)
public static int getBorderSizeRight(JComponent c)
public static int getBorderSizeBottom(JComponent c)
public static Border createCompoundedBorder(Border... borders)
borders -
public static void synchronizeTwoScrollbars(JScrollBar sb1,
JScrollBar sb2)
public static JScrollPane createTransparentJScrollpane()
public static JScrollPane createTransparentJScrollpane(Component c)
public static void jumpToComponentInScrollpane(JComponent component)
component -
public static void jumpTo(JComponent component,
JScrollPane jscrollpane)
component - jscrollpane - public static String describe(Component c)
public static BufferedImage createImageFromComponent(Component comp)
comp - public static BufferedImage createImage(JComponent component)
public static BufferedImage createImage(JComponent component,
Rectangle region)
public static BufferedImage createImage(Component component)
throws AWTException
component - AWT component to create image fromfileName - name of file to be created or null
IOException - if an error occurs during writing
AWTException
public static BufferedImage createImage(Rectangle region)
throws AWTException
region - region on the screen to create image from
AWTException - see Robot class constructors
IOException - if an error occurs during writing
public static BufferedImage createDesktopImage()
throws AWTException
AWTException - see Robot class constructors
IOException - if an error occurs during writingpublic static boolean hasFocusElseRequestAndReclick(JButton button)
public static Component cloneComponent(Component component)
component -
public static void addEnterAsFocusTravelsalKey()
public static void addEnterAsFocusTravelsalKey(Component component)
component - public static void addEnterAsClick(JButton button)
public static void paintImmediately(JComponent c)
public static void disableAllComponents(Container container)
public static void setEnableAll(Container container,
List ignoredComponents,
boolean enable)
public static void setEnableAll(Container container,
boolean enable)
public static boolean print(Component component)
public static ActionListener exceptionsAsJOptionPane(ActionListener actionListener)
public static ActionListener exceptionsAsStatusBarAndJOptionPane(StatusBar statusBar,
ActionListener actionListener)
public static Runnable exceptionsAsJOptionPane(Component component,
Runnable runnable)
public static Runnable exceptionsAsStatusBarAndJOptionPane(Component component,
StatusBar statusBar,
Runnable runnable)
public static void quickKeybind(JComponent c,
KeyStroke k,
Action a)
c - Componentk - Keystrokea - Action
public static boolean pointIsInComponent(Component c,
Point p)
c - p - must be in screen coordinates
public static void setHorizontalAlignment(JSpinner spinner,
int aligment)
spinner - aligment - SwingConstantspublic static ProgressMonitor showProgressMonitorImmediately(ProgressMonitor progressMonitor)
progressMonitor -
public static JComponent findByName(JComponent container,
String name)
container - name -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||