sun.swing.DefaultLookup Java Examples

The following examples show how to use sun.swing.DefaultLookup. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicButtonListener.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void focusLost(FocusEvent e) {
    AbstractButton b = (AbstractButton) e.getSource();
    JRootPane root = b.getRootPane();
    if (root != null) {
       JButton initialDefault = (JButton)root.getClientProperty("initialDefaultButton");
       if (b != initialDefault) {
           BasicButtonUI ui = (BasicButtonUI)BasicLookAndFeel.getUIOfType(
                     b.getUI(), BasicButtonUI.class);
           if (ui != null && DefaultLookup.getBoolean(b, ui,
                               ui.getPropertyPrefix() +
                               "defaultButtonFollowsFocus", true)) {
               root.setDefaultButton(initialDefault);
           }
       }
    }

    ButtonModel model = b.getModel();
    model.setPressed(false);
    model.setArmed(false);
    b.repaint();
}
 
Example #2
Source File: BasicRootPaneUI.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Invoked when the default button property has changed. This reloads
 * the bindings from the defaults table with name
 * <code>RootPane.defaultButtonWindowKeyBindings</code>.
 */
void updateDefaultButtonBindings(JRootPane root) {
    InputMap km = SwingUtilities.getUIInputMap(root, JComponent.
                                           WHEN_IN_FOCUSED_WINDOW);
    while (km != null && !(km instanceof RootPaneInputMap)) {
        km = km.getParent();
    }
    if (km != null) {
        km.clear();
        if (root.getDefaultButton() != null) {
            Object[] bindings = (Object[])DefaultLookup.get(root, this,
                       "RootPane.defaultButtonWindowKeyBindings");
            if (bindings != null) {
                LookAndFeel.loadKeyBindings(km, bindings);
            }
        }
    }
}
 
Example #3
Source File: BasicTreeUI.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
InputMap getInputMap(int condition) {
    if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
        return (InputMap)DefaultLookup.get(tree, this,
                                           "Tree.ancestorInputMap");
    }
    else if (condition == JComponent.WHEN_FOCUSED) {
        InputMap keyMap = (InputMap)DefaultLookup.get(tree, this,
                                                  "Tree.focusInputMap");
        InputMap rtlKeyMap;

        if (tree.getComponentOrientation().isLeftToRight() ||
              ((rtlKeyMap = (InputMap)DefaultLookup.get(tree, this,
              "Tree.focusInputMap.RightToLeft")) == null)) {
            return keyMap;
        } else {
            rtlKeyMap.setParent(keyMap);
            return rtlKeyMap;
        }
    }
    return null;
}
 
Example #4
Source File: BasicSplitPaneDivider.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an instance of BasicSplitPaneDivider. Registers this
 * instance for mouse events and mouse dragged events.
 */
public BasicSplitPaneDivider(BasicSplitPaneUI ui) {
    oneTouchSize = DefaultLookup.getInt(ui.getSplitPane(), ui,
            "SplitPane.oneTouchButtonSize", ONE_TOUCH_SIZE);
    oneTouchOffset = DefaultLookup.getInt(ui.getSplitPane(), ui,
            "SplitPane.oneTouchButtonOffset", ONE_TOUCH_OFFSET);
    centerOneTouchButtons = DefaultLookup.getBoolean(ui.getSplitPane(),
             ui, "SplitPane.centerOneTouchButtons", true);
    setLayout(new DividerLayout());
    setBasicSplitPaneUI(ui);
    orientation = splitPane.getOrientation();
    setCursor((orientation == JSplitPane.HORIZONTAL_SPLIT) ?
              Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR) :
              Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
    setBackground(UIManager.getColor("SplitPane.background"));
}
 
