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 :

Problème de panel


Sujet :

AWT/Swing Java

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    42
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2006
    Messages : 42
    Par défaut Problème de panel
    Bonjour à tous,

    j'utilise le nouveau netbeans pour développer mon interface graphique cependant j'ai un problème, je suis obligé de cliquer sur ma fenêtre pour voir apparaître mon nouveau jPanel, je pense que c'est un problème de dimension. Mais le nouveau netbeans me paraît un peu flou pour voir les dimensions.
    Voici le code:
    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
    /*
     * MainWindow.java
     *
     * Created on 30 March 2007, 10:39
     */
     
    package portcatcher;
     
    import java.awt.*;
    import javax.swing.JFrame;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.GroupLayout;
    import javax.swing.JPanel;
    import portcatcher.JPanelAdmin;
     
     
     
    public class MainWindow extends JFrame{
     
     
     
        public MainWindow(){
              super("PortCatcher");
              initComponents();
              addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});
              this.setVisible(true);
     
     
     
        }
     
        /** 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() {
            jPanelMain = new javax.swing.JPanel();
            jMenuBar1 = new javax.swing.JMenuBar();
            jMenu1 = new javax.swing.JMenu();
            jMenuAdmin = new javax.swing.JMenuItem();
            jUpDatabase = new javax.swing.JMenuItem();
            jPortViewer = new javax.swing.JMenuItem();
            jMenuQuit = new javax.swing.JMenuItem();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setBackground(new java.awt.Color(255, 255, 255));
            jPanelMain.setBackground(new java.awt.Color(255, 255, 255));
            javax.swing.GroupLayout jPanelMainLayout = new javax.swing.GroupLayout(jPanelMain);
            jPanelMain.setLayout(jPanelMainLayout);
            jPanelMainLayout.setHorizontalGroup(
                jPanelMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 641, Short.MAX_VALUE)
            );
            jPanelMainLayout.setVerticalGroup(
                jPanelMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 487, Short.MAX_VALUE)
            );
     
            jMenuBar1.setBackground(java.awt.Color.lightGray);
            jMenu1.setText("Menu");
            jMenuAdmin.setText("Administration");
            jMenuAdmin.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuAdminActionPerformed(evt);
                }
            });
     
            jMenu1.add(jMenuAdmin);
     
            jUpDatabase.setText("Upgrade Database");
            jUpDatabase.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jUpDatabaseActionPerformed(evt);
                }
            });
     
            jMenu1.add(jUpDatabase);
     
            jPortViewer.setText("Port Viewer");
            jMenu1.add(jPortViewer);
     
            jMenuQuit.setText("quit");
            jMenuQuit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuQuitActionPerformed(evt);
                }
            });
     
            jMenu1.add(jMenuQuit);
     
            jMenuBar1.add(jMenu1);
     
            setJMenuBar(jMenuBar1);
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jPanelMain, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jPanelMain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            );
            pack();
        }// </editor-fold>                        
     
        private void jUpDatabaseActionPerformed(java.awt.event.ActionEvent evt) {                                            
    // TODO add your handling code here:
        }                                           
     
        private void jMenuAdminActionPerformed(java.awt.event.ActionEvent evt) {                                           
     
            if(evt.getSource()==jMenuAdmin){
            jPanelMain.setLayout(new BorderLayout());
            jPanelMain.removeAll();
            JPanelAdmin jPA = new JPanelAdmin(MainWindow.this);
            jPanelMain.add(jPA,BorderLayout.CENTER);
            jPanelMain.repaint();
            jPanelMain.setVisible(true);
            }
     
        }                                          
     
        private void jMenuQuitActionPerformed(java.awt.event.ActionEvent evt) {                                          
         if(evt.getSource()==jMenuQuit) {
             System.exit(0);
         }
        }                                         
     
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
     
                }
     
     
     
            });
        }
     
        private void replace(JPanel jPanelMain, JPanelAdmin jPA) {
            throw new UnsupportedOperationException("Not yet implemented");
        }
     
     
     
        // Variables declaration - do not modify                     
        private javax.swing.JMenu jMenu1;
        private javax.swing.JMenuItem jMenuAdmin;
        private javax.swing.JMenuBar jMenuBar1;
        private javax.swing.JMenuItem jMenuQuit;
        private javax.swing.JPanel jPanelMain;
        private javax.swing.JMenuItem jPortViewer;
        private javax.swing.JMenuItem jUpDatabase;
        // End of variables declaration                   
     
    }
     
    /*
     * JPanelAdmin.java
     *
     * Created on 30 March 2007, 12:54
     */
     
    package portcatcher;
     
    /**
     *
     * @author  id813441
     */
    public class JPanelAdmin extends javax.swing.JPanel {
     
        /**
         * Creates new form JPanelAdmin
         */
        private MainWindow window;
     
        public JPanelAdmin( MainWindow w) {
            window = w;
            initComponents();
            this.setVisible(true);
        }
     
        /** 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() {
            jScheduledU = new javax.swing.JButton();
            jButton1 = new javax.swing.JButton();
     
            setBackground(new java.awt.Color(255, 255, 255));
            setPreferredSize(new java.awt.Dimension(100, 100));
            jScheduledU.setText("Scheduled Update");
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(179, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jScheduledU, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGap(170, 170, 170))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(116, 116, 116)
                    .addComponent(jScheduledU)
                    .addGap(61, 61, 61)
                    .addComponent(jButton1)
                    .addContainerGap(228, Short.MAX_VALUE))
            );
        }// </editor-fold>
     
     
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jScheduledU;
        // End of variables declaration
     
    }
    Merci d'avance,

    Flames

  2. #2
    Membre Expert
    Avatar de natha
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    2 346
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Janvier 2006
    Messages : 2 346
    Par défaut
    Essaie d'appeler la méthode validate() avant setVisible(true) de ta JFrame.

Discussions similaires

  1. Problème update panel et javascript
    Par ralf91 dans le forum ASP.NET
    Réponses: 5
    Dernier message: 08/08/2011, 15h30
  2. problème affichage panel
    Par ktounette dans le forum Débuter
    Réponses: 2
    Dernier message: 17/10/2010, 17h57
  3. Problème de Panel/button group
    Par snapshot1001 dans le forum Interfaces Graphiques
    Réponses: 2
    Dernier message: 26/05/2010, 13h50
  4. Problème de Panel avec AJAX
    Par Tomystique dans le forum ASP.NET
    Réponses: 2
    Dernier message: 22/10/2008, 16h07
  5. [ASP.NET VB.NET] petit problème de panel
    Par Dokho1000 dans le forum ASP.NET
    Réponses: 4
    Dernier message: 23/02/2007, 17h59

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