Board index » jbuilder » Frames and components

Frames and components


2004-06-23 02:37:08 AM
jbuilder3
I am trying to add labels, textbox and button to a frame but it wont appear on the frame until i resize the frame. what wld be the reason. The following is my code - do i need to add anything to it
import java.awt.*;
import java.awt.*;
public class FrameDemo extends Frame{
public static void main(String args[]){
FrameDemo fd = new FrameDemo();
Panel p = new Panel();
fd.setSize(400,400);
fd.setVisible(true);
fd.setTitle("Frame Demo");
fd.setBackground(Color.red);
fd.setForeground(Color.blue);
fd.setLayout(new FlowLayout());
Label lb = new Label("TEXT");
p.add(lb);
Button bt = new Button("Push me");
p.add(bt);
TextField tf = new TextField("Type here",20);
p.add(tf);
p.setVisible(true);
fd.add(p);
}
}
thanks
 
 

Re:Frames and components

On 22 Jun 2004 11:37:08 -0700, lata < XXXX@XXXXX.COM >wrote:
Quote
The following is my code - do i need to add anything to it
Either move the
fd.setVisible(true);
*after* your code to add components, or add a
fd.repaint();
at the end.
--
Using Opera's revolutionary e-mail client: www.opera.com/m2/