Search in sources :

Example 1 with UIResource

use of javax.swing.plaf.UIResource in project Botnak by Gocnak.

the class BaseTextAreaUI method installListeners.

protected void installListeners() {
    super.installListeners();
    if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
        focusListener = new FocusListener() {

            public void focusGained(FocusEvent e) {
                if (getComponent() != null) {
                    orgBorder = getComponent().getBorder();
                    LookAndFeel laf = UIManager.getLookAndFeel();
                    if (laf instanceof AbstractLookAndFeel && orgBorder instanceof UIResource) {
                        Border focusBorder = ((AbstractLookAndFeel) laf).getBorderFactory().getFocusFrameBorder();
                        getComponent().setBorder(focusBorder);
                    }
                    getComponent().invalidate();
                    getComponent().repaint();
                }
            }

            public void focusLost(FocusEvent e) {
                if (getComponent() != null) {
                    if (orgBorder instanceof UIResource) {
                        getComponent().setBorder(orgBorder);
                    }
                    getComponent().invalidate();
                    getComponent().repaint();
                }
            }
        };
        getComponent().addFocusListener(focusListener);
    }
}
Also used : FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent) Border(javax.swing.border.Border) UIResource(javax.swing.plaf.UIResource)

Example 2 with UIResource

use of javax.swing.plaf.UIResource in project Botnak by Gocnak.

the class BaseFormattedTextFieldUI method installListeners.

protected void installListeners() {
    super.installListeners();
    if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
        focusListener = new FocusListener() {

            public void focusGained(FocusEvent e) {
                if (getComponent() != null) {
                    orgBorder = getComponent().getBorder();
                    LookAndFeel laf = UIManager.getLookAndFeel();
                    if (laf instanceof AbstractLookAndFeel && orgBorder instanceof UIResource) {
                        Border focusBorder = ((AbstractLookAndFeel) laf).getBorderFactory().getFocusFrameBorder();
                        getComponent().setBorder(focusBorder);
                    }
                    getComponent().invalidate();
                    getComponent().repaint();
                }
            }

            public void focusLost(FocusEvent e) {
                if (getComponent() != null) {
                    if (orgBorder instanceof UIResource) {
                        getComponent().setBorder(orgBorder);
                        getComponent().invalidate();
                        getComponent().repaint();
                    }
                }
            }
        };
        getComponent().addFocusListener(focusListener);
    }
}
Also used : FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent) Border(javax.swing.border.Border) UIResource(javax.swing.plaf.UIResource)

Example 3 with UIResource

use of javax.swing.plaf.UIResource in project Botnak by Gocnak.

the class BaseInternalFrameUI method stripContentBorder.

public void stripContentBorder() {
    Container cp = frame.getContentPane();
    if (cp instanceof JComponent) {
        JComponent contentPane = (JComponent) cp;
        Border contentBorder = contentPane.getBorder();
        if (contentBorder == null || contentBorder instanceof UIResource) {
            contentPane.setBorder(HANDY_EMPTY_BORDER);
        }
    }
}
Also used : EmptyBorder(javax.swing.border.EmptyBorder) Border(javax.swing.border.Border) UIResource(javax.swing.plaf.UIResource)

Example 4 with UIResource

use of javax.swing.plaf.UIResource in project Botnak by Gocnak.

the class GraphiteTabbedPaneUI method paintText.

protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) {
    Color backColor = tabPane.getBackgroundAt(tabIndex);
    if (!(backColor instanceof UIResource)) {
        super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected);
        return;
    }
    g.setFont(font);
    View v = getTextViewForTab(tabIndex);
    if (v != null) {
        // html
        Graphics2D g2D = (Graphics2D) g;
        Object savedRenderingHint = null;
        if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
            savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
            g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, AbstractLookAndFeel.getTheme().getTextAntiAliasingHint());
        }
        v.paint(g, textRect);
        if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
            g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
        }
    } else {
        // plain text
        int mnemIndex = -1;
        if (JTattooUtilities.getJavaVersion() >= 1.4) {
            mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
        }
        if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) {
            if (isSelected) {
                if (ColorHelper.getGrayValue(AbstractLookAndFeel.getControlColorDark()) > 128) {
                    g.setColor(tabPane.getForegroundAt(tabIndex));
                } else {
                    Color titleColor = AbstractLookAndFeel.getWindowTitleForegroundColor();
                    if (ColorHelper.getGrayValue(titleColor) > 164) {
                        g.setColor(Color.black);
                    } else {
                        g.setColor(Color.white);
                    }
                    JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x + 1, textRect.y + 1 + metrics.getAscent());
                    g.setColor(titleColor);
                }
            } else {
                g.setColor(tabPane.getForegroundAt(tabIndex));
            }
            JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
        } else {
            // tab disabled
            g.setColor(Color.white);
            JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x + 1, textRect.y + metrics.getAscent() + 1);
            g.setColor(AbstractLookAndFeel.getDisabledForegroundColor());
            JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
        }
    }
}
Also used : View(javax.swing.text.View) UIResource(javax.swing.plaf.UIResource) ColorUIResource(javax.swing.plaf.ColorUIResource)

Example 5 with UIResource

use of javax.swing.plaf.UIResource in project Botnak by Gocnak.

the class HiFiButtonUI method paintBackground.

protected void paintBackground(Graphics g, AbstractButton b) {
    if (!b.isContentAreaFilled() || (b.getParent() instanceof JMenuBar)) {
        return;
    }
    int width = b.getWidth();
    int height = b.getHeight();
    Graphics2D g2D = (Graphics2D) g;
    Shape savedClip = g.getClip();
    if ((b.getBorder() != null) && b.isBorderPainted() && (b.getBorder() instanceof UIResource)) {
        Area clipArea = new Area(new Rectangle2D.Double(1, 1, width - 2, height - 2));
        clipArea.intersect(new Area(savedClip));
        g2D.setClip(clipArea);
    }
    super.paintBackground(g, b);
    g2D.setClip(savedClip);
}
Also used : Area(java.awt.geom.Area) Rectangle2D(java.awt.geom.Rectangle2D) UIResource(javax.swing.plaf.UIResource) ColorUIResource(javax.swing.plaf.ColorUIResource)

Aggregations

UIResource (javax.swing.plaf.UIResource)33 Border (javax.swing.border.Border)16 FocusEvent (java.awt.event.FocusEvent)6 FocusListener (java.awt.event.FocusListener)6 EmptyBorder (javax.swing.border.EmptyBorder)4 View (javax.swing.text.View)4 JBColor (com.intellij.ui.JBColor)3 Color (java.awt.Color)3 ColorUIResource (javax.swing.plaf.ColorUIResource)3 Area (java.awt.geom.Area)2 FontUIResource (javax.swing.plaf.FontUIResource)2 JTextComponent (javax.swing.text.JTextComponent)2 JRSUIState (apple.laf.JRSUIState)1 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)1 GraphicsConfig (com.intellij.openapi.ui.GraphicsConfig)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 Insets (java.awt.Insets)1 StringSelection (java.awt.datatransfer.StringSelection)1