01: package org.uispec4j.utils;
02:
03: import javax.swing.*;
04: import javax.swing.text.JTextComponent;
05: import java.awt.*;
06:
07: /**
08: * Miscellaneous utilities designed for internal use.
09: */
10: public class ComponentUtils {
11: public static boolean hasDisplayedName(Class componentClass) {
12: return ((AbstractButton.class.isAssignableFrom(componentClass))
13: || (JLabel.class.isAssignableFrom(componentClass)) || (JTextComponent.class
14: .isAssignableFrom(componentClass)));
15: }
16:
17: public static String getDisplayedName(Component component) {
18: if (AbstractButton.class.isAssignableFrom(component.getClass())) {
19: return ((AbstractButton) component).getText();
20: } else if (JLabel.class.isAssignableFrom(component.getClass())) {
21: return ((JLabel) component).getText();
22: } else if (JTextComponent.class.isAssignableFrom(component
23: .getClass())) {
24: return ((JTextComponent) component).getText();
25: }
26: return null;
27: }
28:
29: public static void close(org.uispec4j.Window window) {
30: window.getAwtComponent().setVisible(false);
31: }
32: }
|