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 :

GUI Java par netbeans - ne s'affiche pas


Sujet :

AWT/Swing Java

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    92
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Juin 2006
    Messages : 92
    Points : 61
    Points
    61
    Par défaut GUI Java par netbeans - ne s'affiche pas
    Bonjour,

    J'ai généré ce code via netBeans, il me semble correct.
    Le projet ce compile bien mais ne me génére aucune fenêtre...

    PS : il manque peut-etre un setVisible(true) a la fin ?
    PS2 : j'ai essayé de placer le Setvisible, mais ca va tjs pas.
    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
     
    package javaapplication1;
     
    /**
     *
     * @author  gefa
     */
    public class NewJPanel extends javax.swing.JPanel {
     
        /** Creates new form NewJPanel */
        public NewJPanel() {
            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.
         */
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                          
        private void initComponents() {
            BtnCon = new javax.swing.JButton();
            jTextLogin = new javax.swing.JTextField();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jTextPassword = new javax.swing.JTextField();
     
            BtnCon.setText("Connection");
     
            jLabel1.setText("Login");
     
            jLabel2.setText("Password");
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(74, 74, 74)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel1)
                        .addComponent(jLabel2))
                    .addGap(6, 6, 6)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(BtnCon)
                        .addComponent(jTextLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(176, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(jTextLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(jTextPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(BtnCon)
                    .addContainerGap(214, Short.MAX_VALUE))
            );
        }// </editor-fold>                        
     
     
        // Variables declaration - do not modify                     
        private javax.swing.JButton BtnCon;
     
        public void setVisible(boolean aFlag) {
        }
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JTextField jTextLogin;
        private javax.swing.JTextField jTextPassword;
        // End of variables declaration                   
     
    }
    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
     
    /*
     * Main.java
     *
     * Created on 29 janvier 2007, 10:41
     *
     * To change this template, choose Tools | Template Manager
     * and open the template in the editor.
     */
     
    package javaapplication1;
     
    /**
     *
     * @author gefa
     */
    import javax.swing.*;
    import java.applet.*;
    import java.awt.*;
    import java.lang.*;
     
     
    public class Main
    {
     
        /** Creates a new instance of Main */
        public Main() 
        {
     
        }
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) 
        {
            // TODO code application logic here
            //App Applet = new Applet();
            NewJPanel Fen = new NewJPanel();
     
        }
     
    }
    Merci

  2. #2
    Expert confirmé
    Avatar de le y@m's
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2005
    Messages
    2 636
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Février 2005
    Messages : 2 636
    Points : 5 943
    Points
    5 943
    Par défaut
    Un JPanel n'est pas une fenêtre, il te faut le placer dans une JFrame par exemple.
    Je ne répondrai à aucune question technique par MP.

    Pensez aux Tutoriels et aux FAQs avant de poster (pour le java il y a aussi JavaSearch), n'oubliez pas non plus la fonction Rechercher.
    Enfin, quand une solution a été trouvée à votre problème
    pensez au tag

    Cours Dvp : http://ydisanto.developpez.com
    Blog : http://yann-disanto.blogspot.com/
    Page perso : http://yann-disanto.fr

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2006
    Messages
    92
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Juin 2006
    Messages : 92
    Points : 61
    Points
    61
    Par défaut
    merci,

    en fait, j'ai encore un peu de mal. C'est quoi alors un JPanel ?


    Merci.

    Geo. (Débutant)

  4. #4
    Membre confirmé Avatar de schniouf
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Décembre 2003
    Messages
    382
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Luxembourg

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Décembre 2003
    Messages : 382
    Points : 474
    Points
    474
    Par défaut
    Citation Envoyé par G_angel
    en fait, j'ai encore un peu de mal. C'est quoi alors un JPanel ?
    JPanel : http://java.sun.com/docs/books/tutor...nts/panel.html

  5. #5
    Membre éclairé Avatar de LeXo
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    1 147
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Janvier 2004
    Messages : 1 147
    Points : 868
    Points
    868
    Par défaut
    JFrame -> ta fenetre
    Layout -> Gestionnaire de placement
    et apres

    JButton, JPanel, JList, JLabel ce sont les composants que tu mets a l'intérieur

    ils ont différents attributs et méthode selon ce que tu as besoin de faire tu choisis l'un ou l'autre..

    Allez bon courage
    Plzzz pas de questions par MP.

Discussions similaires

  1. ASP-Page par défault ne s'affiche pas
    Par goldorak20 dans le forum ASP.NET
    Réponses: 0
    Dernier message: 16/09/2013, 19h19
  2. Mail envoyé par un script n'affiche pas les images
    Par princesse95 dans le forum Administration système
    Réponses: 2
    Dernier message: 16/10/2010, 11h09
  3. impression d'un document en java, image qui ne s'affiche pas
    Par allezlolo dans le forum Documents
    Réponses: 3
    Dernier message: 01/07/2010, 12h25
  4. Réponses: 4
    Dernier message: 11/01/2010, 14h46
  5. Réponses: 0
    Dernier message: 10/06/2009, 10h36

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