Hello Bytes.com members.....
I write a swing program that automatically re-size the separator. But I didn't understand the significance of jseparator.reva lidate() line in the code.
here is the code..........
can you please explain the statement??
thanks....
I write a swing program that automatically re-size the separator. But I didn't understand the significance of jseparator.reva lidate() line in the code.
here is the code..........
Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/* <applet
code=resize_separator.class
width=600
height=600
>
</applet> */
public class resize_separator extends JApplet implements ComponentListener
{
JSeparator js=new JSeparator(JSeparator.VERTICAL);
Dimension d=js.getPreferredSize();
public void init()
{
Container c=getContentPane();
c.setLayout(new FlowLayout());
c.add(new JTextField("Hello from swing!",30));
c.add(js);
c.add(new JTextField("Hello from swing!",30));
addComponentListener(this);
}
public void componentShown(ComponentEvent e)
{
js.setPreferredSize(new Dimension(d.width,getSize().height));
js.revalidate(); // please explain the line
}
public void componentResized(ComponentEvent e)
{
js.setPreferredSize(new Dimension(d.width,getSize().height));
js.revalidate();
}
public void componentMoved(ComponentEvent e){}
public void componentHidden(ComponentEvent e){}
}
thanks....