Componentes em uma JInternalFrame

5 respostas
nefertiti

Alguém podia me ajudar? O que está errado no código abaixo? Os componentes não aparecessem na InternalFrame.

geneItem1.addActionListener (new ActionListener() {

public void actionPerformed(ActionEvent event){

JInternalFrame  frameGene1 = new JInternalFrame (Cadastrar gene,true,true,true,true);
setLayout (null);  
                    
                   //criação dos componentes 
                   unigeneLabel = new JLabel ("UNIGENE");
                   unigeneLabel.setBounds(50,50,200,40);
                   unigeneJTextField = new JTextField (10);
                   giLabel = new JLabel ("GI");
                   giJTextField = new JTextField(10);
                   nomeGeneLabel = new JLabel ("Nome do gene");
                   nomeGeneJTextField = new JTextField (255);
                   sequenciaDnaLabel = new JLabel("Seqüência de Dna");
                   sequenciaDnaTextArea = new JTextArea (20,10);
                   
                   
                    
                    //adicão do componentestes no InternalFrame
                    frameGene1.add(unigeneLabel);
                    frameGene1.add(unigeneJTextField);
                    frameGene1.add(giLabel);
                    frameGene1.add(giJTextField);
                    frameGene1.add(nomeGeneLabel);
                    frameGene1.add(nomeGeneJTextField);
                    frameGene1.add(sequenciaDnaLabel);
                    frameGene1.add(sequenciaDnaTextArea);


                   
			
			Container biancaContainer = frameGene1.getContentPane();
			JPanel biancaPanel = new JPanel();
                    biancaContainer.add(biancaPanel,BorderLayout.CENTER);
                    
                    
                    frameGene1.pack();
			
			biancaDesktop.add(frameGene1);
			frameGene1.setVisible(true);
                             
		}
	}
);

[color=“blue”][/color]

Até mais

Nefertiti :stuck_out_tongue:

5 Respostas

danieldestro

Você não está jogando este frameGene1 para lugar nenhum.

Você deve adicioná-lo ao JDesktopNumSeiDasQuantas…

1112

Use frameGene1.getContentPane().add() .

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JInternalFrame.html

“API”:
The JInternalFrame content pane is where you add child components. So, to create a JInternalFrame that has a number of buttons arranged with the content pane’s default BorderLayout object, you might do something like this:

JComponent c = (JComponent) internalFrame.getContentPane(); c.add(new JButton(), BorderLayout.NORTH); c.add(new JButton(), BorderLayout.CENTER);

danieldestro

Isso já acontece… leia o código!

brlima

eu tambem acho que ta faltando o getContentPane().
Vc deve adicionar os objetos no ContentPane do InternalFrame.

vc tb tá setando o que pra nulo ( setLayout(null) ??? ). Se ta pensando em setar o contentpane do internalFrame, faça assim:

frameGene1.setLayout(null);

E de preferencia , adicione o internalframe dentro de um desktoppane tb :wink:

Flw!

A

Tem quer criar um JDesktopPane para addicionar o JInternal Frame

JDesktopPane Desk;
Desk.add(framegene1);

Naum tenho certeza mas falta isso…

Criado 23 de agosto de 2004
Ultima resposta 24 de ago. de 2004
Respostas 5
Participantes 5