Re: how to set (preferred) JSlider length?



On Aug 7, 6:23 pm, Knute Johnson <nos...@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Mark_Galeck wrote:
Nope, same thing as always, slider length is 1024 (covers the whole
applet).

Change the layout manager to something that honors preferred size.

My preference is GridBagLayout.


same problem, does not honor, heres the code foo.java , width is 200
not 400

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

public class foo extends JApplet {
public void init() {
GridBagConstraints gridBagConstraints;

setLayout(new GridBagLayout());

gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.weightx = 1.0;
add(new JPanel(), gridBagConstraints);

gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
JSlider s = new JSlider(0, 400);
add(s, gridBagConstraints);
validate();
Dimension d = s.getSize();
d.width = 400;
s.setSize(d);
validate();
}
}
.



Relevant Pages

  • Re: resize an applet
    ... I have not found solution with JAVASCRIPT ... I've created the attached example applet, which allows you to change the applets dimension using two slider controls. ... private JSObject documentDOMObject; ... GridBagConstraints gridBagConstraints4 = ...
    (comp.lang.java.programmer)
  • Re: GridBagLayout - A simple test program
    ... work I thought I would write a little test program to use as a training device. ... The other feature that might be good to add is the ability to set the preferred size of the components as that does have an effect on layout. ... GridBagConstraints labelConstraints = new GridBagConstraints; ... I find the above to be a useful idiom but I don't think your Applet would help anyone learn it. ...
    (comp.lang.java.help)