> Hi!
>
[quoted text clipped - 51 lines]
>
> }
Use a JList instead of a Box will solve.
If you want to use a Box then call jfrm.pack() at the end of
actionPerformed() method.

Signature
Andrea Francia
http://www.andreafrancia.it/
> Hi!
>
[quoted text clipped - 51 lines]
>
> }
When you add or remove components from an already visible Frame you must
call validate() on the Frame to cause the LayoutManager to re-layout the
components. Then they will be visible.
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class Test implements ActionListener {
JFrame jfrm;
Box box;
int lines;
Random generator = new Random();
Test() {
jfrm = new JFrame("Random Lines Test");
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
box = Box.createVerticalBox();
int random = generator.nextInt(9)+1;
for (int i = 1; i <= random; i++) {
box.add(new JLabel("Line number " + i));
}
lines = random;
JButton jbRandom = new JButton("Add a random (1-9) number of
lines");
jbRandom.addActionListener(this);
jfrm.add(box);
jfrm.add(jbRandom, BorderLayout.SOUTH);
jfrm.pack();
jfrm.setExtendedState(Frame.MAXIMIZED_BOTH);
jfrm.setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
int random = generator.nextInt(9)+1;
for (int i = lines; i < lines+random; i++) {
box.add(new JLabel("Line number " + i));
}
lines+=random;
jfrm.validate();
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new Test();
}
});
}
}

Signature
Knute Johnson
email s/nospam/linux/
------->>>>>>http://www.NewsDem
all@singletask.com - 03 Apr 2008 23:11 GMT
jfrm.pack(); did not help...
but jfrm.validate(); did the trick!
Thanks for your help! :-)
On Apr 3, 6:17 pm, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
> frod...@gmail.com wrote:
> > Hi!
[quoted text clipped - 116 lines]
>
> - Show quoted text -
frodefi@gmail.com - 04 Apr 2008 00:11 GMT
jfrm.pack(); did not help, perhpas I did something wrong... But JList
definately looks like the thing for me.
Anyway, jfrm.validate() did the trick for this test-case.
Thanks for your help! :-)
On Apr 3, 6:17 pm, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
> frod...@gmail.com wrote:
> > Hi!
[quoted text clipped - 116 lines]
>
> - Show quoted text -