Précédent   Forum du club des développeurs et IT Pro > Java > EDI et OUTILS pour Java > NetBeans
NetBeans Forum d'entraide NetBeans. Avant de poster -> Ressources NetBeans - La F.A.Q NetBeans - Tutoriels NetBeans
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 09/01/2013, 21h34   #1
lcrprod
Invité de passage
 
Homme
Technicien Help Desk
Inscription : novembre 2003
Messages : 6
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 36
Localisation : France, Haute Vienne (Limousin)

Informations professionnelles :
Activité : Technicien Help Desk
Secteur : Santé

Informations forums :
Inscription : novembre 2003
Messages : 6
Points : 0
Points : 0
Par défaut JInternalFrame via un menu

Bonjour,


j'ai un soucis pour effectuer l'opération suivante: J'ai une fenêtre principale qui contient mes menus , dans ces menus ( pour l'instant un seul ) je veux ouvrir une autre fenêtre qui est contenus dans une autre classe. Cette opération fonctionne à merveille mais moi je veux l'ouvrir en mode interne à mon jDesktop, comme une JInternalFrame dans ma première fenêtre.

je vous joint le bout de code qui me pose problème.

Lorsque je laisse actif la ligne desktopPane.add(fenetrePrepa); j'ai automatiquement une erreur.


Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
try { 
                FenPreparationPharma fenetrePrepa = new FenPreparationPharma();
                fenetrePrepa.pack();
                desktopPane.add(fenetrePrepa);
                fenetrePrepa.setVisible(true);
                //dispose();
            } 
                catch(Exception e) {
                JOptionPane.showMessageDialog(null, 
                        "Impossible d'ouvrir" 
                        + " la fenetre", 
                        "ALERTE", JOptionPane.ERROR_MESSAGE); 
 
                }


Merci par avance a ceux qui auront pris quelque minute pour lire mon message et doublement merci pour ceux qui auront des idées...

Cordialement.
lcrprod est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2013, 09h04   #2
plegat
Expert Confirmé Sénior
 
Jean-Michel BORLOT
Fabricant et casseur d'avions
Inscription : avril 2004
Messages : 3 216
Détails du profil
Informations personnelles :
Nom : Jean-Michel BORLOT
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Fabricant et casseur d'avions
Secteur : Aéronautique - Marine - Espace - Armement

Informations forums :
Inscription : avril 2004
Messages : 3 216
Points : 5 379
Points : 5 379
Salut

Citation:
Envoyé par lcrprod Voir le message
Lorsque je laisse actif la ligne desktopPane.add(fenetrePrepa); j'ai automatiquement une erreur.
Et c'est quoi comme erreur?
Parce que c'est joli de mettre un message d'erreur personnalisé, mais avec ton code du coup on ne sait jamais quelle erreur tu as déclenché...
__________________
"Errare humanum est, sed perseverare diabolicum"

Ma page sur DVP.com
plegat est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2013, 10h08   #3
lcrprod
Invité de passage
 
Homme
Technicien Help Desk
Inscription : novembre 2003
Messages : 6
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 36
Localisation : France, Haute Vienne (Limousin)

Informations professionnelles :
Activité : Technicien Help Desk
Secteur : Santé

Informations forums :
Inscription : novembre 2003
Messages : 6
Points : 0
Points : 0
Bonjour,
merci pour la réponse.

voici les codes erreurs générés:

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: adding a window to a container
	at java.awt.Container.checkNotAWindow(Container.java:483)
	at java.awt.Container.addImpl(Container.java:1084)
	at javax.swing.JLayeredPane.addImpl(JLayeredPane.java:230)
	at javax.swing.JDesktopPane.addImpl(JDesktopPane.java:474)
	at java.awt.Container.add(Container.java:410)
	at Interface.InterfacePrincipale.prepaMenuItemActionPerformed(InterfacePrincipale.java:283)
	at Interface.InterfacePrincipale.access$400(InterfacePrincipale.java:20)
	at Interface.InterfacePrincipale$5.actionPerformed(InterfacePrincipale.java:165)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
	at java.awt.Component.processMouseEvent(Component.java:6505)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
	at java.awt.Component.processEvent(Component.java:6270)
	at java.awt.Container.processEvent(Container.java:2229)
	at java.awt.Component.dispatchEventImpl(Component.java:4861)
	at java.awt.Container.dispatchEventImpl(Container.java:2287)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
	at java.awt.Container.dispatchEventImpl(Container.java:2273)
	at java.awt.Window.dispatchEventImpl(Window.java:2719)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
	at java.awt.EventQueue.access$200(EventQueue.java:103)
	at java.awt.EventQueue$3.run(EventQueue.java:682)
	at java.awt.EventQueue$3.run(EventQueue.java:680)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:696)
	at java.awt.EventQueue$4.run(EventQueue.java:694)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
