Re: how to set (preferred) JSlider length?



On 8 Sie, 01:26, Mark_Galeck <mark_galeck_spam_mag...@xxxxxxxxx>
wrote:
Here is the file foo.java:

import javax.swing.*;
import java.awt.*;

public class foo extends JApplet {
        public void init() {
                setLayout(new BorderLayout());
                add("Center", new JPanel());
                JSlider s = new JSlider(0, 400);
                add("East", s);
                validate();
                Dimension d = s.getSize();
                d.width = 400;
                s.setSize(d);
                validate();
        }
        }

Here is the file foo.html:

<OBJECT
                codetype="application/java"
         code=foo.class
                width=1024 height=1024



<PARAM NAME="cache_option" VALUE="No">

</OBJECT>

OK, then why is the slider 200 pixels wide, not 400???? Please
explain, thank you!  Mark

Try this:

public void init() {
JSlider s = new JSlider(0, 400);
add(s);
s.setPreferredSize(new Dimension(400, 20));
}


Przemek
.