Java Code Examples for javax.swing.JSlider#setOpaque()

The following examples show how to use javax.swing.JSlider#setOpaque() . 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: PreviewStatusPanel.java    From GIFKR with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void initializeComponents() {
	qualitySlider = new JSlider(10, 100, 50) {
		private static final long serialVersionUID = -3633632766184431178L;

		@Override
		public Dimension getPreferredSize() {
			return new Dimension(super.getPreferredSize().width/2, new JLabel(" ").getPreferredSize().height);
		}
	};
	qualitySlider.addChangeListener(ce -> r.refresh());
	
	qualitySlider.setOpaque(false);
	statusLabel = new JLabel();
	skipFrames = new JCheckBox("Skip frames", false);
	skipFrames.setOpaque(false);
}
 
Example 2
Source File: ChartPanel.java    From javamelody with Apache License 2.0 6 votes vote down vote up
private JSlider createSlider() {
	final JSlider slider = new JSlider();
	slider.setOpaque(false);
	slider.setMinimum(10);
	slider.setMaximum(200);
	slider.setValue(100);
	slider.setLabelTable(slider.createStandardLabels(50));
	slider.setMajorTickSpacing(100);
	slider.setMinorTickSpacing(10);
	slider.setExtent(20);
	// slider.setPaintLabels(true);
	// slider.setPaintTicks(true);
	// slider.setSnapToTicks(true);
	slider.addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			final int value = slider.getValue();
			refreshZoom(value);
		}
	});
	return slider;
}
 
Example 3
Source File: LargeNavigationPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
protected JSlider createSlider() {
	JSlider slider = new JSlider(0, 1000);
	slider.setOpaque(false);
	slider.setName(SLIDER_NAME);
	installSliderListener(slider);
	return slider;
}
 
Example 4
Source File: ColorPickerSliderUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected void installListeners(JSlider slider) {
	super.installListeners(slider);
	slider.removeMouseListener(trackListener);
	slider.removeMouseMotionListener(trackListener);
	slider.addMouseListener(myMouseListener);
	slider.addMouseMotionListener(myMouseListener);
	slider.setOpaque(false);
}
 
Example 5
Source File: ColorPickerSliderUI.java    From PyramidShader with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void installListeners(JSlider slider) {
	super.installListeners(slider);
	slider.removeMouseListener(trackListener);
	slider.removeMouseMotionListener(trackListener);
	slider.addMouseListener(myMouseListener);
	slider.addMouseMotionListener(myMouseListener);
	slider.setOpaque(false);
}
 
Example 6
Source File: AnimationController.java    From pumpernickel with MIT License 4 votes vote down vote up
/**
 * Format animation controls and add them to a container. This includes
 * assigning the borders of all the components, assigning the PanelUI of the
 * container, assigning the preferred size of the container, and making a
 * spacebar on the slider trigger the toggle play button.
 * 
 * @param container
 *            this container is emptied, assigned a GridBagLayout, and the
 *            other arguments are added to this container.
 * @param togglePlayButton
 *            this button will be the left-most button. It is expected to
 *            always be visible.
 * @param buttons
 *            an optional collection of buttons to display after the
 *            togglePlayButton.
 * @param slider
 *            the slider that stretches to fill the remaining width.
 */
public static void format(JPanel container, final JButton togglePlayButton,
		JButton[] buttons, JSlider slider) {
	if (buttons == null)
		buttons = new JButton[] {};
	container.setUI(new GradientPanelUI(new Color(0xebebeb), Color.white));
	container.removeAll();
	container.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 0;
	c.weighty = 1;
	c.fill = GridBagConstraints.VERTICAL;
	container.add(togglePlayButton, c);
	for (int a = 0; a < buttons.length; a++) {
		c.gridx++;
		container.add(buttons[a], c);
		buttons[a].setOpaque(false);
		buttons[a].setContentAreaFilled(false);
		buttons[a].setRolloverIcon(new DarkenedIcon(buttons[a], .5f));
		buttons[a].setPressedIcon(new DarkenedIcon(buttons[a], .75f));
		buttons[a].setBorder(new PartialLineBorder(Color.gray, new Insets(
				1, 0, 1, 1)));
	}
	c.weightx = 1;
	c.gridx++;
	c.fill = GridBagConstraints.BOTH;
	container.add(slider, c);

	togglePlayButton.setOpaque(false);
	togglePlayButton.setContentAreaFilled(false);
	togglePlayButton.setBorder(new LineBorder(Color.gray));
	slider.setOpaque(false);
	slider.setBorder(new PartialLineBorder(Color.gray, new Insets(1, 0, 1,
			1)));
	Dimension d = slider.getPreferredSize();
	d.width = 60;
	d.height = 25;
	slider.setPreferredSize((Dimension) d.clone());
	d.width = d.height;
	togglePlayButton.setPreferredSize(d);
	for (int a = 0; a < buttons.length; a++) {
		buttons[a].setPreferredSize(d);
	}

	InputMap inputMap = slider.getInputMap(JComponent.WHEN_FOCUSED);
	inputMap.put(KeyStroke.getKeyStroke(' '), "togglePlay");
	slider.getActionMap().put("togglePlay", new AbstractAction() {
		private static final long serialVersionUID = 1L;

		public void actionPerformed(ActionEvent e) {
			togglePlayButton.doClick();
		}
	});

	togglePlayButton.setFocusPainted(false);
	setInsetFocusBorder(togglePlayButton);
	for (JButton button : buttons) {
		button.setFocusPainted(false);
		setInsetFocusBorder(button);
	}
	setInsetFocusBorder(slider);
}