Example #5
Source File: BasicTextUI.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private void installDefaults2() {
    editor.addMouseListener(dragListener);
    editor.addMouseMotionListener(dragListener);

    String prefix = getPropertyPrefix();

    Caret caret = editor.getCaret();
    if (caret == null || caret instanceof UIResource) {
        caret = createCaret();
        editor.setCaret(caret);

        int rate = DefaultLookup.getInt(getComponent(), this, prefix + ".caretBlinkRate", 500);
        caret.setBlinkRate(rate);
    }

    Highlighter highlighter = editor.getHighlighter();
    if (highlighter == null || highlighter instanceof UIResource) {
        editor.setHighlighter(createHighlighter());
    }

    TransferHandler th = editor.getTransferHandler();
    if (th == null || th instanceof UIResource) {
        editor.setTransferHandler(getTransferHandler());
    }
}
 
Example #6
Source File: BasicListUI.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
InputMap getInputMap(int condition) {
    if (condition == JComponent.WHEN_FOCUSED) {
        InputMap keyMap = (InputMap)DefaultLookup.get(
                         list, this, "List.focusInputMap");
        InputMap rtlKeyMap;

        if (isLeftToRight ||
            ((rtlKeyMap = (InputMap)DefaultLookup.get(list, this,
                          "List.focusInputMap.RightToLeft")) == null)) {
                return keyMap;
        } else {
            rtlKeyMap.setParent(keyMap);
            return rtlKeyMap;
        }
    }
    return null;
}
 
Example #7
Source File: BasicOptionPaneUI.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the icon to use for the passed in type.
 */
protected Icon getIconForType(int messageType) {
    if(messageType < 0 || messageType > 3)
        return null;
    String propertyName = null;
    switch(messageType) {
    case 0:
        propertyName = "OptionPane.errorIcon";
        break;
    case 1:
        propertyName = "OptionPane.informationIcon";
        break;
    case 2:
        propertyName = "OptionPane.warningIcon";
        break;
    case 3:
        propertyName = "OptionPane.questionIcon";
        break;
    }
    if (propertyName != null) {
        return (Icon)DefaultLookup.get(optionPane, this, propertyName);
    }
    return null;
}
 
Example #8
Source File: BasicSliderUI.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
InputMap getInputMap(int condition, JSlider slider) {
    if (condition == JComponent.WHEN_FOCUSED) {
        InputMap keyMap = (InputMap)DefaultLookup.get(slider, this,
              "Slider.focusInputMap");
        InputMap rtlKeyMap;

        if (slider.getComponentOrientation().isLeftToRight() ||
            ((rtlKeyMap = (InputMap)DefaultLookup.get(slider, this,
                      "Slider.focusInputMap.RightToLeft")) == null)) {
            return keyMap;
        } else {
            rtlKeyMap.setParent(keyMap);
            return rtlKeyMap;
        }
    }
    return null;
}
 
Example #9
Source File: BasicListUI.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
InputMap getInputMap(int condition) {
    if (condition == JComponent.WHEN_FOCUSED) {
        InputMap keyMap = (InputMap)DefaultLookup.get(
                         list, this, "List.focusInputMap");
        InputMap rtlKeyMap;

        if (isLeftToRight ||
            ((rtlKeyMap = (InputMap)DefaultLookup.get(list, this,
                          "List.focusInputMap.RightToLeft")) == null)) {
                return keyMap;
        } else {
            rtlKeyMap.setParent(keyMap);
            return rtlKeyMap;
        }
    }
    return null;
}
 
Example #10
Source File: BasicSliderUI.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
InputMap getInputMap(int condition, JSlider slider) {
    if (condition == JComponent.WHEN_FOCUSED) {
        InputMap keyMap = (InputMap)DefaultLookup.get(slider, this,
              "Slider.focusInputMap");
        InputMap rtlKeyMap;

        if (slider.getComponentOrientation().isLeftToRight() ||
            ((rtlKeyMap = (InputMap)DefaultLookup.get(slider, this,
                      "Slider.focusInputMap.RightToLeft")) == null)) {
            return keyMap;
        } else {
            rtlKeyMap.setParent(keyMap);
            return rtlKeyMap;
        }
    }
    return null;
}
 
Example #11
Source File: BasicSplitPaneDivider.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an instance of BasicSplitPaneDivider. Registers this
 * instance for mouse events and mouse dragged events.
 */
