public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("Slider Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 50);
slider.setUI(new BasicSliderUI() {
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
}
@Override
public void paintTrack(Graphics g) {
if(slider.getOrientation() == JSlider.HORIZONTAL) {
int y = (trackRect.height / 2) - 2;
int w = trackRect.width;
g.translate(trackRect.x, trackRect.y + y);
g.setColor(Color.white);
g.drawLine(0, -3, 0, 3);
g.drawLine(w -1, -3, w -1, 3);
g.drawLine(0, 0, w -2, 0); // Main Line
g.translate(-trackRect.x, -(trackRect.y + y));
}
}
@Override
public void paintThumb(Graphics g1) {
Rectangle knobBounds = thumbRect;
int x = knobBounds.x;
int y = knobBounds.y;
int w = knobBounds.width;
int h = knobBounds.height;
Graphics2D g = (Graphics2D) g1;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.white);
g.translate(x, y);
g.fillOval(0, 3, w, w);
}
@Override
protected void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) {
g.setColor(Color.white);
g.drawLine(x, -5, x, tickBounds.height / 2 - 5);
}
@Override
protected void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) {
g.setColor(Color.white);
g.drawLine(x, -5, x, tickBounds.height / 2 - 10);
}
});
slider.setMajorTickSpacing(10);
slider.setMinorTickSpacing(5);
slider.setPaintTicks(true);
slider.setPaintLabels(true);
frame.getContentPane().add(slider);
slider.setBackground(Color.black);
frame.getContentPane().setBackground(Color.black);
frame.setSize(400, 150);
frame.setVisible(true);
});
}
}
我在《刑法》中曾遇到过一种奇怪的行为,当时我为我的国家情报和安全局专门安排了一次联合调查。 令人费解的是,当我rag笑 s时,标准是刻意抹去的。 然而,一旦我释放了umb,他们就会mag然地重新耳光。 难道有人会帮助我,这里会发生什么情况? 我曾寻求解决办法,但我无法找到解决办法。