本文整理汇总了Java中javax.swing.plaf.basic.BasicSliderUI类的典型用法代码示例。如果您正苦于以下问题:Java BasicSliderUI类的具体用法?Java BasicSliderUI怎么用?Java BasicSliderUI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicSliderUI类属于javax.swing.plaf.basic包,在下文中一共展示了BasicSliderUI类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bug6401380
import javax.swing.plaf.basic.BasicSliderUI; //导入依赖的package包/类
public bug6401380() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
slider = new JSlider();
slider.setMajorTickSpacing(0);
slider.setMaximum(50);
slider.setMinorTickSpacing(10);
slider.setPaintLabels(true);
slider.setPaintTicks(true);
slider.setSnapToTicks(true);
// MetalSliderUI overrides scrollDueToClickInTrack() method
// so this test doens't work for Metal
slider.setUI(new BasicSliderUI(slider));
add(slider);
setSize(200, 200);
}
示例2: TrackableSlider
import javax.swing.plaf.basic.BasicSliderUI; //导入依赖的package包/类
/**
* Simple constructor.
*
* @param slider
* The associated slider.
*/
public TrackableSlider(JSlider slider, ButtonModel transitionModel) {
this.slider = slider;
this.transitionModel = transitionModel;
SliderUI sliderUI = slider.getUI();
if (sliderUI instanceof BasicSliderUI) {
try {
this.thumbRectField = BasicSliderUI.class
.getDeclaredField("thumbRect");
this.thumbRectField.setAccessible(true);
} catch (Exception exc) {
this.thumbRectField = null;
}
}
this.stateTransitionTracker = new StateTransitionTracker(
this.slider, this.transitionModel);
}
示例3: fixWinSliderUI
import javax.swing.plaf.basic.BasicSliderUI; //导入依赖的package包/类
public static void fixWinSliderUI(JSlider s) {
if(System.getProperty("os.name").toLowerCase().contains("win")) {
s.setUI(new BasicSliderUI(s){
protected Dimension getThumbSize() {
Dimension old = super.getThumbSize();
return new Dimension(old.width*2, old.height);
}
});
}
}
示例4: getAnimationPanel
import javax.swing.plaf.basic.BasicSliderUI; //导入依赖的package包/类
/**
* Returns the frames-per-second slider for the animation dialog.
*/
final JPanel getAnimationPanel() {
// lazily create the label
if (this.animationPanel == null) {
JLabel label = new JLabel("Animation Speed");
label.setAlignmentX(Component.CENTER_ALIGNMENT);
final JSlider slider = new JSlider(SwingConstants.HORIZONTAL, 1, 10, 2) {
@Override
public void updateUI() {
setUI(BasicSliderUI.createUI(this));
}
};
slider.setMajorTickSpacing(9);
slider.setMinorTickSpacing(1);
slider.setSnapToTicks(true);
slider.setPaintTicks(true);
slider.setPaintLabels(true);
slider.setFocusable(false);
slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int speed = slider.getValue();
setSpeed(speed);
}
});
slider.setAlignmentX(Component.CENTER_ALIGNMENT);
this.animationPanel = new JPanel();
this.animationPanel.setLayout(new BoxLayout(this.animationPanel, BoxLayout.Y_AXIS));
this.animationPanel.add(label);
this.animationPanel.add(slider);
}
return this.animationPanel;
}
示例5: getThumbRectField
import javax.swing.plaf.basic.BasicSliderUI; //导入依赖的package包/类
private static Rectangle getThumbRectField() {
try {
SliderUI ui = slider.getUI();
Field field = BasicSliderUI.class.getDeclaredField("thumbRect");
field.setAccessible(true);
return (Rectangle) field.get(ui);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例6: MThumbSliderAdditionalUI
import javax.swing.plaf.basic.BasicSliderUI; //导入依赖的package包/类
public MThumbSliderAdditionalUI(BasicSliderUI ui) {
this.ui = ui;
}
示例7: createTrackListener
import javax.swing.plaf.basic.BasicSliderUI; //导入依赖的package包/类
protected BasicSliderUI.TrackListener createTrackListener(final JSlider s) {
return new TrackListener();
}
示例8: run
import javax.swing.plaf.basic.BasicSliderUI; //导入依赖的package包/类
private void run() throws InterruptedException, InvocationTargetException {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
try {
UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
} catch (Exception e) {
fail(e.getMessage());
}
BufferedImage image = new BufferedImage(300, 200, BufferedImage.TYPE_INT_ARGB);
// Test 1
JSlider slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
slider.setMajorTickSpacing((Integer.MAX_VALUE - 1) / 4);
slider.setPaintTicks(true);
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
// Test 2
slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
slider.setMinorTickSpacing((Integer.MAX_VALUE - 1) / 4);
slider.setPaintTicks(true);
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
// Test 3
slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
slider.setOrientation(JSlider.VERTICAL);
slider.setMajorTickSpacing((Integer.MAX_VALUE - 1) / 4);
slider.setPaintTicks(true);
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
// Test 4
slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
slider.setOrientation(JSlider.VERTICAL);
slider.setMinorTickSpacing((Integer.MAX_VALUE - 1) / 4);
slider.setPaintTicks(true);
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
countDownLatch.countDown();
}
}
});
if (countDownLatch.await(3000, TimeUnit.MILLISECONDS)) {
System.out.println("bug6794831 passed");
} else {
fail("bug6794831 failed");
}
}
示例9: run
import javax.swing.plaf.basic.BasicSliderUI; //导入依赖的package包/类
private void run() throws InterruptedException {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
try {
UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
} catch (Exception e) {
fail(e.getMessage());
}
BufferedImage image = new BufferedImage(300, 200, BufferedImage.TYPE_INT_ARGB);
// Test 1
JSlider slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
slider.setMajorTickSpacing((Integer.MAX_VALUE - 1) / 4);
slider.setPaintTicks(true);
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
// Test 2
slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
slider.setMinorTickSpacing((Integer.MAX_VALUE - 1) / 4);
slider.setPaintTicks(true);
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
// Test 3
slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
slider.setOrientation(JSlider.VERTICAL);
slider.setMajorTickSpacing((Integer.MAX_VALUE - 1) / 4);
slider.setPaintTicks(true);
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
// Test 4
slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
slider.setOrientation(JSlider.VERTICAL);
slider.setMinorTickSpacing((Integer.MAX_VALUE - 1) / 4);
slider.setPaintTicks(true);
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
countDownLatch.countDown();
}
}
});
if (countDownLatch.await(3000, TimeUnit.MILLISECONDS)) {
System.out.println("bug6794831 passed");
} else {
fail("bug6794831 failed");
}
}