Java Code Examples for sun.swing.DefaultLookup#getBoolean()
The following examples show how to use
sun.swing.DefaultLookup#getBoolean() .
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 openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void focusGained(FocusEvent e) { AbstractButton b = (AbstractButton) e.getSource(); if (b instanceof JButton && ((JButton)b).isDefaultCapable()) { JRootPane root = b.getRootPane(); if (root != null) { BasicButtonUI ui = (BasicButtonUI)BasicLookAndFeel.getUIOfType( b.getUI(), BasicButtonUI.class); if (ui != null && DefaultLookup.getBoolean(b, ui, ui.getPropertyPrefix() + "defaultButtonFollowsFocus", true)) { root.putClientProperty("temporaryDefaultButton", b); root.setDefaultButton((JButton)b); root.putClientProperty("temporaryDefaultButton", null); } } } b.repaint(); }
Example 2
Source File: DefaultTableCellHeaderRenderer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override public void paintComponent(Graphics g) { boolean b = DefaultLookup.getBoolean(this, ui, "TableHeader.rightAlignSortArrow", false); if (b && sortArrow != null) { //emptyIcon is used so that if the text in the header is right //aligned, or if the column is too narrow, then the text will //be sized appropriately to make room for the icon that is about //to be painted manually here. emptyIcon.width = sortArrow.getIconWidth(); emptyIcon.height = sortArrow.getIconHeight(); setIcon(emptyIcon); super.paintComponent(g); Point position = computeIconPosition(g); sortArrow.paintIcon(this, g, position.x, position.y); } else { super.paintComponent(g); } }
Example 3
Source File: DefaultTableCellHeaderRenderer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public void paintComponent(Graphics g) { boolean b = DefaultLookup.getBoolean(this, ui, "TableHeader.rightAlignSortArrow", false); if (b && sortArrow != null) { //emptyIcon is used so that if the text in the header is right //aligned, or if the column is too narrow, then the text will //be sized appropriately to make room for the icon that is about //to be painted manually here. emptyIcon.width = sortArrow.getIconWidth(); emptyIcon.height = sortArrow.getIconHeight(); setIcon(emptyIcon); super.paintComponent(g); Point position = computeIconPosition(g); sortArrow.paintIcon(this, g, position.x, position.y); } else { super.paintComponent(g); } }
Example 4
Source File: BasicSplitPaneDivider.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Creates an instance of {@code BasicSplitPaneDivider}. Registers this * instance for mouse events and mouse dragged events. * * @param ui an instance of {@code BasicSplitPaneUI} */ 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: BasicSpinnerUI.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Initializes <code>PropertyChangeListener</code> with * a shared object that delegates interesting PropertyChangeEvents * to protected methods. * <p> * This method is called by <code>installUI</code>. * * @see #replaceEditor * @see #uninstallListeners */ protected void installListeners() { propertyChangeListener = createPropertyChangeListener(); spinner.addPropertyChangeListener(propertyChangeListener); if (DefaultLookup.getBoolean(spinner, this, "Spinner.disableOnBoundaryValues", false)) { spinner.addChangeListener(getHandler()); } JComponent editor = spinner.getEditor(); if (editor != null && editor instanceof JSpinner.DefaultEditor) { JTextField tf = ((JSpinner.DefaultEditor)editor).getTextField(); if (tf != null) { tf.addFocusListener(nextButtonHandler); tf.addFocusListener(previousButtonHandler); } } }
Example 6
Source File: BasicButtonListener.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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 7
Source File: BasicSpinnerUI.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Recursively updates the enabled state of the child * <code>Component</code>s of <code>c</code>. */ private void updateEnabledState(Container c, boolean enabled) { for (int counter = c.getComponentCount() - 1; counter >= 0;counter--) { Component child = c.getComponent(counter); if (DefaultLookup.getBoolean(spinner, this, "Spinner.disableOnBoundaryValues", false)) { SpinnerModel model = spinner.getModel(); if (child.getName() == "Spinner.nextButton" && model.getNextValue() == null) { child.setEnabled(false); } else if (child.getName() == "Spinner.previousButton" && model.getPreviousValue() == null) { child.setEnabled(false); } else { child.setEnabled(enabled); } } else { child.setEnabled(enabled); } if (child instanceof Container) { updateEnabledState((Container)child, enabled); } } }
Example 8
Source File: BasicSplitPaneDivider.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Messaged when the oneTouchExpandable value of the JSplitPane the * receiver is contained in changes. Will create the * <code>leftButton</code> and <code>rightButton</code> if they * are null. invalidates the receiver as well. */ protected void oneTouchExpandableChanged() { if (!DefaultLookup.getBoolean(splitPane, splitPaneUI, "SplitPane.supportsOneTouchButtons", true)) { // Look and feel doesn't want to support one touch buttons, bail. return; } if (splitPane.isOneTouchExpandable() && leftButton == null && rightButton == null) { /* Create the left button and add an action listener to expand/collapse it. */ leftButton = createLeftOneTouchButton(); if (leftButton != null) leftButton.addActionListener(new OneTouchActionHandler(true)); /* Create the right button and add an action listener to expand/collapse it. */ rightButton = createRightOneTouchButton(); if (rightButton != null) rightButton.addActionListener(new OneTouchActionHandler (false)); if (leftButton != null && rightButton != null) { add(leftButton); add(rightButton); } } revalidateSplitPane(); }
Example 9
Source File: BasicSpinnerUI.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 10
Source File: BasicSpinnerUI.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Recursively updates the enabled state of the child * <code>Component</code>s of <code>c</code>. */ private void updateEnabledState(Container c, boolean enabled) { for (int counter = c.getComponentCount() - 1; counter >= 0;counter--) { Component child = c.getComponent(counter); if (DefaultLookup.getBoolean(spinner, this, "Spinner.disableOnBoundaryValues", false)) { SpinnerModel model = spinner.getModel(); if (child.getName() == "Spinner.nextButton" && model.getNextValue() == null) { child.setEnabled(false); } else if (child.getName() == "Spinner.previousButton" && model.getPreviousValue() == null) { child.setEnabled(false); } else { child.setEnabled(enabled); } } else { child.setEnabled(enabled); } if (child instanceof Container) { updateEnabledState((Container)child, enabled); } } }
Example 11
Source File: BasicTabbedPaneUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void navigateTo(int index) { if (DefaultLookup.getBoolean(tabPane, this, "TabbedPane.selectionFollowsFocus", true)) { tabPane.setSelectedIndex(index); } else { // Just move focus (not selection) setFocusIndex(index, true); } }
Example 12
Source File: BasicScrollBarUI.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
protected void layoutVScrollbar(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); /* * Width and left edge of the buttons and thumb. */ int itemW = sbSize.width - (sbInsets.left + sbInsets.right); int itemX = sbInsets.left; /* Nominal locations of the buttons, assuming their preferred * size will fit. */ boolean squareButtons = DefaultLookup.getBoolean( scrollbar, this, "ScrollBar.squareButtons", false); int decrButtonH = squareButtons ? itemW : decrButton.getPreferredSize().height; int decrButtonY = sbInsets.top; int incrButtonH = squareButtons ? itemW : incrButton.getPreferredSize().height; int incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH); /* The thumb must fit within the height left over after we * subtract the preferredSize of the buttons and the insets * and the gaps */ int sbInsetsH = sbInsets.top + sbInsets.bottom; int sbButtonsH = decrButtonH + incrButtonH; int gaps = decrGap + incrGap; float trackH = sbSize.height - (sbInsetsH + sbButtonsH) - gaps; /* Compute the height and origin of the thumb. The case * where the thumb is at the bottom edge is handled specially * to avoid numerical problems in computing thumbY. Enforce * the thumbs min/max dimensions. If the thumb doesn't * fit in the track (trackH) we'll hide it later. */ float min = sb.getMinimum(); float extent = sb.getVisibleAmount(); float range = sb.getMaximum() - min; float value = getValue(sb); int thumbH = (range <= 0) ? getMaximumThumbSize().height : (int)(trackH * (extent / range)); thumbH = Math.max(thumbH, getMinimumThumbSize().height); thumbH = Math.min(thumbH, getMaximumThumbSize().height); int thumbY = incrButtonY - incrGap - thumbH; if (value < (sb.getMaximum() - sb.getVisibleAmount())) { float thumbRange = trackH - thumbH; thumbY = (int)(0.5f + (thumbRange * ((value - min) / (range - extent)))); thumbY += decrButtonY + decrButtonH + decrGap; } /* If the buttons don't fit, allocate half of the available * space to each and move the lower one (incrButton) down. */ int sbAvailButtonH = (sbSize.height - sbInsetsH); if (sbAvailButtonH < sbButtonsH) { incrButtonH = decrButtonH = sbAvailButtonH / 2; incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH); } decrButton.setBounds(itemX, decrButtonY, itemW, decrButtonH); incrButton.setBounds(itemX, incrButtonY, itemW, incrButtonH); /* Update the trackRect field. */ int itrackY = decrButtonY + decrButtonH + decrGap; int itrackH = incrButtonY - incrGap - itrackY; trackRect.setBounds(itemX, itrackY, itemW, itrackH); /* If the thumb isn't going to fit, zero it's bounds. Otherwise * make sure it fits between the buttons. Note that setting the * thumbs bounds will cause a repaint. */ if(thumbH >= (int)trackH) { if (UIManager.getBoolean("ScrollBar.alwaysShowThumb")) { // This is used primarily for GTK L&F, which expands the // thumb to fit the track when it would otherwise be hidden. setThumbBounds(itemX, itrackY, itemW, itrackH); } else { // Other L&F's simply hide the thumb in this case. setThumbBounds(0, 0, 0, 0); } } else { if ((thumbY + thumbH) > incrButtonY - incrGap) { thumbY = incrButtonY - incrGap - thumbH; } if (thumbY < (decrButtonY + decrButtonH + decrGap)) { thumbY = decrButtonY + decrButtonH + decrGap + 1; } setThumbBounds(itemX, thumbY, itemW, thumbH); } }
Example 13
Source File: DefaultTreeCellRenderer.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} * * @since 1.7 */ public void updateUI() { super.updateUI(); // To avoid invoking new methods from the constructor, the // inited field is first checked. If inited is false, the constructor // has not run and there is no point in checking the value. As // all look and feels have a non-null value for these properties, // a null value means the developer has specifically set it to // null. As such, if the value is null, this does not reset the // value. if (!inited || (getLeafIcon() instanceof UIResource)) { setLeafIcon(DefaultLookup.getIcon(this, ui, "Tree.leafIcon")); } if (!inited || (getClosedIcon() instanceof UIResource)) { setClosedIcon(DefaultLookup.getIcon(this, ui, "Tree.closedIcon")); } if (!inited || (getOpenIcon() instanceof UIManager)) { setOpenIcon(DefaultLookup.getIcon(this, ui, "Tree.openIcon")); } if (!inited || (getTextSelectionColor() instanceof UIResource)) { setTextSelectionColor( DefaultLookup.getColor(this, ui, "Tree.selectionForeground")); } if (!inited || (getTextNonSelectionColor() instanceof UIResource)) { setTextNonSelectionColor( DefaultLookup.getColor(this, ui, "Tree.textForeground")); } if (!inited || (getBackgroundSelectionColor() instanceof UIResource)) { setBackgroundSelectionColor( DefaultLookup.getColor(this, ui, "Tree.selectionBackground")); } if (!inited || (getBackgroundNonSelectionColor() instanceof UIResource)) { setBackgroundNonSelectionColor( DefaultLookup.getColor(this, ui, "Tree.textBackground")); } if (!inited || (getBorderSelectionColor() instanceof UIResource)) { setBorderSelectionColor( DefaultLookup.getColor(this, ui, "Tree.selectionBorderColor")); } drawsFocusBorderAroundIcon = DefaultLookup.getBoolean( this, ui, "Tree.drawsFocusBorderAroundIcon", false); drawDashedFocusIndicator = DefaultLookup.getBoolean( this, ui, "Tree.drawDashedFocusIndicator", false); fillBackground = DefaultLookup.getBoolean(this, ui, "Tree.rendererFillBackground", true); Insets margins = DefaultLookup.getInsets(this, ui, "Tree.rendererMargins"); if (margins != null) { setBorder(new EmptyBorder(margins.top, margins.left, margins.bottom, margins.right)); } setName("Tree.cellRenderer"); }
Example 14
Source File: SynthOptionPaneUI.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected boolean getSizeButtonsToSameWidth() { return DefaultLookup.getBoolean(optionPane, this, "OptionPane.sameSizeButtons", true); }
Example 15
Source File: SynthOptionPaneUI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected boolean getSizeButtonsToSameWidth() { return DefaultLookup.getBoolean(optionPane, this, "OptionPane.sameSizeButtons", true); }
Example 16
Source File: BasicTreeUI.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Ensures that the rows identified by beginRow through endRow are * visible. */ protected void ensureRowsAreVisible(int beginRow, int endRow) { if(tree != null && beginRow >= 0 && endRow < getRowCount(tree)) { boolean scrollVert = DefaultLookup.getBoolean(tree, this, "Tree.scrollsHorizontallyAndVertically", false); if(beginRow == endRow) { Rectangle scrollBounds = getPathBounds(tree, getPathForRow (tree, beginRow)); if(scrollBounds != null) { if (!scrollVert) { scrollBounds.x = tree.getVisibleRect().x; scrollBounds.width = 1; } tree.scrollRectToVisible(scrollBounds); } } else { Rectangle beginRect = getPathBounds(tree, getPathForRow (tree, beginRow)); if (beginRect != null) { Rectangle visRect = tree.getVisibleRect(); Rectangle testRect = beginRect; int beginY = beginRect.y; int maxY = beginY + visRect.height; for(int counter = beginRow + 1; counter <= endRow; counter++) { testRect = getPathBounds(tree, getPathForRow(tree, counter)); if (testRect == null) { return; } if((testRect.y + testRect.height) > maxY) counter = endRow; } tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1, testRect.y + testRect.height- beginY)); } } } }
Example 17
Source File: BasicScrollBarUI.java From JDKSourceCode1.8 with MIT License | 4 votes |
protected void layoutVScrollbar(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); /* * Width and left edge of the buttons and thumb. */ int itemW = sbSize.width - (sbInsets.left + sbInsets.right); int itemX = sbInsets.left; /* Nominal locations of the buttons, assuming their preferred * size will fit. */ boolean squareButtons = DefaultLookup.getBoolean( scrollbar, this, "ScrollBar.squareButtons", false); int decrButtonH = squareButtons ? itemW : decrButton.getPreferredSize().height; int decrButtonY = sbInsets.top; int incrButtonH = squareButtons ? itemW : incrButton.getPreferredSize().height; int incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH); /* The thumb must fit within the height left over after we * subtract the preferredSize of the buttons and the insets * and the gaps */ int sbInsetsH = sbInsets.top + sbInsets.bottom; int sbButtonsH = decrButtonH + incrButtonH; int gaps = decrGap + incrGap; float trackH = sbSize.height - (sbInsetsH + sbButtonsH) - gaps; /* Compute the height and origin of the thumb. The case * where the thumb is at the bottom edge is handled specially * to avoid numerical problems in computing thumbY. Enforce * the thumbs min/max dimensions. If the thumb doesn't * fit in the track (trackH) we'll hide it later. */ float min = sb.getMinimum(); float extent = sb.getVisibleAmount(); float range = sb.getMaximum() - min; float value = getValue(sb); int thumbH = (range <= 0) ? getMaximumThumbSize().height : (int)(trackH * (extent / range)); thumbH = Math.max(thumbH, getMinimumThumbSize().height); thumbH = Math.min(thumbH, getMaximumThumbSize().height); int thumbY = incrButtonY - incrGap - thumbH; if (value < (sb.getMaximum() - sb.getVisibleAmount())) { float thumbRange = trackH - thumbH; thumbY = (int)(0.5f + (thumbRange * ((value - min) / (range - extent)))); thumbY += decrButtonY + decrButtonH + decrGap; } /* If the buttons don't fit, allocate half of the available * space to each and move the lower one (incrButton) down. */ int sbAvailButtonH = (sbSize.height - sbInsetsH); if (sbAvailButtonH < sbButtonsH) { incrButtonH = decrButtonH = sbAvailButtonH / 2; incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH); } decrButton.setBounds(itemX, decrButtonY, itemW, decrButtonH); incrButton.setBounds(itemX, incrButtonY, itemW, incrButtonH); /* Update the trackRect field. */ int itrackY = decrButtonY + decrButtonH + decrGap; int itrackH = incrButtonY - incrGap - itrackY; trackRect.setBounds(itemX, itrackY, itemW, itrackH); /* If the thumb isn't going to fit, zero it's bounds. Otherwise * make sure it fits between the buttons. Note that setting the * thumbs bounds will cause a repaint. */ if(thumbH >= (int)trackH) { if (UIManager.getBoolean("ScrollBar.alwaysShowThumb")) { // This is used primarily for GTK L&F, which expands the // thumb to fit the track when it would otherwise be hidden. setThumbBounds(itemX, itrackY, itemW, itrackH); } else { // Other L&F's simply hide the thumb in this case. setThumbBounds(0, 0, 0, 0); } } else { if ((thumbY + thumbH) > incrButtonY - incrGap) { thumbY = incrButtonY - incrGap - thumbH; } if (thumbY < (decrButtonY + decrButtonH + decrGap)) { thumbY = decrButtonY + decrButtonH + decrGap + 1; } setThumbBounds(itemX, thumbY, itemW, thumbH); } }
Example 18
Source File: BasicTreeUI.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * Ensures that the rows identified by {@code beginRow} through * {@code endRow} are visible. * * @param beginRow the begin row * @param endRow the end row */ protected void ensureRowsAreVisible(int beginRow, int endRow) { if(tree != null && beginRow >= 0 && endRow < getRowCount(tree)) { boolean scrollVert = DefaultLookup.getBoolean(tree, this, "Tree.scrollsHorizontallyAndVertically", false); if(beginRow == endRow) { Rectangle scrollBounds = getPathBounds(tree, getPathForRow (tree, beginRow)); if(scrollBounds != null) { if (!scrollVert) { scrollBounds.x = tree.getVisibleRect().x; scrollBounds.width = 1; } tree.scrollRectToVisible(scrollBounds); } } else { Rectangle beginRect = getPathBounds(tree, getPathForRow (tree, beginRow)); if (beginRect != null) { Rectangle visRect = tree.getVisibleRect(); Rectangle testRect = beginRect; int beginY = beginRect.y; int maxY = beginY + visRect.height; for(int counter = beginRow + 1; counter <= endRow; counter++) { testRect = getPathBounds(tree, getPathForRow(tree, counter)); if (testRect == null) { return; } if((testRect.y + testRect.height) > maxY) counter = endRow; } tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1, testRect.y + testRect.height- beginY)); } } } }
Example 19
Source File: BasicTreeUI.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Ensures that the rows identified by beginRow through endRow are * visible. */ protected void ensureRowsAreVisible(int beginRow, int endRow) { if(tree != null && beginRow >= 0 && endRow < getRowCount(tree)) { boolean scrollVert = DefaultLookup.getBoolean(tree, this, "Tree.scrollsHorizontallyAndVertically", false); if(beginRow == endRow) { Rectangle scrollBounds = getPathBounds(tree, getPathForRow (tree, beginRow)); if(scrollBounds != null) { if (!scrollVert) { scrollBounds.x = tree.getVisibleRect().x; scrollBounds.width = 1; } tree.scrollRectToVisible(scrollBounds); } } else { Rectangle beginRect = getPathBounds(tree, getPathForRow (tree, beginRow)); if (beginRect != null) { Rectangle visRect = tree.getVisibleRect(); Rectangle testRect = beginRect; int beginY = beginRect.y; int maxY = beginY + visRect.height; for(int counter = beginRow + 1; counter <= endRow; counter++) { testRect = getPathBounds(tree, getPathForRow(tree, counter)); if (testRect == null) { return; } if((testRect.y + testRect.height) > maxY) counter = endRow; } tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1, testRect.y + testRect.height- beginY)); } } } }
Example 20
Source File: SynthOptionPaneUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected boolean getSizeButtonsToSameWidth() { return DefaultLookup.getBoolean(optionPane, this, "OptionPane.sameSizeButtons", true); }