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 :

manipulation des JFrame et jPanel


Sujet :

Agents de placement/Fenêtres Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Inscrit en
    Février 2006
    Messages
    12
    Détails du profil
    Informations forums :
    Inscription : Février 2006
    Messages : 12
    Par défaut manipulation des JFrame et jPanel
    bonsoir tout le monde ben voila,
    j'ai une frame et plusieurs panels une de ces panel sert a l'authentification je veux quand je clique sur valider et quand touts les donnée sont correcte charger une autre panel par exemple une panel qui contient "bienvenu Mr XXX"
    merci bien de m'aider

  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
    Et que n'arrives-tu pas à faire ?

  3. #3
    Membre confirmé Avatar de CORTEZ
    Profil pro
    Dev : Java/J2EE
    Inscrit en
    Juillet 2007
    Messages
    59
    Détails du profil
    Informations personnelles :
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Dev : Java/J2EE
    Secteur : Service public

    Informations forums :
    Inscription : Juillet 2007
    Messages : 59
    Par défaut
    Bonjour,


    Tout le monde ne sont des programmeurs
    Ils existent des non informaticiens qui veulent apprendre java alors on est la pour les aider.

    ils arrivent des cas où ils peuvent pas avancer.
    Alors il faut penser à ça.

    1ère form
    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
     
    /*
     * Form1.java
     *
     * Created on 28 mai 2008, 10:42
     */
     
    package testd;
     
    /**
     *
     * @author  zbenrhouma
     */
    public class Form1 extends javax.swing.JFrame {
     
        /** Creates new form Form1 */
        public Form1() {
            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() {
     
            jTextField1 = new javax.swing.JTextField();
            jButton1 = new javax.swing.JButton();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
            jButton1.setText("OK");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
     
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .add(93, 93, 93)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jButton1)
                        .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 190, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(117, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .add(63, 63, 63)
                    .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(40, 40, 40)
                    .add(jButton1)
                    .addContainerGap(155, Short.MAX_VALUE))
            );
     
            pack();
        }// </editor-fold>
     
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
            new Form2(this.jTextField1.getText()).setVisible(true);
        }
     
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Form1().setVisible(true);
                }
            });
        }
     
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JTextField jTextField1;
        // End of variables declaration
     
    }


    et voici le code de 2ème from

    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
     
    /*
     * Form2.java
     *
     * Created on 28 mai 2008, 10:43
     */
     
    package testd;
     
    /**
     *
     * @author  zbenrhouma
     */
    public class Form2 extends javax.swing.JFrame {
     
        /** Creates new form Form2 */
        public Form2(String str) {
            initComponents();
            this.jLabel1.setText(this.jLabel1.getText()+ " " + str) ;
        }
     
        /** 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() {
     
            jLabel1 = new javax.swing.JLabel();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
            jLabel1.setText("Bonjour Mr ");
     
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .add(114, 114, 114)
                    .add(jLabel1)
                    .addContainerGap(231, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .add(49, 49, 49)
                    .add(jLabel1)
                    .addContainerGap(237, Short.MAX_VALUE))
            );
     
            pack();
        }// </editor-fold>
     
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Form2("").setVisible(true);
                }
            });
        }
     
        // Variables declaration - do not modify
        private javax.swing.JLabel jLabel1;
        // End of variables declaration
     
    }

  4. #4
    Membre averti
    Inscrit en
    Février 2006
    Messages
    12
    Détails du profil
    Informations forums :
    Inscription : Février 2006
    Messages : 12
    Par défaut
    je détaille j'ai un Jframe et plusieurs Jpanels au démarrage de l'application il y a le jframe et un jpanel cette derniere contient des élément pour l'authentification un champ login et un autre password et le bouton valider je veux quand l'utilisateur saisie des information correct charger une autre panel a la place de celle de l'authentification toute en gardant le même jframe c'est ça mon problème : charger un jpanel a partir d'un autre

  5. #5
    Membre Expert Avatar de guigui5931
    Profil pro
    Chef de projet NTIC
    Inscrit en
    Avril 2006
    Messages
    1 667
    Détails du profil
    Informations personnelles :
    Âge : 38
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2006
    Messages : 1 667
    Par défaut
    Normalement dans ta JFrame tu doit avoir quelque part
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    taJFrame.getContentPane().add(tonPremierPanel);
    Tu devra d'abord enlever le premier panel puis ajouter le second
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    taJFrame.getContentPane().removeAll()
    taJFrame.getContentPane().add(tonSecondPanel);

  6. #6
    Membre averti
    Inscrit en
    Février 2006
    Messages
    12
    Détails du profil
    Informations forums :
    Inscription : Février 2006
    Messages : 12
    Par défaut
    ça marche pas :s
    voila mon code.
    dans le main de ma Jfram :
    g.getContentPane().add(g.b);
    g instance de la jframe et b instance de ma 1ere panel

    dans action performed du bouton valider de ma panel :

    il y a la connexion a la base
    ..
    ...
    if (rs.next())
    {
    g.getContentPane().removeAll(); //g instance de ma Jfram
    g.getContentPane().add(g.choix);//choix instance ma second panel que je veux charger
    }

Discussions similaires

  1. Problème lié à des [ JFrame - JPanel ] + Connexion BDD globale
    Par Saokore91 dans le forum Agents de placement/Fenêtres
    Réponses: 2
    Dernier message: 19/04/2012, 15h35
  2. [xml]manipuler des données xml sous Oracle9i
    Par crazy dans le forum SQL
    Réponses: 7
    Dernier message: 28/02/2004, 11h40
  3. Manipuler des dates...
    Par Ti Jen-tsie dans le forum Langage
    Réponses: 4
    Dernier message: 26/06/2003, 11h46
  4. Manipulation des handle contexte
    Par rockbiker dans le forum DirectX
    Réponses: 1
    Dernier message: 09/05/2003, 18h51
  5. Fonctions de manipulation des chaines et des dates
    Par Fares BELHAOUAS dans le forum Débuter
    Réponses: 3
    Dernier message: 09/11/2002, 22h43

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