Search in sources :

Example 1 with ComponentUI

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

the class JRangeSlider method updateUI.

/**
     * Overrides the superclass method to install the UI delegate to draw two
     * thumbs.
     */
@Override
public void updateUI() {
    ComponentUI uiv = UIManager.getUI(this);
    if (uiv instanceof WindowsSliderUI) {
        uiv = new JRangeSliderWindowsUI(this);
    } else {
        uiv = new JRangeSliderBasicUI(this);
    }
    setUI(uiv);
    // Update UI for slider labels.  This must be called after updating the
    // UI of the slider.  Refer to JSlider.updateUI().
    updateLabelUIs();
}
Also used : ComponentUI(javax.swing.plaf.ComponentUI) WindowsSliderUI(com.sun.java.swing.plaf.windows.WindowsSliderUI)

Example 2 with ComponentUI

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

the class UIManager method getUI.

/**
     * Returns the appropriate {@code ComponentUI} implementation for
     * {@code target}. Typically, this is a cover for
     * {@code getDefaults().getUI(target)}. However, if an auxiliary
     * look and feel has been installed, this first invokes
     * {@code getUI(target)} on the multiplexing look and feel's
     * defaults, and returns that value if it is {@code non-null}.
     *
     * @param target the <code>JComponent</code> to return the
     *        {@code ComponentUI} for
     * @return the <code>ComponentUI</code> object for {@code target}
     * @throws NullPointerException if {@code target} is {@code null}
     * @see UIDefaults#getUI
     */
public static ComponentUI getUI(JComponent target) {
    maybeInitialize();
    maybeInitializeFocusPolicy(target);
    ComponentUI ui = null;
    LookAndFeel multiLAF = getLAFState().multiLookAndFeel;
    if (multiLAF != null) {
        // This can return null if the multiplexing look and feel
        // doesn't support a particular UI.
        ui = multiLAF.getDefaults().getUI(target);
    }
    if (ui == null) {
        ui = getDefaults().getUI(target);
    }
    return ui;
}
Also used : ComponentUI(javax.swing.plaf.ComponentUI)

Example 3 with ComponentUI

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

the class ScreenMenuItem method addNotify.

public void addNotify() {
    super.addNotify();
    fMenuItem.addComponentListener(this);
    fListener = new ScreenMenuPropertyListener(this);
    fMenuItem.addPropertyChangeListener(fListener);
    addActionListener(this);
    setEnabled(fMenuItem.isEnabled());
    // can't setState or setAccelerator or setIcon till we have a peer
    setAccelerator(fMenuItem.getAccelerator());
    final String label = fMenuItem.getText();
    if (label != null) {
        setLabel(label);
    }
    final Icon icon = fMenuItem.getIcon();
    if (icon != null) {
        this.setIcon(icon);
    }
    final String tooltipText = fMenuItem.getToolTipText();
    if (tooltipText != null) {
        this.setToolTipText(tooltipText);
    }
    if (fMenuItem instanceof JRadioButtonMenuItem) {
        final ComponentUI ui = fMenuItem.getUI();
        if (ui instanceof ScreenMenuItemUI) {
            ((ScreenMenuItemUI) ui).updateListenersForScreenMenuItem();
        }
    }
}
Also used : ComponentUI(javax.swing.plaf.ComponentUI)

Example 4 with ComponentUI

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

the class GradientSlider method updateUI.

@Override
public void updateUI() {
    String name = UIManager.getString("GradientSliderUI");
    try {
        Class c = Class.forName(name);
        Constructor[] constructors = c.getConstructors();
        for (int a = 0; a < constructors.length; a++) {
            Class[] types = constructors[a].getParameterTypes();
            if (types.length == 1 && types[0].equals(GradientSlider.class)) {
                ComponentUI ui = (ComponentUI) constructors[a].newInstance(new Object[] { this });
                setUI(ui);
                return;
            }
        }
    } catch (ClassNotFoundException e) {
        throw new RuntimeException("The class \"" + name + "\" could not be found.");
    } catch (Throwable t) {
        RuntimeException e = new RuntimeException("The class \"" + name + "\" could not be constructed.");
        e.initCause(t);
        throw e;
    }
}
Also used : ComponentUI(javax.swing.plaf.ComponentUI) Constructor(java.lang.reflect.Constructor)

Example 5 with ComponentUI

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

the class DelegatingChooserUI method createUI.

public static ComponentUI createUI(JComponent c) {
    JFileChooser fc = (JFileChooser) c;
    // it's terribly slow on Windows due to JDK bug
    if (Utilities.isWindows()) {
        if (System.getProperty(NB_USE_SHELL_FOLDER) != null) {
            fc.putClientProperty(USE_SHELL_FOLDER, Boolean.getBoolean(NB_USE_SHELL_FOLDER));
        } else {
            String jv = System.getProperty("java.version");
            jv = jv.split("-", 2)[0];
            if ("1.6.0_02".compareToIgnoreCase(jv) <= 0 && "1.6.0_10".compareToIgnoreCase(jv) >= 0) {
                if (!Boolean.TRUE.equals(fc.getClientProperty(USE_SHELL_FOLDER))) {
                    fc.putClientProperty(USE_SHELL_FOLDER, Boolean.FALSE);
                }
            }
        }
    }
    // because of property listenign below)
    if (fc.getClientProperty(START_TIME) == null) {
        fc.putClientProperty(START_TIME, Long.valueOf(System.currentTimeMillis()));
    }
    Class<? extends FileChooserUI> chooser = getCurChooser(fc);
    ComponentUI compUI;
    try {
        Method createUIMethod = chooser.getMethod("createUI", JComponent.class);
        compUI = (ComponentUI) createUIMethod.invoke(null, fc);
    } catch (Exception exc) {
        Logger.getLogger(DelegatingChooserUI.class.getName()).log(Level.FINE, "Could not instantiate custom chooser, fallbacking to Metal", exc);
        compUI = MetalFileChooserUI.createUI(c);
    }
    // filechooser.updateUI() which triggers this createUI again 
    if (firstTime) {
        fc.addPropertyChangeListener(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY, new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                JFileChooser fileChooser = (JFileChooser) evt.getSource();
                fileChooser.updateUI();
            }
        });
    }
    return compUI;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) JFileChooser(javax.swing.JFileChooser) ComponentUI(javax.swing.plaf.ComponentUI) PropertyChangeListener(java.beans.PropertyChangeListener) Method(java.lang.reflect.Method)

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