dcsimg
Swing Problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Akshay_B
Posted On:   Friday, July 29, 2005 07:33 AM

This is the first JFrmae i am trying to create public class mainFrameServer extends JFrame { JButton send; JTextField textSend; JTextArea textHist; public mainFrameServer() { System.out.println("here"); this.setBounds(50,50,600,600); this.setTitle("Server"); //this.layout(null); this.setVisible(true); Container cont = getContentPane(); cont.setLayout(null); textHist = new JTextArea(); textHist.setBounds(20,20,200,200); cont.add(textHist); send = new JButton(); send.setText(&quo   More>>

This is the first JFrmae i am trying to create


public class mainFrameServer extends JFrame

{

JButton send;

JTextField textSend;

JTextArea textHist;

public mainFrameServer()

{

System.out.println("here");

this.setBounds(50,50,600,600);

this.setTitle("Server");

//this.layout(null);

this.setVisible(true);



Container cont = getContentPane();

cont.setLayout(null);



textHist = new JTextArea();

textHist.setBounds(20,20,200,200);

cont.add(textHist);



send = new JButton();

send.setText("Send");

send.setBounds(250,300,50,30);

cont.add(send);




}





Now,.. wen i run this code (Needed classes r imported,..
compiling is fine) Firstly I dont see any components
added,... when I maximize the frame, then they are seen.

Another problem is, the text font in the JButton is too large
to fit in.

   <<Less

Re: Swing Problem

Posted By:   WarnerJan_Veldhuis  
Posted On:   Friday, July 29, 2005 08:09 AM

Remove setVisible() from the top and move it to the bottom of the method. When done adding components, call this.pack(), then call this.setVisible(true).
About | Sitemap | Contact