Eu estou começando a usar gui no java desktop. Eu estou usando o modo Design do Java e desenvolvi um JFrame Form com um JMenu no Jmenu tem um JMenuItem. Desebvolvi também um JInternalFrame Form, nele tem alguns JLabels e JTextField.
Eu quero que quando eu clicar no JMenuItem que deixei com o nome de novo ele abra o JInternalFrame Form onde estão as caixas de texto. Estou tentando ativar isso mas não consigo. Como eu faço?
O meu código é esse:
JFrame:
/*
* MDINota.java
*
* Created on 26 de Abril de 2006, 21:03
*/
package Nota;
/**
*
* @author root
*/
public class MDINota extends javax.swing.JFrame {
/** Creates new form MDINota */
public MDINota() {
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.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jMenuBar1 = new javax.swing.JMenuBar();
Arquivo = new javax.swing.JMenu();
Novo = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Arquivo.setText("Arquivo");
Novo.setText("Novo");
Arquivo.add(Novo);
jMenuBar1.add(Arquivo);
setJMenuBar(jMenuBar1);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 640, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 463, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MDINota().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JMenu Arquivo;
private javax.swing.JMenuItem Novo;
private javax.swing.JMenuBar jMenuBar1;
// End of variables declaration
}
JInternalFrame
/*
* FormNota.java
*
* Created on 26 de Abril de 2006, 21:07
*/
package Nota;
/**
*
* @author root
*/
public class FormNota extends javax.swing.JInternalFrame {
/** Creates new form FormNota */
public FormNota() {
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.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
setTitle("Nota");
jLabel1.setText("Nome:");
jLabel2.setText("Endere\u00e7o:");
jLabel3.setText("Bairro:");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(layout.createSequentialGroup()
.add(jLabel1)
.add(4, 4, 4)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 339, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.add(jLabel2)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField2)))
.add(layout.createSequentialGroup()
.add(jLabel3)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 247, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(181, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addContainerGap(224, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
// End of variables declaration
}
Alguém pode me ajudar? Estou usando o modo design! Não estou fazendo o layout na mão.
Pergunta
alexandremanowar
E a e galera
Eu estou começando a usar gui no java desktop. Eu estou usando o modo Design do Java e desenvolvi um JFrame Form com um JMenu no Jmenu tem um JMenuItem. Desebvolvi também um JInternalFrame Form, nele tem alguns JLabels e JTextField.
Eu quero que quando eu clicar no JMenuItem que deixei com o nome de novo ele abra o JInternalFrame Form onde estão as caixas de texto. Estou tentando ativar isso mas não consigo. Como eu faço?
O meu código é esse:
JFrame:
JInternalFrameAlguém pode me ajudar? Estou usando o modo design! Não estou fazendo o layout na mão.
Link para o comentário
Compartilhar em outros sites
2 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.