IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

AWT/Swing Java Discussion :

Pas d'affichage de mon application sous netbeans


Sujet :

AWT/Swing Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Candidat au Club
    Homme Profil pro
    Ingénieur développement matériel électronique
    Inscrit en
    Mars 2012
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement matériel électronique
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Mars 2012
    Messages : 2
    Par défaut Pas d'affichage de mon application sous netbeans
    Bonjour,

    Je suis nouvellement inscrit et un débutant dans les applications graphiques java.
    J'essaie en vain de faire tourner le code suivant sans parvenir à afficher mon application graphique. De plus, en prévisualisation la combolist n'affiche aucun des items. Qu'est-ce qui cloche ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
     
     
    import javax.swing.JOptionPane;
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    /*
     * choixDessin.java
     *
     * Created on 25 mars 2012, 20:35:51
     */
     
    /**
     *
     * @author pascal
     */
    public class ChoixDessin extends javax.swing.JPanel {
     
        /** Creates new form choixDessin */
        public ChoixDessin() {
            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() {
     
            jTextField2 = new javax.swing.JTextField();
            jLabel7 = new javax.swing.JLabel();
            jButton1 = new javax.swing.JButton();
            jComboListFigure = new javax.swing.JComboBox();
            jPanel1 = new javax.swing.JPanel();
            jTextFieldx0 = new javax.swing.JTextField();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jLabel4 = new javax.swing.JLabel();
            jTextFieldy0 = new javax.swing.JTextField();
            jSeparator1 = new javax.swing.JSeparator();
            jLabel5 = new javax.swing.JLabel();
            jTextFieldHauteur = new javax.swing.JTextField();
            jTextFieldLargeur = new javax.swing.JTextField();
            jLabel6 = new javax.swing.JLabel();
            jLabel8 = new javax.swing.JLabel();
            jLabel1 = new javax.swing.JLabel();
            jbuttonCreerFigure = new javax.swing.JButton();
            jbuttonAnnFigure = new javax.swing.JButton();
     
            jTextField2.setText("Choix de la figure");
            jTextField2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jTextField2ActionPerformed(evt);
                }
            });
     
            jLabel7.setText("hauteur");
     
            jButton1.setText("jButton1");
     
            setBorder(new javax.swing.border.MatteBorder(null));
            setName("Creer une figure"); // NOI18N
     
            jComboListFigure.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ellipse", "Cercle", "Rectangle", "Carré" }));
            jComboListFigure.setSelectedItem("Ellipse");
            jComboListFigure.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jComboListFigureActionPerformed(evt);
                }
            });
     
            jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
     
            jTextFieldx0.setText("0");
            jTextFieldx0.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jTextFieldx0ActionPerformed(evt);
                }
            });
     
            jLabel2.setText("Origine");
     
            jLabel3.setText("x0");
     
            jLabel4.setText("y0");
     
            jTextFieldy0.setText("100");
            jTextFieldy0.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jTextFieldy0ActionPerformed(evt);
                }
            });
     
            jLabel5.setText("Dimension");
     
            jTextFieldHauteur.setText("100");
            jTextFieldHauteur.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jTextFieldHauteurActionPerformed(evt);
                }
            });
     
            jTextFieldLargeur.setText("100");
            jTextFieldLargeur.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jTextFieldLargeurActionPerformed(evt);
                }
            });
     
            jLabel6.setText("hauteur");
     
            jLabel8.setText("largeur");
     
            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(73, 73, 73)
                            .addComponent(jTextFieldHauteur, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(jTextFieldLargeur, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(51, 51, 51)
                            .addComponent(jLabel6)
                            .addGap(18, 18, 18)
                            .addComponent(jLabel8))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel2)
                                    .addGap(18, 18, 18)
                                    .addComponent(jLabel3)
                                    .addGap(22, 22, 22))
                                .addComponent(jTextFieldx0, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGap(38, 38, 38)
                                    .addComponent(jTextFieldy0, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel4)
                                    .addGap(20, 20, 20))))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jLabel5)))
                    .addContainerGap())
            );
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jLabel2)
                            .addGap(18, 18, 18))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel3)
                                .addComponent(jLabel4))
                            .addGap(4, 4, 4)))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jTextFieldy0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextFieldx0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jLabel5)
                    .addGap(12, 12, 12)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel6)
                        .addComponent(jLabel8))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextFieldHauteur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextFieldLargeur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
            );
     
            jLabel1.setText("Choix de la figure");
     
            jbuttonCreerFigure.setText("OK");
     
            jbuttonAnnFigure.setText("Ann.");
            jbuttonAnnFigure.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jbuttonAnnFigureActionPerformed(evt);
                }
            });
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jbuttonCreerFigure)
                                .addComponent(jbuttonAnnFigure))
                            .addGap(29, 29, 29))
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jComboListFigure, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGap(24, 24, 24))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)
                    .addContainerGap())
                .addGroup(layout.createSequentialGroup()
                    .addGap(18, 18, 18)
                    .addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jComboListFigure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(51, 51, 51)
                    .addComponent(jbuttonCreerFigure)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
                    .addComponent(jbuttonAnnFigure)
                    .addGap(24, 24, 24))
            );
        }// </editor-fold>                        
     
        @SuppressWarnings("static-access")
        private void jTextFieldx0ActionPerformed(java.awt.event.ActionEvent evt) {                                             
    	String texteUtilisateur = jTextFieldx0.getText();
            if (Integer.parseInt(texteUtilisateur) < 0) {
                JOptionPane jerreur = new JOptionPane();
                String mess = "Valeur négative ! \n";
                jerreur.showMessageDialog(null, mess, "À propos", JOptionPane.ERROR_MESSAGE);
            }     
        }                                            
     
        private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {                                            
            System.out.println("Salut !");
            // TODO add your handling code here:
        }                                           
     
        @SuppressWarnings("static-access")
        private void jTextFieldy0ActionPerformed(java.awt.event.ActionEvent evt) {                                             
    	String texteUtilisateur = jTextFieldy0.getText();
            System.out.println("Salut !");
            if (Integer.parseInt(texteUtilisateur) < 0) {
                JOptionPane jerreur = new JOptionPane();
                String mess = "Valeur négative ! \n";
                jerreur.showMessageDialog(null, mess, "À propos", JOptionPane.ERROR_MESSAGE);
            }
        }                                            
     
        @SuppressWarnings("static-access")
        private void jTextFieldHauteurActionPerformed(java.awt.event.ActionEvent evt) {                                                  
            System.out.println("Salut !");
    	String texteUtilisateur = jTextFieldHauteur.getText();
            if (Integer.parseInt(texteUtilisateur) < 0) {
                JOptionPane jerreur = new JOptionPane();
                String mess = "Valeur négative ! \n";
                jerreur.showMessageDialog(null, mess, "À propos", JOptionPane.ERROR_MESSAGE);
            }         
        }                                                 
     
        @SuppressWarnings("static-access")
        private void jTextFieldLargeurActionPerformed(java.awt.event.ActionEvent evt) {                                                  
    	String texteUtilisateur = jTextFieldLargeur.getText();
            if (Integer.parseInt(texteUtilisateur) < 0) {
                JOptionPane jerreur = new JOptionPane();
                String mess = "Valeur négative ! \n";
                jerreur.showMessageDialog(null, mess, "À propos", JOptionPane.ERROR_MESSAGE);
            }
        }                                                 
     
        private void jbuttonAnnFigureActionPerformed(java.awt.event.ActionEvent evt) {                                                 
            System.out.println("Salut !");
            // TODO add your handling code here:
        }                                                
     
        private void jComboListFigureActionPerformed(java.awt.event.ActionEvent evt) {                                                 
           Object getFigure = jComboListFigure.getSelectedItem();
           System.out.println("get figure " + getFigure);
        }                                                
     
        public static void main(String args[]) {
            ChoixDessin monChoixDessin = new ChoixDessin();
            monChoixDessin.setVisible(true);
        }
     
        // Variables declaration - do not modify                     
        private javax.swing.JButton jButton1;
        private javax.swing.JComboBox jComboListFigure;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JLabel jLabel7;
        private javax.swing.JLabel jLabel8;
        private javax.swing.JPanel jPanel1;
        private javax.swing.JSeparator jSeparator1;
        private javax.swing.JTextField jTextField2;
        private javax.swing.JTextField jTextFieldHauteur;
        private javax.swing.JTextField jTextFieldLargeur;
        private javax.swing.JTextField jTextFieldx0;
        private javax.swing.JTextField jTextFieldy0;
        private javax.swing.JButton jbuttonAnnFigure;
        private javax.swing.JButton jbuttonCreerFigure;
        // End of variables declaration                   
     
    }

  2. #2
    Membre émérite Avatar de fraco
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    750
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juin 2006
    Messages : 750
    Par défaut
    Salut !

    Commence par un petit projet ultra-simple, afficher un label par exemple...
    si ça marche, tu ajoutes d'autres éléments, tu verras bien où ça coince !

  3. #3
    Membre éclairé
    Homme Profil pro
    Développeur java, .Net
    Inscrit en
    Janvier 2011
    Messages
    55
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Développeur java, .Net

    Informations forums :
    Inscription : Janvier 2011
    Messages : 55
    Par défaut
    Si tu changes ton main ainsi?


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    public static void main(String args[]) {
            ChoixDessin monChoixDessin = new ChoixDessin();
            JFrame fenetre=new JFrame();
            fenetre.add(monChoixDessin);
            fenetre.pack();
            fenetre.setVisible(true);
            //monChoixDessin.setVisible(true);
        }

  4. #4
    Candidat au Club
    Homme Profil pro
    Ingénieur développement matériel électronique
    Inscrit en
    Mars 2012
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement matériel électronique
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Mars 2012
    Messages : 2
    Par défaut
    Citation Envoyé par gandalf72000 Voir le message
    Si tu changes ton main ainsi?


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    public static void main(String args[]) {
            ChoixDessin monChoixDessin = new ChoixDessin();
            JFrame fenetre=new JFrame();
            fenetre.add(monChoixDessin);
            fenetre.pack();
            fenetre.setVisible(true);
            //monChoixDessin.setVisible(true);
        }
    En fait j'ai changé mon fusil d'épaule et j'ai refait complètement mon interface. Elle est opérationnelle. Ce faisant j'ai compris mon erreur du début.
    Merci pour les conseils tout de même.

  5. #5
    Membre averti Avatar de JakRenegade
    Homme Profil pro
    Etudiant en Informatique
    Inscrit en
    Avril 2012
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Doubs (Franche Comté)

    Informations professionnelles :
    Activité : Etudiant en Informatique

    Informations forums :
    Inscription : Avril 2012
    Messages : 33
    Par défaut
    Mets le post en résolu

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Déploiement de mon application sous TOMCAT
    Par binard dans le forum Servlets/JSP
    Réponses: 8
    Dernier message: 01/05/2008, 17h18
  2. Réponses: 7
    Dernier message: 11/12/2007, 09h08
  3. Comment lancer mon application sous n'importe quel répertoire ?
    Par condor_01 dans le forum Applications et environnements graphiques
    Réponses: 13
    Dernier message: 14/11/2007, 23h02
  4. Réponses: 15
    Dernier message: 08/09/2006, 09h45
  5. [TOMCAT]pas d'images pour mon applications web
    Par mamiberkof dans le forum Tomcat et TomEE
    Réponses: 4
    Dernier message: 23/04/2006, 16h41

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo