Java Code Examples for javax.swing.UIManager#get()

The following examples show how to use javax.swing.UIManager#get() . 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: StatusLineComponent.java    From netbeans with Apache License 2.0 8 votes vote down vote up
private void createCloseButton() {
    discardCloseButton();
    closeButton = new JButton();
    closeButton.setBorderPainted(false);
    closeButton.setBorder(BorderFactory.createEmptyBorder());
    closeButton.setOpaque(false);
    closeButton.setContentAreaFilled(false);
    
    Object img = UIManager.get("nb.progress.cancel.icon");
    if( null != img ) {
        closeButton.setIcon( ListComponent.iconOrImage2icon( img ) );
    }
    img = UIManager.get("nb.progress.cancel.icon.mouseover");
    if( null != img ) {
        closeButton.setRolloverEnabled(true);
        closeButton.setRolloverIcon( ListComponent.iconOrImage2icon( img ) );
    }
    img = UIManager.get("nb.progress.cancel.icon.pressed");
    if( null != img ) {
        closeButton.setPressedIcon( ListComponent.iconOrImage2icon( img ) );
    }
}
 
Example 2
Source File: BasicLookAndFeel.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If necessary, invokes {@code actionPerformed} on
 * {@code audioAction} to play a sound.
 * The {@code actionPerformed} method is invoked if the value of
 * the {@code "AuditoryCues.playList"} default is a {@code
 * non-null} {@code Object[]} containing a {@code String} entry
 * equal to the name of the {@code audioAction}.
 *
 * @param audioAction an Action that knows how to render the audio
 *                    associated with the system or user activity
 *                    that is occurring; a value of {@code null}, is
 *                    ignored
 * @throws ClassCastException if {@code audioAction} is {@code non-null}
 *         and the value of the default {@code "AuditoryCues.playList"}
 *         is not an {@code Object[]}
 * @since 1.4
 */
protected void playSound(Action audioAction) {
    if (audioAction != null) {
        Object[] audioStrings = (Object[])
                                UIManager.get("AuditoryCues.playList");
        if (audioStrings != null) {
            // create a HashSet to help us decide to play or not
            HashSet<Object> audioCues = new HashSet<Object>();
            for (Object audioString : audioStrings) {
                audioCues.add(audioString);
            }
            // get the name of the Action
            String actionName = (String)audioAction.getValue(Action.NAME);
            // if the actionName is in the audioCues HashSet, play it.
            if (audioCues.contains(actionName)) {
                audioAction.actionPerformed(new
                    ActionEvent(this, ActionEvent.ACTION_PERFORMED,
                                actionName));
            }
        }
    }
}
 
Example 3
Source File: TableScrollPaneCorner.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    Painter painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
Example 4
Source File: BasicLookAndFeel.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * If necessary, invokes {@code actionPerformed} on
 * {@code audioAction} to play a sound.
 * The {@code actionPerformed} method is invoked if the value of
 * the {@code "AuditoryCues.playList"} default is a {@code
 * non-null} {@code Object[]} containing a {@code String} entry
 * equal to the name of the {@code audioAction}.
 *
 * @param audioAction an Action that knows how to render the audio
 *                    associated with the system or user activity
 *                    that is occurring; a value of {@code null}, is
 *                    ignored
 * @throws ClassCastException if {@code audioAction} is {@code non-null}
 *         and the value of the default {@code "AuditoryCues.playList"}
 *         is not an {@code Object[]}
 * @since 1.4
 */
protected void playSound(Action audioAction) {
    if (audioAction != null) {
        Object[] audioStrings = (Object[])
                                UIManager.get("AuditoryCues.playList");
        if (audioStrings != null) {
            // create a HashSet to help us decide to play or not
            HashSet<Object> audioCues = new HashSet<Object>();
            for (Object audioString : audioStrings) {
                audioCues.add(audioString);
            }
            // get the name of the Action
            String actionName = (String)audioAction.getValue(Action.NAME);
            // if the actionName is in the audioCues HashSet, play it.
            if (audioCues.contains(actionName)) {
                audioAction.actionPerformed(new
                    ActionEvent(this, ActionEvent.ACTION_PERFORMED,
                                actionName));
            }
        }
    }
}
 
