JinternalFrame

1 resposta
jonasjgs2

bom dia a todos..
eu tenho um jinternalframe
e tenho um jpainel

nao consigo adicional o meu painel "painalexemplo" no jinternalframe
alguem pode me explicar?

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package master00java;

import java.awt.Dimension;
import javax.swing.JFrame;

/**
 *
 * @author Admin
 */
public class PainalPrincipal extends javax.swing.JInternalFrame {
     private JFrame frame;
     PainelExemplo painelexemplo=null;
     

    public PainelPrincipal(JFrame frame) {
        this.frame = frame;
        painelexemplo = new painelexemplo(frame);
        painelexemplo.setVisible(true);
        initComponents();
        
//        this.add(painelexemplo);                                                  // ja tentei adicionar assim
        this.getContentPane().add(painelexemplo);                          // e com esta linha tambem nao mostra
        
    }

    /**
     * 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() {

        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                formMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 696, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 669, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>

    private void formMouseClicked(java.awt.event.MouseEvent evt) {                                  
        // TODO add your handling code here:

    }                                 

    // Variables declaration - do not modify
    // End of variables declaration
}

1 Resposta

jeanmalvessi

O JInternalFrame deve ser adicionado e não receber outros componentes. Você não vai adicionar um JPanel a um JInternalFrame, mas sim adicionar um JInternalFrame em um JDesktopPane.

Sugiro dar uma procurada aqui no fórum mesmo sobre aplicações MDI com JDesktopPane! :smiley:

Criado 17 de janeiro de 2013
Ultima resposta 17 de jan. de 2013
Respostas 1
Participantes 2