lcrprod est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2013, 10h46   #4
plegat
Expert Confirmé Sénior
 
Jean-Michel BORLOT
Fabricant et casseur d'avions
Inscription : avril 2004
Messages : 3 216
Détails du profil
Informations personnelles :
Nom : Jean-Michel BORLOT
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Fabricant et casseur d'avions
Secteur : Aéronautique - Marine - Espace - Armement

Informations forums :
Inscription : avril 2004
Messages : 3 216
Points : 5 379
Points : 5 379
Code :
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: adding a window to a container
Je crois que c'est clair...
Ta fenêtre doit contenir un panel ou un autre container, c'est lui qu'il te faut placer dans ton desktop, pas la fenêtre complète.
__________________
"Errare humanum est, sed perseverare diabolicum"

Ma page sur DVP.com
plegat est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2013, 13h54   #5
lcrprod
Invité de passage
 
Homme
Technicien Help Desk
Inscription : novembre 2003
Messages : 6
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 36
Localisation : France, Haute Vienne (Limousin)

Informations professionnelles :
Activité : Technicien Help Desk
Secteur : Santé

Informations forums :
Inscription : novembre 2003
Messages : 6
Points : 0
Points : 0
merci pour ta réponse, j'ai rajouté un panel à la classe jframe que je souhaite ouvrir mais j'ai toujours le même message.

voici la classe complète créer via netbeans. j'avoue je débute dans ce qui est interface graphique....

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interface;
 
/**
 *
 * @author crous
 */
public class FenPreparationPharma extends javax.swing.JFrame {
 
    /**
     * Creates new form FenPreparationPharma
     */
    public FenPreparationPharma() {
        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() {
 
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
 
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Préparation Magistrale Pharmaceutique");
 
        jLabel1.setText("TEST");
 
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(358, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jLabel1)
                .addContainerGap(262, Short.MAX_VALUE))
        );
 
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
 
        getAccessibleContext().setAccessibleDescription("");
        getAccessibleContext().setAccessibleParent(this);
 
        pack();
    }// </editor-fold>
 
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FenPreparationPharma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FenPreparationPharma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FenPreparationPharma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FenPreparationPharma.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
 
        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FenPreparationPharma().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration
}
lcrprod est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2013, 14h43   #6
plegat
Expert Confirmé Sénior
 
Jean-Michel BORLOT
Fabricant et casseur d'avions
Inscription : avril 2004
Messages : 3 216
Détails du profil
Informations personnelles :
Nom : Jean-Michel BORLOT
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Fabricant et casseur d'avions
Secteur : Aéronautique - Marine - Espace - Armement

Informations forums :
Inscription : avril 2004
Messages : 3 216
Points : 5 379
Points : 5 379
Citation:
Envoyé par lcrprod Voir le message
j'ai rajouté un panel à la classe jframe que je souhaite ouvrir mais j'ai toujours le même message.
ce qui est normal...

Avant, tu essayais d'intégrer dans ton desktop une jframe.
Maintenant, tu essayes d'intégrer dans ton desktop une jframe... qui intègre un jpanel, ok, mais c'est toujours une jframe. Donc c'est pareil.

Ce que tu dois faire, c'est intégrer à ton desktop le jpanel qui est intégré dans ta jframe, mais pas intégrer ta jframe directement.

Donc:
- soit tu "bidouilles" ta classe FenPreparationPharma pour pouvoir récupérer le jpanel (via un getter par exemple)
- soit tu modifies ta classe FenPreparationPharma pour lui faire étendre JPanel et plus JFrame (si tant est que tu n'aies plus besoin qu'elle l'étende)
__________________
"Errare humanum est, sed perseverare diabolicum"

Ma page sur DVP.com
plegat est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2013, 15h03   #7
lcrprod
Invité de passage
 
Homme
Technicien Help Desk
Inscription : novembre 2003
Messages : 6
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 36
Localisation : France, Haute Vienne (Limousin)

Informations professionnelles :
Activité : Technicien Help Desk
Secteur : Santé

Informations forums :
Inscription : novembre 2003
Messages : 6
Points : 0
Points : 0
Merci pour tes explications ,

Entre temps j'ai trouvé exactement ce que je voulais en recréant ma classe pour qu'elle soit de type swing JInternalFrame et la mon code fonctionne à merveille sans rien touché.

j'ai trouvé en voulait crée une nouvelle fenêtre

je passe le sujet en résolu.
lcrprod est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 08h07.


 
 
 
 
Partenaires

Hébergement Web