javax.swing.JSlider#setBorder ( )源码实例Demo

下面列出了javax.swing.JSlider#setBorder ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: material-ui-swing   文件: MaterialSliderUI.java
@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));
}
 
源代码2 项目: pumpernickel   文件: AnimationController.java
/**
 * 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);
}