Hi I have created a slider in java in linux platform. But the slider gave different look and feel in different operating systems. Means in linux it looks little bit good but in mac operating system the slider looks different. so how to give same look and feel to my slider irrespective of operating system
The code is given below.
import javax.swing.JFrame; import javax.swing.JSlider; import javax.swing.Timer;
public class Test {
static int percent = 0;
public static void main(String[] args) {
JFrame f = new JFrame();
final JSlider s = new JSlider();
f.getContentPane().add(s);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.pack();
f.setVisible(true);
Timer time = new Timer(100, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
percent++;
if (percent>100)
percent = 0;
// s.setMajorTickSpacing(10); //s.setMinorTickSpacing(1); //s.setPaintTicks(true); //s.setPaintLabels(true);
// JScrollBar sb = s.getHorizontalScrollBar(); s.setValue((int)(s.getMaximum()*(percent/100.0))); s.setAutoscrolls(true); } }); time.start(); }
}
Thanks Sunil kumar Sahoo