Search in sources :

Example 26 with UIResource

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

the class BaseComboBoxUI method installListeners.

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

            public void focusGained(FocusEvent e) {
                if (comboBox != null) {
                    orgBorder = comboBox.getBorder();
                    orgBackgroundColor = comboBox.getBackground();
                    LookAndFeel laf = UIManager.getLookAndFeel();
                    if (laf instanceof AbstractLookAndFeel) {
                        if (orgBorder instanceof UIResource) {
                            Border focusBorder = ((AbstractLookAndFeel) laf).getBorderFactory().getFocusFrameBorder();
                            comboBox.setBorder(focusBorder);
                        }
                        Color backgroundColor = AbstractLookAndFeel.getTheme().getFocusBackgroundColor();
                        comboBox.setBackground(backgroundColor);
                    }
                }
            }

            public void focusLost(FocusEvent e) {
                if (comboBox != null) {
                    if (orgBorder instanceof UIResource) {
                        comboBox.setBorder(orgBorder);
                    }
                    comboBox.setBackground(orgBackgroundColor);
                }
            }
        };
        comboBox.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 27 with UIResource

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

the class BaseEditorPaneUI 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 28 with UIResource

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

the class BasePasswordFieldUI 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 29 with UIResource

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

the class HiFiTabbedPaneUI 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);
        }
        Graphics2D g2D = (Graphics2D) g;
        Composite composite = g2D.getComposite();
        AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
        g2D.setComposite(alpha);
        Color fc = tabPane.getForegroundAt(tabIndex);
        if (isSelected) {
            fc = AbstractLookAndFeel.getTheme().getTabSelectionForegroundColor();
        }
        if (!tabPane.isEnabled() || !tabPane.isEnabledAt(tabIndex)) {
            fc = AbstractLookAndFeel.getTheme().getDisabledForegroundColor();
        }
        if (ColorHelper.getGrayValue(fc) > 128) {
            g2D.setColor(Color.black);
        } else {
            g2D.setColor(Color.white);
        }
        JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x + 1, textRect.y + 1 + metrics.getAscent());
        g2D.setComposite(composite);
        g2D.setColor(fc);
        JTattooUtilities.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
    }
}
Also used : View(javax.swing.text.View) UIResource(javax.swing.plaf.UIResource)

Example 30 with UIResource

use of javax.swing.plaf.UIResource in project android by JetBrains.

the class StatefulButtonUI method paintText.

@Override
protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) {
    if (isHelpButton(c)) {
        return;
    }
    AbstractButton button = (AbstractButton) c;
    ButtonModel model = button.getModel();
    Color fg = button.getForeground();
    if (fg instanceof UIResource && isDefaultButton(button)) {
        fg = SELECTED_BUTTON_FOREGROUND;
    }
    g.setColor(fg);
    FontMetrics metrics = SwingUtilities2.getFontMetrics(c, g);
    int mnemonicIndex = DarculaLaf.isAltPressed() ? button.getDisplayedMnemonicIndex() : -1;
    if (model.isEnabled()) {
        SwingUtilities2.drawStringUnderlineCharAt(c, g, text, mnemonicIndex, textRect.x + getTextShiftOffset(), textRect.y + metrics.getAscent() + getTextShiftOffset());
    } else {
        paintDisabledText(g, text, c, textRect, metrics);
    }
}
Also used : JBColor(com.intellij.ui.JBColor) FontUIResource(javax.swing.plaf.FontUIResource) UIResource(javax.swing.plaf.UIResource)

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