Galera to com o seguinte problema numa aplicação com JFrame, tenho um JFrame, e um botão que abre outro jframe, porem este outro esta abrindo vazio e eu nao consigo entender o porque, minha aplicação esta deste jeito
package teste;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
public class ex01 extends javax.swing.JFrame{
private static final long serialVersionUID = 1L;
public static void main(String[] args) {
JFrame window = new JFrame("Janela 01");
window.setSize(400,400);
window.setVisible(true);
window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel painel = new JPanel();
painel.setLayout(new GridLayout(1, 1));
painel.setBackground(new Color(55, 55, 55));
painel.setBounds(0, 0, 400, 400);
window.add(painel);
JButton btn = new JButton();
btn.setText("abri janela 2");
btn.setBackground(Color.white);
btn.setSize(150,50);
painel.add(btn);
btn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
new ex02().setVisible(true);
}
});
}
}
este a cima seria o codigo de um jframe e este a baixo o jframe q seria aberto pelo de cima
package teste;
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
public class ex02 extends javax.swing.JFrame{
private static final long serialVersionUID = 1L;
public static void main(String[] args) {
JFrame window = new JFrame("Janela 01");
window.setSize(400,400);
window.setVisible(true);
window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel painel = new JPanel();
painel.setLayout(new GridLayout(1, 1));
painel.setBackground(new Color(55, 55, 55));
painel.setBounds(0, 0, 400, 400);
window.add(painel);
JLabel jn2 = new JLabel();
jn2.setText("Janela 2");
jn2.setBounds(50,50,150,50);
jn2.setForeground(Color.white);
painel.add(jn2);
}
}