Example 5
Source File: BasicLookAndFeel.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If necessary, invokes {@code actionPerformed} on
 * {@code audioAction} to play a sound.
 * The {@code actionPerformed} method is invoked if the value of
 * the {@code "AuditoryCues.playList"} default is a {@code
 * non-null} {@code Object[]} containing a {@code String} entry
 * equal to the name of the {@code audioAction}.
 *
 * @param audioAction an Action that knows how to render the audio
 *                    associated with the system or user activity
 *                    that is occurring; a value of {@code null}, is
 *                    ignored
 * @throws ClassCastException if {@code audioAction} is {@code non-null}
 *         and the value of the default {@code "AuditoryCues.playList"}
 *         is not an {@code Object[]}
 * @since 1.4
 */
protected void playSound(Action audioAction) {
    if (audioAction != null) {
        Object[] audioStrings = (Object[])
                                UIManager.get("AuditoryCues.playList");
        if (audioStrings != null) {
            // create a HashSet to help us decide to play or not
            HashSet<Object> audioCues = new HashSet<Object>();
            for (Object audioString : audioStrings) {
                audioCues.add(audioString);
            }
            // get the name of the Action
            String actionName = (String)audioAction.getValue(Action.NAME);
            // if the actionName is in the audioCues HashSet, play it.
            if (audioCues.contains(actionName)) {
                audioAction.actionPerformed(new
                    ActionEvent(this, ActionEvent.ACTION_PERFORMED,
                                actionName));
            }
        }
    }
}
 
Example 6
Source File: BasicLookAndFeel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If necessary, invokes {@code actionPerformed} on
 * {@code audioAction} to play a sound.
 * The {@code actionPerformed} method is invoked if the value of
 * the {@code "AuditoryCues.playList"} default is a {@code
 * non-null} {@code Object[]} containing a {@code String} entry
 * equal to the name of the {@code audioAction}.
 *
 * @param audioAction an Action that knows how to render the audio
 *                    associated with the system or user activity
 *                    that is occurring; a value of {@code null}, is
 *                    ignored
 * @throws ClassCastException if {@code audioAction} is {@code non-null}
 *         and the value of the default {@code "AuditoryCues.playList"}
 *         is not an {@code Object[]}
 * @since 1.4
 */
protected void playSound(Action audioAction) {
    if (audioAction != null) {
        Object[] audioStrings = (Object[])
                                UIManager.get("AuditoryCues.playList");
        if (audioStrings != null) {
            // create a HashSet to help us decide to play or not
            HashSet<Object> audioCues = new HashSet<Object>();
            for (Object audioString : audioStrings) {
                audioCues.add(audioString);
            }
            // get the name of the Action
            String actionName = (String)audioAction.getValue(Action.NAME);
            // if the actionName is in the audioCues HashSet, play it.
            if (audioCues.contains(actionName)) {
                audioAction.actionPerformed(new
                    ActionEvent(this, ActionEvent.ACTION_PERFORMED,
                                actionName));
            }
        }
    }
}
 
