Java Code Examples for javax.swing.JSlider#setForeground()
The following examples show how to use
javax.swing.JSlider#setForeground() .
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: MaterialSliderUI.java From material-ui-swing with MIT License | 5 votes |
@Override public void installUI (JComponent c) { super.installUI (c); JSlider slider = (JSlider) c; slider.setFont (UIManager.getFont ("Slider.font")); slider.setBackground (UIManager.getColor ("Slider.background")); slider.setForeground (UIManager.getColor ("Slider.foreground")); slider.setBorder (UIManager.getBorder ("Slider.border")); c.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); }
Example 2
Source File: WaveformSliderUI.java From pumpernickel with MIT License | 5 votes |
@Override protected void installListeners(JSlider slider) { super.installListeners(slider); slider.removeMouseListener(trackListener); slider.removeMouseMotionListener(trackListener); slider.addMouseListener(mouseListener); slider.addMouseMotionListener(mouseListener); slider.setForeground(Color.darkGray); }
Example 3
Source File: SpaceSliderPanel.java From Open-Realms-of-Stars with GNU General Public License v2.0 | 4 votes |
/** * Create space slider panel with - and + buttons and label * @param actionMinus ActionCommand for minus button * @param actionPlus ActionCommand for plus button * @param iconName Icon name to show * @param text Text for label * @param minValue Minimum value in slider * @param maxValue Maximum value in slider * @param sliderValue slider value * @param actionSlider slider action command * @param listener Action Listener */ public SpaceSliderPanel(final String actionMinus, final String actionPlus, final String iconName, final String text, final int minValue, final int maxValue, final int sliderValue, final String actionSlider, final ActionListener listener) { super(); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); btnMinus = new IconButton(Icons.getIconByName(Icons.ICON_MINUS), Icons.getIconByName(Icons.ICON_MINUS_PRESSED), false, actionMinus, this); btnMinus.addActionListener(listener); this.add(Box.createRigidArea(new Dimension(5, 5))); this.add(btnMinus); SpaceGreyPanel panel = new SpaceGreyPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); label = new IconLabel(null, Icons.getIconByName(iconName), text); panel.add(label); slider = new JSlider(minValue, maxValue, sliderValue); slider.setMinorTickSpacing(1); slider.setMajorTickSpacing(10); slider.setPaintTicks(true); slider.setSnapToTicks(true); slider.setBackground(GuiStatics.COLOR_GREYBLUE); slider.setForeground(GuiStatics.COLOR_COOL_SPACE_BLUE); slider.addKeyListener(null); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(final ChangeEvent e) { if (e.getSource() instanceof JSlider) { JSlider slide = (JSlider) e.getSource(); if (slide.getValue() % slide.getMinorTickSpacing() == 0) { listener.actionPerformed(new ActionEvent(e, 0, actionSlider)); } } } }); panel.add(slider); this.add(panel); btnPlus = new IconButton(Icons.getIconByName(Icons.ICON_PLUS), Icons.getIconByName(Icons.ICON_PLUS_PRESSED), false, actionPlus, this); btnPlus.addActionListener(listener); this.add(btnPlus); this.add(Box.createRigidArea(new Dimension(5, 5))); }
Example 4
Source File: ResearchTechPanel.java From Open-Realms-of-Stars with GNU General Public License v2.0 | 4 votes |
/** * Create Research Tech panel with - and + buttons and up arrow to * upgrade tech level. * @param actionMinus ActionCommand for minus button * @param actionPlus ActionCommand for plus button * @param iconName Icon name to show * @param text Text for tech focus label * @param text2 Text for tech level label * @param actionUpgrade ActionCommand for upgrade button * @param sliderValue slider value * @param actionSlider slider action command * @param listener Action Listener */ public ResearchTechPanel(final String actionMinus, final String actionPlus, final String iconName, final String text, final String text2, final String actionUpgrade, final int sliderValue, final String actionSlider, final ActionListener listener) { super(); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); btnMinus = new IconButton(Icons.getIconByName(Icons.ICON_MINUS), Icons.getIconByName(Icons.ICON_MINUS_PRESSED), false, actionMinus, this); btnMinus.addActionListener(listener); this.add(Box.createRigidArea(new Dimension(5, 5))); this.add(btnMinus); SpaceGreyPanel panel = new SpaceGreyPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); label = new IconLabel(null, Icons.getIconByName(iconName), text); panel.add(label); slider = new JSlider(0, 100, sliderValue); slider.setMinorTickSpacing(4); slider.setMajorTickSpacing(20); slider.setPaintTicks(true); slider.setSnapToTicks(true); slider.setBackground(GuiStatics.COLOR_GREYBLUE); slider.setForeground(GuiStatics.COLOR_COOL_SPACE_BLUE); slider.addKeyListener(null); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(final ChangeEvent e) { if (e.getSource() instanceof JSlider) { JSlider slide = (JSlider) e.getSource(); if (slide.getValue() % 4 == 0) { listener.actionPerformed(new ActionEvent(e, 0, actionSlider)); } } } }); panel.add(slider); lvlLabel = new IconLabel(null, Icons.getIconByName(Icons.ICON_EMPTY), text2); panel.add(lvlLabel); this.add(panel); btnUpgrade = new IconButton(Icons.getIconByName(Icons.ICON_ARROWUP), Icons.getIconByName(Icons.ICON_ARROWUP_PRESSED), false, actionUpgrade, this); btnUpgrade.setDisabledImage( Icons.getIconByName(Icons.ICON_ARROWUP_DISABLED).getIcon()); btnUpgrade.addActionListener(listener); btnUpgrade.setEnabled(false); this.add(btnUpgrade); btnPlus = new IconButton(Icons.getIconByName(Icons.ICON_PLUS), Icons.getIconByName(Icons.ICON_PLUS_PRESSED), false, actionPlus, this); btnPlus.addActionListener(listener); this.add(btnPlus); this.add(Box.createRigidArea(new Dimension(5, 5))); }