javax.swing.plaf.SliderUI Java Examples

The following examples show how to use javax.swing.plaf.SliderUI. 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: BasicAudioPlayerUI.java    From pumpernickel with MIT License 6 votes vote down vote up
@Override
protected void notifyPlaybackProgress(AudioPlayerComponent apc,
		float timeElapsed, float timeAsFraction) {
	Fields fields = getFields(apc);
	int span = fields.playbackProgress.getMaximum()
			- fields.playbackProgress.getMinimum();
	int v = (int) (span * timeAsFraction + fields.playbackProgress
			.getMinimum());
	SliderUI ui = fields.playbackProgress.getUI();
	boolean isDragging = ui instanceof WaveformSliderUI ? ((WaveformSliderUI) ui)
			.isDragging() : false;
	if (!isDragging) {
		fields.playbackProgress.removeChangeListener(fields.sliderListener);
		fields.playbackProgress.setValue(v);
		fields.playbackProgress.addChangeListener(fields.sliderListener);
	}
	setIcon(fields.playButton, PAUSE_ICON);
}
 
Example #2
Source File: AngleSliderUIDemo.java    From pumpernickel with MIT License 6 votes vote down vote up
private void refreshAngleSlider() {
	SliderUI ui = new AngleSliderUI();
	angleSlider.setUI(ui);
	angleSlider.setEnabled(stateEnabled.isSelected());

	Dimension d = ui.getPreferredSize(angleSlider);
	int z = Math.max(d.width, d.height);

	int relativeValue = sizeSlider.getValue() - sizeSlider.getMinimum();
	int newValue = z + relativeValue;
	sizeSlider.getModel().setRangeProperties(newValue,
			sizeSlider.getModel().getExtent(), z, z + 100,
			sizeSlider.getModel().getValueIsAdjusting());

	angleSlider.setPreferredSize(new Dimension(newValue, newValue));
}
 
Example #3
Source File: bug6848475.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #4
Source File: bug6848475.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #5
Source File: bug6848475.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #6
Source File: bug6848475.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #7
Source File: bug6848475.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #8
Source File: bug6848475.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #9
Source File: bug6848475.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #10
Source File: JSliderOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JSlider.setUI(SliderUI)} through queue
 */
public void setUI(final SliderUI sliderUI) {
    runMapping(new MapVoidAction("setUI") {
        @Override
        public void map() {
            ((JSlider) getSource()).setUI(sliderUI);
        }
    });
}
 
Example #11
Source File: JSliderOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JSlider.getUI()} through queue
 */
public SliderUI getUI() {
    return (runMapping(new MapAction<SliderUI>("getUI") {
        @Override
        public SliderUI map() {
            return ((JSlider) getSource()).getUI();
        }
    }));
}
 
Example #12
Source File: bug6848475.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #13
Source File: bug6848475.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #14
Source File: bug6848475.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #15
Source File: bug6848475.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #16
Source File: bug6848475.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #17
Source File: bug6848475.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #18
Source File: ThemeSettingsPanel.java    From darklaf with MIT License 4 votes vote down vote up
private JSlider createFontSlider() {
    JSlider fontSlider = new JSlider() {
        @Override
        public String getToolTipText(final MouseEvent event) {
            return getValue() + "%";
        }
    };
    ToolTipContext context = new ToolTipContext().setAlignment(Alignment.CENTER)
                                                 .setCenterAlignment(Alignment.NORTH)
                                                 .setUseBestFit(true)
                                                 .setToolTipRectSupplier(e -> {
                                                     SliderUI ui = fontSlider.getUI();
                                                     if (ui instanceof DarkSliderUI) {
                                                         Rectangle r = ((DarkSliderUI) ui).getThumbRect();
                                                         r.x -= 1;
                                                         return r;
                                                     }
                                                     return new Rectangle(0, 0, fontSlider.getWidth(),
                                                                          fontSlider.getHeight());
                                                 });
    fontSlider.putClientProperty(DarkSliderUI.KEY_INSTANT_SCROLL, true);
    fontSlider.putClientProperty(ToolTipConstants.KEY_CONTEXT, context);
    fontSlider.putClientProperty(ToolTipConstants.KEY_STYLE, ToolTipConstants.VARIANT_BALLOON);
    fontSlider.setToolTipText(String.valueOf(fontSlider.getValue()));
    fontSlider.setOrientation(JSlider.HORIZONTAL);
    fontSlider.setPaintTicks(true);
    fontSlider.setMinimum(FontSizePreset.TINY.getPercentage());
    fontSlider.setMaximum(FontSizePreset.HUGE.getPercentage());
    int tickSpacing = 25;
    Dictionary<Integer, JComponent> dict = fontSlider.createStandardLabels(tickSpacing);
    JLabel min = ((JLabel) dict.get(fontSlider.getMinimum()));
    UIUpdater.registerComponent(min);
    min.setText(resourceBundle.getString("label_font_smaller"));
    min.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    min.putClientProperty(DarkSliderUI.KEY_MANUAL_LABEL_ALIGN, true);

    JLabel mid = ((JLabel) dict.get(fontSlider.getMinimum() + tickSpacing));
    UIUpdater.registerComponent(mid);
    dict.remove(fontSlider.getMinimum() + tickSpacing);
    dict.put(FontSizePreset.NORMAL.getPercentage(), mid);
    mid.setText(resourceBundle.getString("label_font_default"));
    mid.setAlignmentX(JComponent.CENTER_ALIGNMENT);
    mid.setHorizontalTextPosition(JLabel.RIGHT);

    JLabel max = ((JLabel) dict.get(fontSlider.getMaximum()));
    max.putClientProperty(DarkSliderUI.KEY_MANUAL_LABEL_ALIGN, true);
    max.setText(resourceBundle.getString("label_font_bigger"));
    max.setAlignmentX(JComponent.RIGHT_ALIGNMENT);
    max.putClientProperty(DarkSliderUI.KEY_MANUAL_LABEL_ALIGN, true);
    UIUpdater.registerComponent(max);

    dict.remove(FontSizePreset.Small.getPercentage());
    dict.remove(FontSizePreset.SMALL.getPercentage());
    dict.remove(FontSizePreset.Large.getPercentage());
    dict.remove(FontSizePreset.LARGE.getPercentage());
    dict.remove(FontSizePreset.Huge.getPercentage());

    fontSlider.setLabelTable(dict);
    fontSlider.setMajorTickSpacing(tickSpacing);
    fontSlider.setMinorTickSpacing(tickSpacing);
    fontSlider.setPaintLabels(true);
    fontSlider.setSnapToTicks(true);
    return fontSlider;
}