Example 7
Source File: WindowsInternalFrameTitlePane.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected void installDefaults() {
    super.installDefaults();

    titlePaneHeight = UIManager.getInt("InternalFrame.titlePaneHeight");
    buttonWidth     = UIManager.getInt("InternalFrame.titleButtonWidth")  - 4;
    buttonHeight    = UIManager.getInt("InternalFrame.titleButtonHeight") - 4;

    Object obj      = UIManager.get("InternalFrame.titleButtonToolTipsOn");
    hotTrackingOn = (obj instanceof Boolean) ? (Boolean)obj : true;


    if (XPStyle.getXP() != null) {
        // Fix for XP bug where sometimes these sizes aren't updated properly
        // Assume for now that height is correct and derive width using the
        // ratio from the uxtheme part
        buttonWidth = buttonHeight;
        Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL);
        if (d != null && d.width != 0 && d.height != 0) {
            buttonWidth = (int) ((float) buttonWidth * d.width / d.height);
        }
    } else {
        buttonWidth += 2;
        selectedTitleGradientColor =
                UIManager.getColor("InternalFrame.activeTitleGradient");
        notSelectedTitleGradientColor =
                UIManager.getColor("InternalFrame.inactiveTitleGradient");
        Color activeBorderColor =
                UIManager.getColor("InternalFrame.activeBorderColor");
        setBorder(BorderFactory.createLineBorder(activeBorderColor, 1));
    }
}
 
Example 8
Source File: KeywordsPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form KeywordsPanel. 
 *
 * @param view view with the given filter
 * @param filter filter to be edited. Can be null and in that case
 *               all fields are disabled.
 */
public KeywordsPanel( KeywordsFilter filter ) {
    this.filter = filter;

    initComponents();
    initA11y();
    
    if( "Metal".equals( UIManager.getLookAndFeel().getID() ) ) //NOI18N
        setOpaque( true );
    else
        setOpaque( false );

    // it's not generated by form editor
    JPanel topAlign = new JPanel();
    topAlign.setLayout(new BorderLayout());
    topAlign.add(conditionsPanel, BorderLayout.NORTH);
    conditionsScrollPane.setViewportView(topAlign);
    // compute 80x10 chars space in scroll pane
    FontMetrics fm = getFontMetrics(getFont());
    int width = fm.charWidth('n') * 80;  // NOI18N
    int height = fm.getHeight() * 10;
    conditionsScrollPane.setPreferredSize(new java.awt.Dimension(width, height));

    Color background = (Color)UIManager.get("Table.background"); //NOI18N
    conditionsPanel.setBackground(background);
    topAlign.setBackground(background);

    moreButton.addActionListener(this);
    fewerButton.addActionListener(this);
    matchAllRadio.addActionListener(this);
    matchAnyRadio.addActionListener(this);

    showFilter(filter);
    updateSensitivity();
}
 
Example 9
Source File: ColorModel.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
final int getInteger(Component component, String suffix) {
    Object value = UIManager.get(this.prefix + suffix, component.getLocale());
    if (value instanceof Integer) {
        return (Integer) value;
    }
    if (value instanceof String) {
        try {
            return Integer.parseInt((String) value);
        }
        catch (NumberFormatException exception) {
        }
    }
    return -1;
}
 
Example 10
Source File: StatusLineComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public CancelAction(boolean text) {
    if (text) {
        putValue(Action.NAME, NbBundle.getMessage(StatusLineComponent.class, "StatusLineComponent.Cancel"));
    } else {
        Object icon = UIManager.get("nb.progress.cancel.icon");
        if (icon == null) {
               // for custom L&F?
            putValue(Action.SMALL_ICON, ImageUtilities.loadImageIcon("org/netbeans/progress/module/resources/buton.png", true));
        } else {
            putValue(Action.SMALL_ICON, ListComponent.iconOrImage2icon(icon));
        }
    }
    setEnabled(handle == null ? false : handle.isAllowCancel());
}
 
Example 11
Source File: PropertySheet.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void updateUI() {
    UIManager.get("nb.propertysheet"); //Causes default colors for the property sheet to be bootstrapped into
                                       //UIDefaults - see core/swing/plaf

    super.updateUI();
}
 
