Java swing comment afficher un jpanel

Résolu/Fermé
layeures Messages postés 286 Date d'inscription mercredi 13 juin 2007 Statut Membre Dernière intervention 22 juin 2018 - 9 sept. 2010 à 10:22
layeures Messages postés 286 Date d'inscription mercredi 13 juin 2007 Statut Membre Dernière intervention 22 juin 2018 - 16 sept. 2010 à 18:33
Bonjour,
comment faire pour afficher une fenetre apres un clic sur un bouton
voici ce que j ai essayer de faire et qui ne marche pas
interfanceun.java
    private void boutonunActionPerformed(java.awt.event.ActionEvent evt) {                                         
panel test = new panel();
        // TODO add your handling code here:
    }                                        


panel.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * panel.java
 *
 * Created on 9 sept. 2010, 09:45:42
 */

package intro;

/**
 *
 * @author sofiene
 */
public class panel extends javax.swing.JPanel {

    /** Creates new form panel */
    public panel() {
    setVisible(true);
    
        initComponents();
    }

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

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>                        


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

}


merci de votre aide
A voir également:

2 réponses

Tu dois declarer une fenetre "JFrame" et ajouter a la fenetre ton JPanel.

par exemple:

fenetre.getContentPane.add(panel);
2
layeures Messages postés 286 Date d'inscription mercredi 13 juin 2007 Statut Membre Dernière intervention 22 juin 2018 3
16 sept. 2010 à 18:33
bonjour
j ai enfin compris
je te remercie

c est sympa de m'avoir aidé
1