Search in sources :

Example 6 with ComponentUI

use of javax.swing.plaf.ComponentUI in project groovy-core by groovy.

the class TextEditor method getScrollableTracksViewportWidth.

public boolean getScrollableTracksViewportWidth() {
    boolean bool = super.getScrollableTracksViewportWidth();
    if (unwrapped) {
        Component parent = this.getParent();
        ComponentUI ui = this.getUI();
        int uiWidth = ui.getPreferredSize(this).width;
        bool = (parent == null) || (uiWidth < parent.getSize().width);
    }
    return bool;
}
Also used : ComponentUI(javax.swing.plaf.ComponentUI) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent)

Example 7 with ComponentUI

use of javax.swing.plaf.ComponentUI in project groovy by apache.

the class TextEditor method getScrollableTracksViewportWidth.

public boolean getScrollableTracksViewportWidth() {
    boolean bool = super.getScrollableTracksViewportWidth();
    if (unwrapped) {
        Component parent = this.getParent();
        ComponentUI ui = this.getUI();
        int uiWidth = ui.getPreferredSize(this).width;
        bool = (parent == null) || (uiWidth < parent.getSize().width);
    }
    return bool;
}
Also used : ComponentUI(javax.swing.plaf.ComponentUI) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent)

Example 8 with ComponentUI

use of javax.swing.plaf.ComponentUI in project jdk8u_jdk by JetBrains.

the class bug6657138 method testUIMap.

private static void testUIMap() throws Exception {
    UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels();
    Set<JComponent> components = componentMap.keySet();
    for (JComponent c : components) {
        Map<String, ComponentUI> uiMap = componentMap.get(c);
        for (UIManager.LookAndFeelInfo laf : lafs) {
            if ("Nimbus".equals(laf.getName())) {
                // when this method is called from the new AppContext
                continue;
            }
            String className = laf.getClassName();
            UIManager.setLookAndFeel(className);
            ComponentUI ui = UIManager.getUI(c);
            if (ui == null) {
                throw new RuntimeException("UI is null for " + c);
            }
            if (ui == uiMap.get(laf.getName())) {
                throw new RuntimeException("Two AppContexts share the same UI delegate! \n" + c + "\n" + ui);
            }
            uiMap.put(laf.getName(), ui);
        }
    }
}
Also used : ComponentUI(javax.swing.plaf.ComponentUI)

Example 9 with ComponentUI

use of javax.swing.plaf.ComponentUI in project JMRI by JMRI.

the class SliderSnap method createUI.

/**
     * Returns the UI as normal, but intercepts the call, so that a listener can
     * be attached
     *
     * @param c the slider component
     * @return a ComponentUI object with attached listener
     */
public static ComponentUI createUI(JComponent c) {
    if (c == null || sliderClass == null) {
        return null;
    }
    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    try {
        Method m = (Method) defaults.get(sliderClass);
        if (m == null) {
            m = //NOI18N
            sliderClass.getMethod(//NOI18N
            "createUI", new Class<?>[] { JComponent.class });
            defaults.put(sliderClass, m);
        }
        ComponentUI uiObject = (ComponentUI) m.invoke(null, new Object[] { c });
        if (uiObject instanceof BasicSliderUI) {
            c.addHierarchyListener(new MouseAttacher());
        }
        return uiObject;
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        throw new RuntimeException(e);
    }
}
Also used : UIDefaults(javax.swing.UIDefaults) JComponent(javax.swing.JComponent) BasicSliderUI(javax.swing.plaf.basic.BasicSliderUI) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) ComponentUI(javax.swing.plaf.ComponentUI)

Aggregations

ComponentUI (javax.swing.plaf.ComponentUI)9 Component (java.awt.Component)2 Method (java.lang.reflect.Method)2 JTextComponent (javax.swing.text.JTextComponent)2 WindowsSliderUI (com.sun.java.swing.plaf.windows.WindowsSliderUI)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 JComponent (javax.swing.JComponent)1 JFileChooser (javax.swing.JFileChooser)1 UIDefaults (javax.swing.UIDefaults)1 BasicSliderUI (javax.swing.plaf.basic.BasicSliderUI)1