Example 12
Source File: ProfileSelectWindow.java    From amidst with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The preferred width should be at least a scrollbar-width wider than the
 * ProfileComponent's preferredSize width of 500 (so 520?). The preferred
 * height should allow the dialog to fit easily on a 720p display, while
 * being nicely divisible by ProfileComponent's height of 40 (so 520 again
 * then?).
 */
@CalledOnlyBy(AmidstThread.EDT)
private String getScrollPaneLayoutString() {
	int scrollBarWidth = (Integer) UIManager.get("ScrollBar.width");
	int preferredWidth = ProfileComponent.PREFERRED_WIDTH + scrollBarWidth;
	int preferredHeight = ProfileComponent.PREFERRED_HEIGHT * HEIGHT_IN_PROFILE_COMPONENTS;
	return "grow, push, w :" + preferredWidth + ":, h 80:" + preferredHeight + ":";
}
 
Example 13
Source File: ForwardFactory.java    From settlers-remake with MIT License 5 votes vote down vote up
/**
 * Load the current factory type from UIManager
 * 
 * @param key
 *            Key of factory
 */
public void loadFromType(String key) {
	Object factoryClassName = UIManager.get(key);
	try {
		factoryClass = Class.forName(String.valueOf(factoryClassName));
		method = factoryClass.getMethod("createUI", JComponent.class);
	} catch (ClassNotFoundException | NoSuchMethodException | SecurityException e) {
		throw new IllegalArgumentException(key, e);
	}
}
 
Example 14
Source File: FilterTopComponent.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private FilterTopComponent() {
    filterSettingsChangedEvent = new ChangedEvent<FilterTopComponent>(this);
    initComponents();
    setName(NbBundle.getMessage(FilterTopComponent.class, "CTL_FilterTopComponent"));
    setToolTipText(NbBundle.getMessage(FilterTopComponent.class, "HINT_FilterTopComponent"));
    //        setIcon(Utilities.loadImage(ICON_PATH, true));

    sequence = new FilterChain();
    filterChain = new FilterChain();
    initFilters();
    manager = new ExplorerManager();
    manager.setRootContext(new AbstractNode(new FilterChildren()));
    associateLookup(ExplorerUtils.createLookup(manager, getActionMap()));
    view = new CheckListView();

    ToolbarPool.getDefault().setPreferredIconSize(16);
    Toolbar toolBar = new Toolbar();
    Border b = (Border) UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
    toolBar.setBorder(b);
    comboBox = new JComboBox();
    toolBar.add(comboBox);
    this.add(toolBar, BorderLayout.NORTH);
    toolBar.add(SaveFilterSettingsAction.get(SaveFilterSettingsAction.class));
    toolBar.add(RemoveFilterSettingsAction.get(RemoveFilterSettingsAction.class));
    toolBar.addSeparator();
    toolBar.add(MoveFilterUpAction.get(MoveFilterUpAction.class).createContextAwareInstance(this.getLookup()));
    toolBar.add(MoveFilterDownAction.get(MoveFilterDownAction.class).createContextAwareInstance(this.getLookup()));
    toolBar.add(RemoveFilterAction.get(RemoveFilterAction.class).createContextAwareInstance(this.getLookup()));
    toolBar.add(NewFilterAction.get(NewFilterAction.class));
    this.add(view, BorderLayout.CENTER);

    filterSettings = new ArrayList<FilterSetting>();
    updateComboBox();

    comboBox.addActionListener(comboBoxActionListener);
    setChain(filterChain);
}
 
