setVisible problem
Hello ,I got the following situation:
A form (main form) which extends JFrame and creates some objects which are encapsulated in the main form and also extends JFrame.
In the main of a MainForm i create a MainForm object and then in the MainForm constractor create the encapsulated objects which contains different things.
The problem is that i don't see encapsulated objects on the screen after setting setVisible(true) at the end of main () in MainForm.
Why?
Thanks
[505 byte] By [
codingGa] at [2007-11-27 8:55:49]

> Why?
I know that I'd do better seeing your actual code than reading your description. Perhaps others more talented than I will have better luck with just the description, but if not, then why not just post a compilable example that is small as possible yet self-contained and demonstrates your problem.
Also, please use code tags if you post code.
Good luck!
/Pete
Make sure you are adding your components to the contentPane:
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Test extends JFrame {
private JButton closeBtn;
public Test() {
initComponents();
}
private void initComponents() {
closeBtn = new JButton("Close");
closeBtn.setLocation(5, 5);
closeBtn.setSize(100, 20);
this.getContentPane().setLayout(null);
this.getContentPane().add(closeBtn);
this.pack();
this.setSize(300, 300);
this.setLocationRelativeTo(null);
this.setTitle("A Simple Demo");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
closeBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
System.exit(0);
}
});
}
public static void main(String[] argv) {
new Test().setVisible(true);
}
}