swing problems

Hello ,I am atying to create a button and presented on a screen by extending the JFrame and by creating a JButton object.The problem is that i can't see the button while i am running it. why?
[206 byte] By [codingGa] at [2007-11-27 3:29:25]
# 1

> Hello ,

> I am atying to create a button and presented on a

> screen by extending the JFrame and by creating a

> JButton object.The problem is that i can't see the

> button while i am running it. why?

Because you have done something wrong?

Did you expect a better answer? You aren't giving any specific details in your question.

Kaj

kajbja at 2007-7-12 8:32:21 > top of Java-index,Java Essentials,New To Java...
# 2

try to be more precise:

import javax.swing.*;

public class FormA extends JFrame{

/**

* @param args

*/

public static void main(String[] args) {

JPanel jp = new JPanel();

JButton jb = new JButton("Open");

jp.add(jb);

// TODO Auto-generated method stub

}

}

codingGa at 2007-7-12 8:32:21 > top of Java-index,Java Essentials,New To Java...
# 3

your code is good, but you do not decide what you will do with your panel.

add this statement to your code:

getContentPane().add(jp, BorderLayout.CENTER);

ofcourse after:

JPanel jp = new JPanel();

do not forget to add:

import java.awt.BorderLayout;

I hope this will be helpfull.

Ahmad Elsafty

NourElsaftya at 2007-7-12 8:32:21 > top of Java-index,Java Essentials,New To Java...
# 4
Where do you setVisible to true? where to do you add the JPanel to the JFrame?Where do you..You need to check here: http://home.cogeco.ca/~ve3ll/jatutora.htm
_helloWorld_a at 2007-7-12 8:32:21 > top of Java-index,Java Essentials,New To Java...