Java Code Examples for javax.swing.JSlider#setBackground()
The following examples show how to use
javax.swing.JSlider#setBackground() .
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: ContrastAdjustmentMode.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
private JSlider createSlider(JPanel panel, GridBagLayout gb, GridBagConstraints c, String title, Font font, int sliderRange, int start) { Utils.log2("createSlider range: " + sliderRange + ", start: " + start); JSlider s = new JSlider(JSlider.HORIZONTAL, 0, sliderRange, start); s.setPaintLabels(false); s.setPaintTicks(false); s.setBackground(Color.white); c.gridy++; c.insets = new Insets(2, 10, 0, 10); gb.setConstraints(s, c); panel.add(s); JLabel l = new JLabel(title); l.setBackground(Color.white); l.setFont(font); c.gridy++; c.insets = new Insets(0, 10, IJ.isMacOSX() ? 4 : 0, 0); JPanel p = new JPanel(); p.setBackground(Color.white); p.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); gb.setConstraints(p, c); p.add(l); panel.add(p); return s; }
Example 2
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 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))); }
Example 5
Source File: AmountPanel.java From testing-cin with MIT License | 4 votes |
/** * Constructor. */ public AmountPanel() { setBackground(UIConstants.TABLE_COLOR); sliderAmounts = new HashMap<Integer, Integer>(); setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); amountSlider = new JSlider(); amountSlider.setBackground(UIConstants.TABLE_COLOR); amountSlider.setMajorTickSpacing(1); amountSlider.setMinorTickSpacing(1); amountSlider.setPaintTicks(true); amountSlider.setSnapToTicks(true); amountSlider.addChangeListener(this); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 2; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(0, 0, 0, 5); add(amountSlider, gbc); amountLabel = new JLabel(" "); amountLabel.setForeground(UIConstants.TEXT_COLOR); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 2; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(5, 0, 5, 0); add(amountLabel, gbc); betRaiseButton = new JButton("Bet"); betRaiseButton.addActionListener(this); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(0, 0, 0, 0); add(betRaiseButton, gbc); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); gbc.gridx = 1; gbc.gridy = 2; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets(0, 0, 0, 0); add(cancelButton, gbc); }