public BasicSplitPaneDivider(BasicSplitPaneUI ui) {
    oneTouchSize = DefaultLookup.getInt(ui.getSplitPane(), ui,
            "SplitPane.oneTouchButtonSize", ONE_TOUCH_SIZE);
    oneTouchOffset = DefaultLookup.getInt(ui.getSplitPane(), ui,
            "SplitPane.oneTouchButtonOffset", ONE_TOUCH_OFFSET);
    centerOneTouchButtons = DefaultLookup.getBoolean(ui.getSplitPane(),
             ui, "SplitPane.centerOneTouchButtons", true);
    setLayout(new DividerLayout());
    setBasicSplitPaneUI(ui);
    orientation = splitPane.getOrientation();
    setCursor((orientation == JSplitPane.HORIZONTAL_SPLIT) ?
              Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR) :
              Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
    setBackground(UIManager.getColor("SplitPane.background"));
}
 
Example #12
Source File: BasicButtonListener.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void focusLost(FocusEvent e) {
    AbstractButton b = (AbstractButton) e.getSource();
    JRootPane root = b.getRootPane();
    if (root != null) {
       JButton initialDefault = (JButton)root.getClientProperty("initialDefaultButton");
       if (b != initialDefault) {
           BasicButtonUI ui = (BasicButtonUI)BasicLookAndFeel.getUIOfType(
                     b.getUI(), BasicButtonUI.class);
           if (ui != null && DefaultLookup.getBoolean(b, ui,
                               ui.getPropertyPrefix() +
                               "defaultButtonFollowsFocus", true)) {
               root.setDefaultButton(initialDefault);
           }
       }
    }

    ButtonModel model = b.getModel();
    model.setPressed(false);
    model.setArmed(false);
    b.repaint();
}
 
Example #13
Source File: BasicOptionPaneUI.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Creates and returns a {@code Container} containing the buttons.
 * The buttons are created by calling {@code getButtons}.
 *
 * @return a {@code Container} containing the buttons
 */
protected Container createButtonArea() {
    JPanel bottom = new JPanel();
    Border border = (Border)DefaultLookup.get(optionPane, this,
                                      "OptionPane.buttonAreaBorder");
    bottom.setName("OptionPane.buttonArea");
    if (border != null) {
        bottom.setBorder(border);
    }
    bottom.setLayout(new ButtonAreaLayout(
       DefaultLookup.getBoolean(optionPane, this,
                                "OptionPane.sameSizeButtons", true),
       DefaultLookup.getInt(optionPane, this, "OptionPane.buttonPadding",
                            6),
       DefaultLookup.getInt(optionPane, this,
                    "OptionPane.buttonOrientation", SwingConstants.CENTER),
       DefaultLookup.getBoolean(optionPane, this, "OptionPane.isYesLast",
                                false)));
    addButtonComponents(bottom, getButtons(), getInitialValueIndex());
    return bottom;
}
 
Example #14
Source File: BasicTabbedPaneUI.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected) {
    Rectangle tabRect = rects[tabIndex];
    String propKey = (isSelected ? "selectedLabelShift" : "labelShift");
    int nudge = DefaultLookup.getInt(
            tabPane, this, "TabbedPane." + propKey, 1);

    switch (tabPlacement) {
        case LEFT:
            return nudge;
        case RIGHT:
            return -nudge;
        case BOTTOM:
        case TOP:
        default:
            return tabRect.width % 2;
    }
}
 
Example #15
Source File: BasicRootPaneUI.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Invoked when the default button property has changed. This reloads
 * the bindings from the defaults table with name
 * <code>RootPane.defaultButtonWindowKeyBindings</code>.
 */
void updateDefaultButtonBindings(JRootPane root) {
    InputMap km = SwingUtilities.getUIInputMap(root, JComponent.
                                           WHEN_IN_FOCUSED_WINDOW);
    while (km != null && !(km instanceof RootPaneInputMap)) {
        km = km.getParent();
    }
    if (km != null) {
        km.clear();
        if (root.getDefaultButton() != null) {
            Object[] bindings = (Object[])DefaultLookup.get(root, this,
                       "RootPane.defaultButtonWindowKeyBindings");
            if (bindings != null) {
                LookAndFeel.loadKeyBindings(km, bindings);
            }
        }
    }
}
 
