Tipos incompatíveis..o que fazer nesta sinuca?

1 resposta
C

Pessoal,

Quanto tento compilar o codigo abaixo, dá erro: imcompatibles types
O próprio erro já diz tudo: tipos incompativeis, ou seja, acho que o erro está ocorrendo nesta linha :

" JComponent newContentPane = new CadAtivo();"

Quando coloco a classe herdando JPanel não ocorre este erro, mas preciso que esta classe herde JFrame… Alguém sabe o que posso fazer?

codigo:

public class CadAtivo extends JFrame

{

JLabel lbCodigo, lbCliente, lbEqp, lbFabric, lbMarca, lbModelo;

JComboBox cbCliente, cbFornec, cbEqp, cbFabric;

JTextField tfCodigo, tfModelo, tfMarca;

JTabbedPane tabbedPane;

JComponent panel1,panel2;

public CadAtivo()
{

tabbedPane = new JTabbedPane();
  ImageIcon icon = new ImageIcon("imgs//abc.gif");

  panel1 = myPainel("Descricao");
  tabbedPane.addTab("Descricao", icon, panel1,"Descricao do Equipamento");
  tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);

  //** Objetos do panel1

  lbCodigo = new JLabel("Serial:");
  lbCodigo.setBounds(16, 42, 57, 21);
  panel1.add(lbCodigo);
        
  tfCodigo = new JTextField();
  tfCodigo.setBounds(100, 41, 100, 21);
  panel1.add(tfCodigo);
          ...
          
  //***

  panel2 = myPainel("Detalhes");
  panel2.setPreferredSize(new Dimension(415, 350));
  tabbedPane.addTab("Detalhes", icon, panel2,"Detalhes da Configuracao");
  tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);

  this.add(tabbedPane);

}

//****

public JComponent myPainel(String text)

{

JPanel panel = new JPanel(false);

JLabel filler = new JLabel(text);

filler.setHorizontalAlignment(JLabel.CENTER);

panel.setLayout(null);

panel.add(filler);

return panel;

}
public static void myFrame()

{

JFrame.setDefaultLookAndFeelDecorated(true);

JFrame frame = new JFrame(CadAtivo);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.dispose();
JComponent newContentPane = new CadAtivo();
  newContentPane.setOpaque(true);  
  frame.getContentPane().add(new CadAtivo());  
  frame.pack();
  frame.setVisible(true);

}

public static void main(String[] args)

{

javax.swing.SwingUtilities.invokeLater(new Runnable()

{

public void run()

{

myFrame();

}

});

}

}

1 Resposta

danieldestro

Olha aqui na documentação a hierarquia de classes da classe JFrame:
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JFrame.html

Use alguma delas que te satisfaça.

Criado 22 de maio de 2006
Ultima resposta 22 de mai. de 2006
Respostas 1
Participantes 2