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

Agents de placement/Fenêtres Java Discussion :

Le JPanel ne veut pas s'afficher


Sujet :

Agents de placement/Fenêtres Java

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 14
    Points : 8
    Points
    8
    Par défaut Le JPanel ne veut pas s'afficher
    J'ai besoin d'une fenetre modale 410x350 avec un panel à fond vert à l'intérieur, je ne comprends pas pourquoi mais la fenêtre apparait comme il faut mais le panel est invisible. Si quelqun pouvait m'aider, je suis entrain de devenir fou.
    Le plus frustrant est que ce code a été intialement généré avec Netbeans et le prévisualisation marche dans netbeans mais l'executable final me donne encore une fenetre vide.
    Merci d'avance
    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
     
    public class Test2 extends javax.swing.JFrame {
     
    public javax.swing.JDialog connect_dialog;
    private javax.swing.JPanel connect_panel;
     
    public Test2(){
    connect_dialog=new javax.swing.JDialog();
    connect_panel = new javax.swing.JPanel();
    connect_dialog.setAlwaysOnTop(true);
    connect_dialog.setBounds(new java.awt.Rectangle(50, 50, 410, 350));
    connect_dialog.setMinimumSize(new java.awt.Dimension(410, 350));
    connect_dialog.setMinimumSize(new java.awt.Dimension(410, 350));
    connect_dialog.setPreferredSize(new java.awt.Dimension(410, 350));
    connect_dialog.setModal(true);
    connect_dialog.setResizable(false);
    connect_dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
     
    connect_panel.setBackground(new java.awt.Color(39, 163, 101));
    connect_panel.setLayout(null);
     
    javax.swing.GroupLayout connect_dialogLayout = new javax.swing.GroupLayout(connect_dialog.getContentPane());
     
    connect_dialog.getContentPane().setLayout(connect_dialogLayout);
    connect_dialogLayout.setHorizontalGroup(
    connect_dialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(connect_panel, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
    );
    connect_dialogLayout.setVerticalGroup(
    connect_dialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(connect_panel, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
    );
     
     
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 410, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGap(0, 350, Short.MAX_VALUE)
    );
    pack();
    }
     
    public static void main (String[] args){
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new Test2().setVisible(true);
    }
    });
    }
    }

  2. #2
    Expert éminent sénior
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Points : 12 977
    Points
    12 977
    Par défaut
    Bah en même temps tu n'ajoutes rien à ta fenêtre, forcément. Avant de se jeter sur les outil comme le GuiBuilder de Netbeans il faudrait déjà peut être commencer par comprendre comment marche Swing au niveau code, ça évite ce genre de problèmes par la suite.

    Aller zou, direction le tuto swing débutant: http://baptiste-wicht.developpez.com...wing/debutant/
    Hey, this is mine. That's mine. All this is mine. I'm claiming all this as mine. Except that bit. I don't want that bit. But all the rest of this is mine. Hey, this has been a really good day. I've eaten five times, I've slept six times, and I've made a lot of things mine. Tomorrow, I'm gonna see if I can't have sex with something.

  3. #3
    Membre habitué
    Étudiant
    Inscrit en
    Janvier 2009
    Messages
    174
    Détails du profil
    Informations personnelles :
    Âge : 37

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2009
    Messages : 174
    Points : 140
    Points
    140
    Par défaut
    Il faut penser à ajouter le panneau à ta Fenetre avec la méthode setcontentPane().

Discussions similaires

  1. Réponses: 7
    Dernier message: 03/02/2008, 14h08
  2. Une JFrame ne veut pas s'afficher (à partir d'un jar)
    Par Mike888 dans le forum Agents de placement/Fenêtres
    Réponses: 7
    Dernier message: 10/11/2007, 11h50
  3. L'Image ne veut pas s'afficher !
    Par archipel dans le forum Tkinter
    Réponses: 4
    Dernier message: 19/02/2007, 10h47
  4. JList qui ne veut pas s'afficher
    Par hamham dans le forum Composants
    Réponses: 16
    Dernier message: 29/01/2007, 18h20
  5. Image ne veut pas s'afficher
    Par krolineeee dans le forum AWT/Swing
    Réponses: 8
    Dernier message: 18/08/2006, 17h27

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