Example #16
Source File: BasicListUI.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
InputMap getInputMap(int condition) {
    if (condition == JComponent.WHEN_FOCUSED) {
        InputMap keyMap = (InputMap)DefaultLookup.get(
                         list, this, "List.focusInputMap");
        InputMap rtlKeyMap;

        if (isLeftToRight ||
            ((rtlKeyMap = (InputMap)DefaultLookup.get(list, this,
                          "List.focusInputMap.RightToLeft")) == null)) {
                return keyMap;
        } else {
            rtlKeyMap.setParent(keyMap);
            return rtlKeyMap;
        }
    }
    return null;
}
 
Example #17
Source File: BasicSpinnerUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void stateChanged(ChangeEvent e) {
    if (e.getSource() instanceof JSpinner) {
        JSpinner spinner = (JSpinner)e.getSource();
        SpinnerUI spinnerUI = spinner.getUI();
        if (DefaultLookup.getBoolean(spinner, spinnerUI,
            "Spinner.disableOnBoundaryValues", false) &&
            spinnerUI instanceof BasicSpinnerUI) {
            BasicSpinnerUI ui = (BasicSpinnerUI)spinnerUI;
            ui.updateEnabledState();
        }
    }
}
 
Example #18
Source File: BasicOptionPaneUI.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Configures any necessary colors/fonts for the specified button
 * used representing the button portion of the optionpane.
 */
private void configureButton(JButton button) {
    Font buttonFont = (Font)DefaultLookup.get(optionPane, this,
                                        "OptionPane.buttonFont");
    if (buttonFont != null) {
        button.setFont(buttonFont);
    }
}
 
Example #19
Source File: BasicOptionPaneUI.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Configures any necessary colors/fonts for the specified button
 * used representing the button portion of the optionpane.
 */
private void configureButton(JButton button) {
    Font buttonFont = (Font)DefaultLookup.get(optionPane, this,
                                        "OptionPane.buttonFont");
    if (buttonFont != null) {
        button.setFont(buttonFont);
    }
}
 
Example #20
Source File: BasicListUI.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private void paintDropLine(Graphics g) {
    JList.DropLocation loc = list.getDropLocation();
    if (loc == null || !loc.isInsert()) {
        return;
    }

    Color c = DefaultLookup.getColor(list, this, "List.dropLineColor", null);
    if (c != null) {
        g.setColor(c);
        Rectangle rect = getDropLineRect(loc);
        g.fillRect(rect.x, rect.y, rect.width, rect.height);
    }
}
 
Example #21
Source File: BasicInternalFrameTitlePane.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void paint(Graphics g) {
    Icon icon = frame.getFrameIcon();
    if (icon == null) {
      icon = (Icon)DefaultLookup.get(frame, frame.getUI(),
              "InternalFrame.icon");
    }
    if (icon != null) {
        // Resize to 16x16 if necessary.
        if (icon instanceof ImageIcon && (icon.getIconWidth() > 16 || icon.getIconHeight() > 16)) {
            Image img = ((ImageIcon)icon).getImage();
            ((ImageIcon)icon).setImage(img.getScaledInstance(16, 16, Image.SCALE_SMOOTH));
        }
        icon.paintIcon(this, g, 0, 0);
    }
}
 
Example #22
Source File: BasicOptionPaneUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Configures any necessary colors/fonts for the specified button
 * used representing the button portion of the optionpane.
 */
private void configureButton(JButton button) {
    Font buttonFont = (Font)DefaultLookup.get(optionPane, this,
                                        "OptionPane.buttonFont");
    if (buttonFont != null) {
        button.setFont(buttonFont);
    }
}
 
Example #23
Source File: BasicOptionPaneUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Messaged from installComponents to create a Container containing the
 * body of the message. The icon is the created by calling
 * <code>addIcon</code>.
 */
