É o seguinte, eu tenho um frame que quando eu clicoem um botão ele tem que abrir um JDialog pra cadastrar autores. Eu construi a JDialog no construtor de tela do NetBeans, se eu rodar, ela roda, agora quando eu chamo ela através do botão aparece a janela, mas não aparece os elementos. O que fazer?
Problema JDialog
3 Respostas
Coloque seu código aqui para o pessoal poder ajudar
package fronteira;
import javax.swing.ImageIcon;
/**
*
* @author Guirodr
*/
public class Janela extends javax.swing.JDialog {
ImageIcon im=new ImageIcon("C:/Users/Guirodr/Desktop/PENDRIVE/Originals/1.png"),im1=new ImageIcon("C:/Users/Guirodr/Desktop/PENDRIVE/Originals/2.png"),im2=new ImageIcon("C:/Users/Guirodr/Desktop/PENDRIVE/Originals/3.png"),im3=new ImageIcon("C:/Users/Guirodr/Desktop/PENDRIVE/Originals/4.png"),im4=new ImageIcon("C:/Users/Guirodr/Desktop/PENDRIVE/Originals/5.png");
/** Creates new form NewJDialog */
public Janela(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
Janela() {
setBounds(100,100,100,100);
//Janela janela=new Janela();
//janela.add(jToolBar1);
//janela.setVisible(true);
}
/** 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jRadioButton1 = new javax.swing.JRadioButton();
jToolBar1 = new javax.swing.JToolBar();
jButton1 = new javax.swing.JButton(im);
jButton2 = new javax.swing.JButton(im2);
jButton3 = new javax.swing.JButton(im3);
jButton4 = new javax.swing.JButton(im4);
jButton5 = new javax.swing.JButton(im1);
jColorChooser1 = new javax.swing.JColorChooser();
jRadioButton1.setText("jRadioButton1");
jRadioButton1.setFocusable(false);
jRadioButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jRadioButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setBackground(new java.awt.Color(0, 110, 203));
jToolBar1.setFloatable(false);
jToolBar1.setRollover(true);
jButton1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton1.setFocusable(false);
jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jToolBar1.add(jButton1);
jButton2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton2.setFocusable(false);
jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jToolBar1.add(jButton2);
jButton3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jButton3.setFocusable(false);
jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jToolBar1.add(jButton3);
jButton4.setBorder(javax.swing.BorderFactory.createCompoundBorder());
jButton4.setFocusable(false);
jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jToolBar1.add(jButton4);
jButton5.setFocusable(false);
jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jToolBar1.add(jButton5);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(114, 114, 114)
.addComponent(jColorChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 734, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(5, 5, 5)
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jColorChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(21, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// 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() {
Janela dialog = new Janela(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JColorChooser jColorChooser1;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JToolBar jToolBar1;
// End of variables declaration
}
você tem certeza que instanciou (usando o new) a Dialog na hora que chamou-a pelo Frame?
Criado 1 de maio de 2011
Ultima resposta 1 de mai. de 2011
Respostas 3
Participantes 3
Alura Sistemas operacionais: entenda seu conceito e suas funções Descubra o que são sistemas operacionais, suas funções e tipos. Aprenda tudo de forma clara e objetiva. Não perca tempo!
Casa do Codigo Orientacao a Objetos: Aprenda seus conceitos e suas... Por Thiago Leite e Carvalho — Casa do Codigo