public void paintIcon(Component c, Graphics g, int x, int y) { boolean enabled = c.isEnabled(); // paint the icon Icon paintedIcon = enabled ? icon : disabledIcon; if (paintedIcon != null) paintedIcon.paintIcon(c, g, x, y); // backup current color Color oldColor = g.getColor(); int insetx = 4; if (c instanceof JComponent) { Insets borderinset = ((JComponent) c).getBorder().getBorderInsets(c); insetx = borderinset.left; } if (paintedIcon != null) { g.translate(paintedIcon.getIconWidth() + X_GAP + insetx, 0); } arrow.paintIcon(c, g, x, y); if (paintedIcon != null) { g.translate(-paintedIcon.getIconWidth() - X_GAP - insetx, 0); } // restore previous color g.setColor(oldColor); }
public void enableControlPanel() { boolean bVisible = false; int nmembers = buttonPane.getComponentCount(); for (int k = 0; k < nmembers; k++) { Component comp = buttonPane.getComponent(k); if (comp != null) { if (comp.isVisible() || comp.isEnabled()) { bVisible = true; break; } } } if (bVisible && !buttonPane.isVisible()) { Dimension dim = getSize(); Dimension dim1 = buttonPane.getPreferredSize(); int w = dim.width; int h = dim.height + dim1.height; if (dim1.width > w) w = dim1.width; if (w < 300) w = 300; if (h < 200) h = 200; setSize(w, h); } buttonPane.setVisible(bVisible); }
public void paintIcon(Component c, Graphics g, int x, int y) { Color oldColor = g.getColor(); boolean enabled = c.isEnabled(); boolean pressed = false; if (c instanceof JButton) { pressed = ((JButton) c).getModel().isPressed(); } int i = 0; int j = 0; int w = Math.min(width, c.getWidth()); int h = c.getHeight(); if (h < 5 || w < 5) { // not enough space for the arrow g.setColor(oldColor); return; } int size = Math.min(h / 2, w / 2); size = Math.max(size, 2); int mid = size / 2; x = ((w - size) / 2); // center arrow y = (h - size) / 2; // center arrow if (pressed) { x++; y++; } g.translate(x, y); // move the x,y origin in the graphic if (enabled) g.setColor(UIManager.getColor("controlDkShadow")); // NOT // LOCALIZABLE else g.setColor(UIManager.getColor("controlShadow")); // NOT // LOCALIZABLE if (!enabled) { g.translate(1, 1); g.setColor(UIManager.getColor("controlLtHighlight")); // NOT // LOCALIZABLE for (i = size - 1; i >= 0; i--) { g.drawLine(mid - i, j, mid + i, j); j++; } g.translate(-1, -1); g.setColor(UIManager.getColor("controlShadow")); // NOT // LOCALIZABLE } j = 0; for (i = size - 1; i >= 0; i--) { g.drawLine(mid - i, j, mid + i, j); j++; } g.translate(-x, -y); g.setColor(oldColor); }
protected Icon getIcon(Component c) { Icon icon; boolean isActive = true; // QuaquaUtilities.isOnActiveWindow(c); if (c instanceof JSlider) { JSlider slider = (JSlider) c; if (isActive) { if (c.isEnabled()) { if (slider.getModel().getValueIsAdjusting()) { icon = icons[EP]; } else { icon = icons[E]; } } else { icon = icons[D]; } } else { if (c.isEnabled()) { icon = icons[I]; } else { icon = icons[DI]; } } } else { if (isActive) { if (c.isEnabled()) { icon = icons[E]; } else { icon = icons[D]; } } else { if (c.isEnabled()) { icon = icons[I]; } else { icon = icons[DI]; } } } return icon; }
protected void paintBackground(Graphics g, Rectangle cellRect, int col) { Component component = getHeaderRenderer(col); int x = cellRect.x; int y = cellRect.y; int w = cellRect.width; int h = cellRect.height; if (header.getBackground() instanceof ColorUIResource) { if ((col == rolloverCol) && (component != null) && component.isEnabled()) { JTattooUtilities.fillHorGradient( g, AbstractLookAndFeel.getTheme().getRolloverColors(), x, y, w, h); } else if (drawAllwaysActive() || JTattooUtilities.isFrameActive(header)) { JTattooUtilities.fillHorGradient( g, AbstractLookAndFeel.getTheme().getColHeaderColors(), x, y, w, h); } else { JTattooUtilities.fillHorGradient( g, AbstractLookAndFeel.getTheme().getInActiveColors(), x, y, w, h); } } else { g.setColor(header.getBackground()); g.fillRect(x, y, w, h); } }
private TitledSeparator getTitledSeparator(Component c) { titledSeparator.setEnabled(c.isEnabled()); return titledSeparator; }
public static boolean isFocusable(Component component) { return component.isFocusable() && component.isDisplayable() && component.isVisible() && component.isEnabled(); }
/** * Sets the help text for the specified component. * * @param cont input container */ static void focus(final Component cont) { final GUI gui = gui(cont); if (gui == null) return; if (gui.gopts.get(GUIOptions.MOUSEFOCUS) && cont.isEnabled()) cont.requestFocusInWindow(); }