Example 15
Source File: FilterTopComponent.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private FilterTopComponent() {
    filterSettingsChangedEvent = new ChangedEvent<>(this);
    initComponents();
    setName(NbBundle.getMessage(FilterTopComponent.class, "CTL_FilterTopComponent"));
    setToolTipText(NbBundle.getMessage(FilterTopComponent.class, "HINT_FilterTopComponent"));
    //        setIcon(Utilities.loadImage(ICON_PATH, true));

    sequence = new FilterChain();
    filterChain = new FilterChain();
    initFilters();
    manager = new ExplorerManager();
    manager.setRootContext(new AbstractNode(new FilterChildren()));
    associateLookup(ExplorerUtils.createLookup(manager, getActionMap()));
    view = new CheckListView();

    ToolbarPool.getDefault().setPreferredIconSize(16);
    Toolbar toolBar = new Toolbar();
    Border b = (Border) UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N
    toolBar.setBorder(b);
    comboBox = new JComboBox();
    toolBar.add(comboBox);
    this.add(toolBar, BorderLayout.NORTH);
    toolBar.add(SaveFilterSettingsAction.get(SaveFilterSettingsAction.class));
    toolBar.add(RemoveFilterSettingsAction.get(RemoveFilterSettingsAction.class));
    toolBar.addSeparator();
    toolBar.add(NewFilterAction.get(NewFilterAction.class));
    toolBar.add(RemoveFilterAction.get(RemoveFilterAction.class).createContextAwareInstance(this.getLookup()));
    toolBar.add(MoveFilterUpAction.get(MoveFilterUpAction.class).createContextAwareInstance(this.getLookup()));
    toolBar.add(MoveFilterDownAction.get(MoveFilterDownAction.class).createContextAwareInstance(this.getLookup()));
    this.add(view, BorderLayout.CENTER);

    filterSettings = new ArrayList<>();
    updateComboBox();

    comboBox.addActionListener(comboBoxActionListener);
    setChain(filterChain);
}
 
Example 16
Source File: NimbusLookAndFeel.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Object createValue(UIDefaults table) {
    return UIManager.get(dstPropName);
}
 
Example 17
Source File: NimbusLookAndFeel.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Object createValue(UIDefaults table) {
    return UIManager.get(dstPropName);
}
 
Example 18
Source File: BasicLizziePaneUI.java    From lizzie with GNU General Public License v3.0 4 votes vote down vote up
InputMap getInputMap(int condition) {
  if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
    return (InputMap) UIManager.get("LizziePane.ancestorInputMap", lizziePane.getLocale());
  }
  return null;
}
 
Example 19
Source File: BasicLookAndFeel.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Creates and returns an {@code Action} used to play a sound.
 * <p>
 * If {@code key} is {@code non-null}, an {@code Action} is created
 * using the value from the defaults with key {@code key}. The value
 * identifies the sound resource to load when
 * {@code actionPerformed} is invoked on the {@code Action}. The
 * sound resource is loaded into a {@code byte[]} by way of
 * {@code getClass().getResourceAsStream()}.
 *
 * @param key the key identifying the audio action
 * @return      an {@code Action} used to play the source, or {@code null}
 *              if {@code key} is {@code null}
 * @see #playSound(Action)
 * @since 1.4
 */
protected Action createAudioAction(Object key) {
    if (key != null) {
        String audioKey = (String)key;
        String audioValue = (String)UIManager.get(key);
        return new AudioAction(audioKey, audioValue);
    } else {
        return null;
    }
}
 
Example 20
Source File: BasicLookAndFeel.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * Creates and returns an {@code Action} used to play a sound.
 * <p>
 * If {@code key} is {@code non-null}, an {@code Action} is created
 * using the value from the defaults with key {@code key}. The value
 * identifies the sound resource to load when
 * {@code actionPerformed} is invoked on the {@code Action}. The
 * sound resource is loaded into a {@code byte[]} by way of
 * {@code getClass().getResourceAsStream()}.
 *
 * @param key the key identifying the audio action
 * @return      an {@code Action} used to play the source, or {@code null}
 *              if {@code key} is {@code null}
 * @see #playSound(Action)
 * @since 1.4
 */
protected Action createAudioAction(Object key) {
    if (key != null) {
        String audioKey = (String)key;
        String audioValue = (String)UIManager.get(key);
        return new AudioAction(audioKey, audioValue);
    } else {
        return null;
    }
}