protected Container createMessageArea() {
    JPanel top = new JPanel();
    Border topBorder = (Border)DefaultLookup.get(optionPane, this,
                                         "OptionPane.messageAreaBorder");
    if (topBorder != null) {
        top.setBorder(topBorder);
    }
    top.setLayout(new BorderLayout());

    /* Fill the body. */
    Container          body = new JPanel(new GridBagLayout());
    Container          realBody = new JPanel(new BorderLayout());

    body.setName("OptionPane.body");
    realBody.setName("OptionPane.realBody");

    if (getIcon() != null) {
        JPanel sep = new JPanel();
        sep.setName("OptionPane.separator");
        sep.setPreferredSize(new Dimension(15, 1));
        realBody.add(sep, BorderLayout.BEFORE_LINE_BEGINS);
    }
    realBody.add(body, BorderLayout.CENTER);

    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = cons.gridy = 0;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cons.gridheight = 1;
    cons.anchor = DefaultLookup.getInt(optionPane, this,
                  "OptionPane.messageAnchor", GridBagConstraints.CENTER);
    cons.insets = new Insets(0,0,3,0);

    addMessageComponents(body, cons, getMessage(),
                      getMaxCharactersPerLineCount(), false);
    top.add(realBody, BorderLayout.CENTER);

    addIcon(top);
    return top;
}
 
Example #24
Source File: DefaultTableCellRenderer.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private Border getNoFocusBorder() {
    Border border = DefaultLookup.getBorder(this, ui, "Table.cellNoFocusBorder");
    if (System.getSecurityManager() != null) {
        if (border != null) return border;
        return SAFE_NO_FOCUS_BORDER;
    } else if (border != null) {
        if (noFocusBorder == null || noFocusBorder == DEFAULT_NO_FOCUS_BORDER) {
            return border;
        }
    }
    return noFocusBorder;
}
 
Example #25
Source File: BasicTextUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the InputMap to use for the UI.
 */
InputMap getInputMap() {
    InputMap map = new InputMapUIResource();

    InputMap shared =
        (InputMap)DefaultLookup.get(editor, this,
        getPropertyPrefix() + ".focusInputMap");
    if (shared != null) {
        map.setParent(shared);
    }
    return map;
}
 
Example #26
Source File: BasicComboBoxUI.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Paints the background of the currently selected item.
 *
 * @param g an instance of {@code Graphics}
 * @param bounds a bounding rectangle to render to
 * @param hasFocus is focused
 */
public void paintCurrentValueBackground(Graphics g,Rectangle bounds,boolean hasFocus) {
    Color t = g.getColor();
    if ( comboBox.isEnabled() )
        g.setColor(DefaultLookup.getColor(comboBox, this,
                                          "ComboBox.background", null));
    else
        g.setColor(DefaultLookup.getColor(comboBox, this,
                                 "ComboBox.disabledBackground", null));
    g.fillRect(bounds.x,bounds.y,bounds.width,bounds.height);
    g.setColor(t);
}
 
Example #27
Source File: BasicSplitPaneUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
InputMap getInputMap(int condition) {
    if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
        return (InputMap)DefaultLookup.get(splitPane, this,
                                           "SplitPane.ancestorInputMap");
    }
    return null;
}
 
Example #28
Source File: BasicProgressBarUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected Dimension getPreferredInnerVertical() {
    Dimension vertDim = (Dimension)DefaultLookup.get(progressBar, this,
        "ProgressBar.verticalSize");
    if (vertDim == null) {
        vertDim = new Dimension(12, 146);
    }
    return vertDim;
}
 
Example #29
Source File: BasicSliderUI.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Dimension getMinimumVerticalSize() {
    Dimension minVertDim = (Dimension)DefaultLookup.get(slider,
            this, "Slider.minimumVerticalSize");
    if (minVertDim == null) {
        minVertDim = new Dimension(21, 36);
    }
    return minVertDim;
}
 
Example #30
Source File: BasicInternalFrameUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
InputMap createInputMap(int condition) {
    if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
        Object[] bindings = (Object[])DefaultLookup.get(
                frame, this, "InternalFrame.windowBindings");

        if (bindings != null) {
            return LookAndFeel.makeComponentInputMap(frame, bindings);
        }
    }
    return null;
}