I have a question about getting a JSlider to point the left instead of right.. BUT, I need it to do so only for one JSlider. This question is very similar but the answer to it only helped if you wanted all JSliders to point the wrong way. Here is a photoshopped image of what i want.
Asked
Active
Viewed 221 times
1 Answers
1
I found out how to do it. All i needed to do was make a new class.
package Main;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import javax.swing.JSlider;
public class ReversedJSlider extends JSlider{
private static final long serialVersionUID = 1L;
public ReversedJSlider() {
super();
}
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
AffineTransform tx = new AffineTransform();
tx.translate(50, 0);
tx.scale(-1, 1);
tx.translate(-50, 0);
g2d.setTransform(tx);
super.paintComponent(g2d);
}
}

707090
- 102
- 6
-
Not sure I'd agree with this, it will work in your case, but the problem is if you now apply labels to the slider, they will be mirrored...just saying ;) – MadProgrammer Feb 26 '14 at 23:08