List of usage examples for java.awt Component isEnabled
public boolean isEnabled()
From source file:Main.java
public static boolean isFocusable(Component c) { return c.isFocusable() && c.isDisplayable() && c.isVisible() && c.isEnabled(); }
From source file:Main.java
/** * Recursive method to disable all child components in JComponent * @param component the highest level parent component * @return The original state of all the child components *//*from w w w.ja v a2 s .c o m*/ public static Map<Component, Boolean> disableAllChildComponents(JComponent... components) { Map<Component, Boolean> stateMap = new HashMap<Component, Boolean>(); for (JComponent component : components) { for (Component child : component.getComponents()) { stateMap.put(child, child.isEnabled()); child.setEnabled(false); if (child instanceof JComponent) stateMap.putAll(disableAllChildComponents((JComponent) child)); } } return stateMap; }
From source file:Main.java
private static void appendComponentDetails(Component component, StringBuilder builder) { builder.append(component.isEnabled() ? "" : "[Disabled]"); if (component instanceof JButton) { builder.append("{"); builder.append("JButton: "); builder.append(((JButton) component).getText()); builder.append("}"); } else if (component instanceof JCheckBox) { builder.append("{"); builder.append("JCheckBox: "); builder.append(((JCheckBox) component).getText()); builder.append("}"); } else if (component instanceof JLabel) { builder.append("{"); builder.append("JLabel: "); builder.append(((JLabel) component).getText()); builder.append("}"); } else if (component instanceof JOptionPane) { builder.append("{"); builder.append("JOptionPane: "); builder.append(((JOptionPane) component).getMessage().toString()); builder.append("}"); } else if (component instanceof JRadioButton) { builder.append("{"); builder.append("JRadioButton: "); builder.append(((JRadioButton) component).getText()); builder.append("}"); } else if (component instanceof JTextField) { builder.append("{"); builder.append("JTextField: "); builder.append(((JTextField) component).getText()); builder.append("}"); } else if (component instanceof JMenuBar) { builder.append("{"); builder.append("JMenuBar: "); builder.append(((JMenuBar) component).getName()); builder.append("}"); } else if (component instanceof JMenuItem) { builder.append("{"); builder.append("JMenuItem: "); builder.append(((JMenuItem) component).getText()); builder.append("}"); } else if (component instanceof JTree) { builder.append("{"); builder.append("JTree: "); builder.append("}"); } else if (component instanceof JComboBox) { builder.append("{"); builder.append("JComboBox: "); builder.append("}"); } else if (component instanceof JList) { builder.append("{"); builder.append("JList: "); builder.append("}"); }/*from w ww.ja v a 2s . c o m*/ }
From source file:Main.java
/** * Disables component and all of its children recursively. * * @param component component to disable * @param startFromChilds whether should disable only component childs or not * @param excludePanels whether should exclude panels from disabling or not * @param excluded components to exclude from disabling * @param disabled list of actually disabled components *//* w w w .j a va 2 s . co m*/ private static void disableRecursively(final Component component, final boolean startFromChilds, final boolean excludePanels, final List<Component> excluded, final List<Component> disabled) { final boolean b = !startFromChilds && !excluded.contains(component) && !(component instanceof JPanel && excludePanels); if (b && component.isEnabled()) { component.setEnabled(false); disabled.add(component); } if (component instanceof Container) { if (b && isHandlesEnableState(component)) { return; } final Container container = (Container) component; for (final Component child : container.getComponents()) { disableRecursively(child, false, excludePanels, excluded, disabled); } } }
From source file:Main.java
public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(Color.RED);//from ww w . ja va 2 s.c om if (c.isEnabled()) { g.fillOval(x, y, getIconWidth(), getIconHeight()); } else { g.drawOval(x, y, getIconWidth(), getIconHeight()); } }
From source file:QandE.SquareIcon.java
public void paintIcon(Component c, Graphics g, int x, int y) { if (c.isEnabled()) { g.setColor(Color.RED);//from w w w . j av a 2 s .c om } else { g.setColor(Color.GRAY); } g.fillRect(x, y, SIZE, SIZE); }
From source file:components.ArrowIcon.java
public void paintIcon(Component c, Graphics g, int x, int y) { if (c.isEnabled()) { g.setColor(c.getForeground());/* w w w.j a v a 2s . c om*/ } else { g.setColor(Color.gray); } g.translate(x, y); g.fillPolygon(xPoints, yPoints, xPoints.length); g.translate(-x, -y); //Restore graphics object }
From source file:RedGreenBorder.java
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Insets insets = getBorderInsets(c); Color horizontalColor;/*from w w w. j a va 2 s . c om*/ if (c.isEnabled()) { boolean pressed = false; if (c instanceof AbstractButton) { ButtonModel model = ((AbstractButton) c).getModel(); pressed = model.isPressed(); } if (pressed) { horizontalColor = Color.RED; } else { horizontalColor = Color.GREEN; } } else { horizontalColor = Color.LIGHT_GRAY; } g.setColor(horizontalColor); g.fillRect(0, 0, width, insets.top); }
From source file:CustomIconDemo.java
public void paintIcon(Component c, Graphics g, int x, int y) { if (c.isEnabled()) { g.setColor(c.getForeground());// w w w. j a v a2 s .c o m } else { g.setColor(Color.gray); } g.translate(x, y); g.fillPolygon(xPoints, yPoints, xPoints.length); g.translate(-x, -y); // Restore graphics object }
From source file:RedGreenBorder.java
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Insets insets = getBorderInsets(c); Color horizontalColor;//from w w w . ja v a 2s . c o m Color verticalColor; if (c.isEnabled()) { boolean pressed = false; if (c instanceof AbstractButton) { ButtonModel model = ((AbstractButton) c).getModel(); pressed = model.isPressed(); } if (pressed) { horizontalColor = Color.red; verticalColor = Color.green; } else { horizontalColor = Color.green; verticalColor = Color.red; } } else { horizontalColor = Color.lightGray; verticalColor = Color.lightGray; } g.setColor(horizontalColor); g.translate(x, y); // top g.fillRect(0, 0, width, insets.top); // bottom g.fillRect(0, height - insets.bottom, width, insets.bottom); g.setColor(verticalColor); // left g.fillRect(0, insets.top, insets.left, height - insets.top - insets.bottom); g.fillRect(width - insets.right, insets.top, insets.right, height - insets.top - insets.bottom); g.translate(-x, -y); }