Pessoal estou tendo problemas para fazer um JInternalFrame aparecer num Jdesktop.
vejam o q estou fazendo:
Código do JFrame q contém o JDesktop que irá chamar o JInternalFrame:
[code]/*
- Main.java
- Created on 13 de Abril de 2005, 10:52
*/
/**
*
-
@author Rodrigo Rocha
*/
public class Main extends javax.swing.JFrame {
Cadastro cadastro = new Cadastro();/** Creates new form Main */
public Main() {
initComponents();
jDesktop.add(cadastro, javax.swing.JLayeredPane.DEFAULT_LAYER);
}/** This method is called from within the constructor to
-
initialize the form.
-
WARNING: Do NOT modify this code. The content of this method is
-
always regenerated by the Form Editor.
*/
private void initComponents() {
jDesktop = new javax.swing.JDesktopPane();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle(“GESTOR”);
getContentPane().add(jDesktop, java.awt.BorderLayout.CENTER);jMenu1.setText(“Clientes”);
jMenu1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenu1ActionPerformed(evt);
}
});jMenuItem1.setText(“Cadastro”);
jMenuItem1.setName(“jMcadastro”);
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});jMenu1.add(jMenuItem1);
jMenuBar1.add(jMenu1);
setJMenuBar(jMenuBar1);
pack();
}
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {
cadastro.setVisible(true); // TODO add your handling code here:
}
/**
-
@param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Main().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JDesktopPane jDesktop;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
// End of variables declaration -
}[/code]
código do JInternalFrame:
[code]public class Cadastro extends javax.swing.JInternalFrame {
/** Creates new form Cadastro */
public Cadastro() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
getContentPane().setLayout(new java.awt.GridBagLayout());
setClosable(true);
setIconifiable(true);
setMaximizable(true);
setTitle("Cadastro");
setVisible(true);
jLabel1.setText("Nome:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
getContentPane().add(jLabel1, gridBagConstraints);
jTextField1.setName("txtNome");
jTextField1.setPreferredSize(new java.awt.Dimension(250, 21));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
getContentPane().add(jTextField1, gridBagConstraints);
jLabel2.setText("Endere\u00e7o:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
getContentPane().add(jLabel2, gridBagConstraints);
jTextField2.setPreferredSize(new java.awt.Dimension(250, 21));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
getContentPane().add(jTextField2, gridBagConstraints);
pack();
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration
}[/code]
Alguém pode me ajudar?