Galera seguinte,
Gostaria de saber como poderia fazer para chamar uma classe dentro de um jPanel,
segue o codigo
Classe inteira
package tuxdesign;
public class Principal extends javax.swing.JFrame {
public Principal() {
initComponents();
}
// <editor-fold defaultstate="collapsed" desc=" Código Gerado ">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jMenuBar1 = new javax.swing.JMenuBar();
jArquivo = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 396, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 275, Short.MAX_VALUE)
);
jArquivo.setText("Menu");
jMenuItem1.setLabel("Area Restrita");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jArquivo.add(jMenuItem1);
jMenuBar1.add(jArquivo);
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(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
Adm a = new Adm();
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
a.show();
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Principal().setVisible(true);
}
});
}
// Declaração de variáveis - não modifique
private javax.swing.JMenu jArquivo;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JPanel jPanel1;
// Fim da declaração de variáveis
}
Estou chamando a minha outra classe pelo metodo show(), so q dai ela esta abrindo uma nova “janela”. como posso fazer para q ela abra dentro do japnel?
Adm a = new Adm();
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
a.show();
}
valeu galera…
[]s
leandrosu