Java Code Examples for sun.swing.DefaultLookup

The following examples show how to use sun.swing.DefaultLookup. These examples are extracted from open source projects. 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 Project: jdk8u60   Source File: BasicButtonListener.java    License: 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
/**
 * 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 Project: openjdk-jdk8u   Source File: BasicTreeUI.java    License: 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
/**
 * 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 Project: jdk1.8-source-analysis   Source File: BasicTextUI.java    License: 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 Project: JDKSourceCode1.8   Source File: BasicListUI.java    License: 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 Project: jdk8u-jdk   Source File: BasicOptionPaneUI.java    License: 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 Project: jdk1.8-source-analysis   Source File: BasicSliderUI.java    License: 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 Project: TencentKona-8   Source File: BasicListUI.java    License: 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 Project: Bytecoder   Source File: BasicSliderUI.java    License: 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
/**
 * 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
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 Project: Bytecoder   Source File: BasicOptionPaneUI.java    License: 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
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 Project: jdk1.8-source-analysis   Source File: BasicRootPaneUI.java    License: 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 Project: jdk1.8-source-analysis   Source File: BasicListUI.java    License: 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
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 Project: jdk8u_jdk   Source File: BasicOptionPaneUI.java    License: 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
/**
 * 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 Project: Bytecoder   Source File: BasicListUI.java    License: 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
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 Project: Java8CN   Source File: BasicOptionPaneUI.java    License: 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 Project: Java8CN   Source File: BasicOptionPaneUI.java    License: 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
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 Project: dragonwell8_jdk   Source File: BasicTextUI.java    License: 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 Project: openjdk-jdk9   Source File: BasicComboBoxUI.java    License: 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 Project: jdk8u-jdk   Source File: BasicSplitPaneUI.java    License: 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 Project: jdk8u-jdk   Source File: BasicProgressBarUI.java    License: 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 Project: TencentKona-8   Source File: BasicSliderUI.java    License: 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
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;
}