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

Entrée/Sortie Java Discussion :

Problème d'integration entre les fichiers


Sujet :

Entrée/Sortie Java

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    140
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 140
    Points : 31
    Points
    31
    Par défaut Problème d'integration entre les fichiers
    Bonjour, j'ai deux fichiers. L'un "AxisCamera" (c'est un java class) et l'autre "Integration" (c'est un JFrame). Je souhaiterai intégrer l'affichage de ma caméra (AxisCamera) dans mon panel JPanelPhoto qui se trouve dans le fichier Integration. Mais je ne sais pas comment faire.

    Pouvez-vous m'aider ?

    Merci d'avance.

    AxisCamera:
    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
     
    package Test;
     
     
    import java.net.*; 
    import com.sun.image.codec.jpeg.*; 
    import java.io.*; 
    import java.awt.*; 
    import java.awt.event.*; 
    import java.awt.image.*; 
    import javax.swing.*; 
     
    /**********************************************/
     
    public class AxisCamera extends JPanel implements Runnable { 
     
        public boolean useMJPGStream = true; 
        public String jpgURL="http://10.104.100.101/axis-cgi/jpg/image.cgi?resolution=704x480"; 
        public String mjpgURL="http://10.104.100.101/axis-cgi/mjpg/video.cgi?resolution=704x480";  //URL de connexion
        DataInputStream dis;    //flux de données d'éntrée 
        private Image image=null;   
        public Dimension imageSize = null; 
        public boolean connected = false; 
        private boolean initCompleted = false; 
        HttpURLConnection huc=null;     
        Component parent;
     
     
        /** Crée une nouvelle instance de AxisCamera */ 
        AxisCamera (Component parent_) { 
            parent = parent_; 
            //initComponents();     
        }
     
     
     
     
        public void connect(){ 
            try{ 
                URL u = new URL(useMJPGStream?mjpgURL:jpgURL); 
                huc = (HttpURLConnection) u.openConnection(); 
                //System.out.println(huc.getContentType()); 
                InputStream is = huc.getInputStream(); 
                connected = true; 
                BufferedInputStream bis = new BufferedInputStream(is); 
                dis= new DataInputStream(bis); 
                if (!initCompleted) initDisplay(); 
            }catch(IOException e){ //Si aucune connexion n'existe, on attend pour se reconnecter à nouveau 
                try{ 
                    huc.disconnect(); 
                    Thread.sleep(60); 
                }catch(InterruptedException ie){huc.disconnect();connect();} 
                    connect(); 
            }catch(Exception e){;} 
        } 
     
        public void initDisplay(){ //Configuration de l'affichage
            if (useMJPGStream)readMJPGStream(); 
            else {readJPG();disconnect();} 
            imageSize = new Dimension(image.getWidth(this), image.getHeight(this)); 
              //centrage de la fenêtre
            Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            this.setLocation((screenSize.width-this.getWidth())/2, (screenSize.height-this.getHeight())/2);
            setPreferredSize(imageSize); 
            parent.setSize(imageSize); 
     
            parent.validate(); 
            initCompleted = true; 
        } 
     
        public void disconnect(){ 
        try{ 
            if(connected){ 
            dis.close(); 
            connected = false; 
        } 
        }catch(Exception e){;} 
        } 
     
     
        public void paint(Graphics g) { //On fixe l'image dans le Panel
            if (image != null) 
            g.drawImage(image, 0, 0, this); 
        } 
     
     
        public void readStream(){ //Lecture des flux continu
        try{ 
            if (useMJPGStream){ 
            while(true){ 
            readMJPGStream(); 
            parent.repaint(); 
            } 
        } 
        else{ 
            while(true){ 
            connect(); 
            readJPG(); 
            parent.repaint(); 
            disconnect(); 
     
            } 
        } 
     
        }catch(Exception e){;} 
        } 
     
     
        public void readMJPGStream(){ //lecture du flux mjpg 
            readLine(3,dis); //Lecture à partir de la 3ème ligne
            readJPG(); 
            readLine(2,dis); //on retire les 2 dernières lignes
        }
     
        public void readJPG(){ //Lecture de l'image jpeg incorporée 
        try{ 
            JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(dis); 
            image = decoder.decodeAsBufferedImage(); 
            }catch(Exception e){e.printStackTrace();disconnect();} 
        } 
     
        public void readLine(int n, DataInputStream dis){ //utilisée pour sauter les lignes d'en-tête
        for (int i=0; i<n;i++){ 
            readLine(dis); 
        } 
        } 
        public void readLine(DataInputStream dis){ 
        try{ 
            boolean end = false; 
            String lineEnd = "\n"; //On suppose que la fin de la ligne est marqué
            byte[] lineEndBytes = lineEnd.getBytes(); 
            byte[] byteBuf = new byte[lineEndBytes.length]; 
     
            while(!end){ 
            dis.read(byteBuf,0,lineEndBytes.length); 
            String t = new String(byteBuf); 
            //System.out.print(t); //décommenter pour voir à quoi ressemble les lignes
            if(t.equals(lineEnd)) end=true; 
        } 
        }catch(Exception e){e.printStackTrace();} 
     
     
        } 
        public void run() { 
            connect(); 
            readStream(); 
        } 
     
     
     
        public static void main(String[] args) { 
            JFrame jframe = new JFrame(); 
            jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
            AxisCamera axPanel = new AxisCamera(jframe); 
            new Thread(axPanel).start(); 
            jframe.getContentPane().add(axPanel); 
            jframe.pack(); 
            jframe.show(); 
            /* java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new JFrame().setVisible(true);
                }
            });*/
        } 
     
     
     
    }
    Integration:
    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
     
    package Test;
     
    import java.awt.Dimension;
    import javax.swing.*;
     
    /**
     *
     * @author  GRESLON Jérémy
     */
    public class Integration extends javax.swing.JFrame {
     
        /** Creates new form Integration */
        public Integration() {
            initComponents();
     
            /*AxisCamera cam = new AxisCamera();
            cam.run();*/
     
             //centrage de la fenêtre
            Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            this.pack();
            this.setLocation((screenSize.width - this.getWidth()) / 2, (screenSize.height - this.getHeight()) / 2);
        }
     
        /** 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() {
     
            jPanelPhoto = new javax.swing.JPanel();
            jButtonBadge = new javax.swing.JButton();
            jPanel1 = new javax.swing.JPanel();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jPanelAlarme = new javax.swing.JPanel();
            jButtonAlarme = new javax.swing.JButton();
            jLabelAutorisation = new javax.swing.JLabel();
            jToggleButtonPorte = new javax.swing.JToggleButton();
            jSeparator1 = new javax.swing.JSeparator();
            jLabel4 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jTextFieldAutorisation = new javax.swing.JTextField();
            jTextFieldNumBadge = new javax.swing.JTextField();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
            jPanelPhoto.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
     
            javax.swing.GroupLayout jPanelPhotoLayout = new javax.swing.GroupLayout(jPanelPhoto);
            jPanelPhoto.setLayout(jPanelPhotoLayout);
            jPanelPhotoLayout.setHorizontalGroup(
                jPanelPhotoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 294, Short.MAX_VALUE)
            );
            jPanelPhotoLayout.setVerticalGroup(
                jPanelPhotoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 276, Short.MAX_VALUE)
            );
     
            jButtonBadge.setText("Passage du badge");
            jButtonBadge.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButtonBadgeActionPerformed(evt);
                }
            });
     
            jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
     
            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 297, Short.MAX_VALUE)
            );
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 276, Short.MAX_VALUE)
            );
     
            jLabel1.setText("Caméra extérieure:");
     
            jLabel2.setText("Photo de l'utilisateur:");
     
            jPanelAlarme.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
     
            javax.swing.GroupLayout jPanelAlarmeLayout = new javax.swing.GroupLayout(jPanelAlarme);
            jPanelAlarme.setLayout(jPanelAlarmeLayout);
            jPanelAlarmeLayout.setHorizontalGroup(
                jPanelAlarmeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 105, Short.MAX_VALUE)
            );
            jPanelAlarmeLayout.setVerticalGroup(
                jPanelAlarmeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 100, Short.MAX_VALUE)
            );
     
            jButtonAlarme.setText("Alarme");
            jButtonAlarme.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButtonAlarmeActionPerformed(evt);
                }
            });
     
            jLabelAutorisation.setText("La porte est fermée");
     
            jToggleButtonPorte.setText("Ouverture/Fermeture porte");
            jToggleButtonPorte.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jToggleButtonPorteActionPerformed(evt);
                }
            });
     
            jLabel4.setText("Simulation de la porte d'entrée:");
     
            jLabel3.setText("Intervention de la sécurité:");
     
            jTextFieldNumBadge.setEditable(false);
            jTextFieldNumBadge.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jTextFieldNumBadgeActionPerformed(evt);
                }
            });
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(122, 122, 122)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jPanel1, 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.LEADING)
                            .addComponent(jTextFieldNumBadge, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                            .addComponent(jTextFieldAutorisation, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                            .addComponent(jLabel1)))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(63, 63, 63)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jPanelPhoto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(80, 80, 80)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jPanelAlarme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGroup(layout.createSequentialGroup()
                                                    .addGap(10, 10, 10)
                                                    .addComponent(jButtonAlarme, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                            .addGap(66, 66, 66))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 54, Short.MAX_VALUE)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                .addComponent(jToggleButtonPorte, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jSeparator1)
                                                .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabelAutorisation, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGap(36, 36, 36)))
                                    .addContainerGap(19, Short.MAX_VALUE))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel2)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 264, Short.MAX_VALUE)
                                    .addComponent(jLabel3)
                                    .addGap(76, 76, 76))))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addGap(140, 140, 140)
                            .addComponent(jButtonBadge, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(340, 340, 340))))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(42, 42, 42)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(jLabel2)
                        .addComponent(jLabel3))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jPanelAlarme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jButtonAlarme, javax.swing.GroupLayout.PREFERRED_SIZE, 68, 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.RELATED)
                            .addComponent(jLabel4)
                            .addGap(18, 18, 18)
                            .addComponent(jLabelAutorisation, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jToggleButtonPorte))
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanelPhoto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 30, Short.MAX_VALUE)
                            .addComponent(jTextFieldNumBadge, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(3, 3, 3)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButtonBadge)
                        .addComponent(jTextFieldAutorisation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap())
            );
     
            pack();
        }// </editor-fold>                        
     
        private void jButtonBadgeActionPerformed(java.awt.event.ActionEvent evt) {                                             
            // TODO add your handling code here:
     
             //Connexion FTP
            TestFTP test = new TestFTP();
            test.Connexion("127.0.0.1", 21); //hôte + port auquel on veut se connecter
     
            //Affichage de la photo dans le panel          
            ImageIcon icone = new ImageIcon("C:\\Documents and Settings\\GRESLON Jérémy\\Mes documents\\Photos_telechargees\\25.jpg");
            JLabel photo = new JLabel (icone);  
            photo.setSize(jPanelPhoto.getWidth(), jPanelPhoto.getHeight());
            jPanelPhoto.add(photo);
            jPanelPhoto.repaint();
            this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
     
            /*Autorisation aut = new Autorisation();
            aut.Connection();*/
    }                                            
     
        private void jButtonAlarmeActionPerformed(java.awt.event.ActionEvent evt) {                                              
            // TODO add your handling code here:
     
    }                                             
     
        private void jToggleButtonPorteActionPerformed(java.awt.event.ActionEvent evt) {                                                   
            // TODO add your handling code here:
     
            Porte porte = new Porte();
            AbstractButton bouton = (AbstractButton) evt.getSource();
            boolean selected = bouton.getModel().isSelected();
            if (selected) {
                porte.PorteOuverte();
            } else {
                porte.PorteFermee();
            }
        }                                                  
     
        private void jTextFieldNumBadgeActionPerformed(java.awt.event.ActionEvent evt) {                                                   
            // TODO add your handling code here:
        }                                                  
     
     
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Integration().setVisible(true);
                }
            });
        }
     
        // Variables declaration - do not modify                     
        private javax.swing.JButton jButtonAlarme;
        private javax.swing.JButton jButtonBadge;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        public static javax.swing.JLabel jLabelAutorisation;
        private javax.swing.JPanel jPanel1;
        private javax.swing.JPanel jPanelAlarme;
        private javax.swing.JPanel jPanelPhoto;
        private javax.swing.JSeparator jSeparator1;
        public static javax.swing.JTextField jTextFieldAutorisation;
        public static javax.swing.JTextField jTextFieldNumBadge;
        private javax.swing.JToggleButton jToggleButtonPorte;
        // End of variables declaration                   
     
    }

  2. #2
    Membre émérite
    Avatar de gifffftane
    Profil pro
    Inscrit en
    Février 2007
    Messages
    2 354
    Détails du profil
    Informations personnelles :
    Localisation : France, Loire (Rhône Alpes)

    Informations forums :
    Inscription : Février 2007
    Messages : 2 354
    Points : 2 582
    Points
    2 582
    Par défaut
    On dirait que tu utilises Netbeans...

    Pour placer ta caméra dans le jPanelPhoto il faut d'une façon ou d'une autre faire simplement jPanelPhote.add(uneAxisCamera).

    J'ai un peu de mal dans ton code à voir qui a le rôle principal... il faudrait que tu détermines qui, de la caméra ou de la fenêtre, a le rôle d'organisateur. Qui, par exemple, crée la caméra et la fenêtre, j'ai l'impression que chacun se crée dans son coin, pour ainsi dire...

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    140
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 140
    Points : 31
    Points
    31
    Par défaut
    au départ, le fichier AxisCamera créer sa propre fenêtre car c'était un fichier de test. Mais justement je souhaiterai que l'image de la caméra s'affiche seulement dans le jPanelPhoto du fichier Integration. Et donc, supprimer la fenêtre qui est créée dans le fichier AxisCamera. Mais je ne sais pas comment faire. Pouvez-vous m'aider s'il vous plait?

    Merci encore.

  4. #4
    Membre émérite
    Avatar de gifffftane
    Profil pro
    Inscrit en
    Février 2007
    Messages
    2 354
    Détails du profil
    Informations personnelles :
    Localisation : France, Loire (Rhône Alpes)

    Informations forums :
    Inscription : Février 2007
    Messages : 2 354
    Points : 2 582
    Points
    2 582
    Par défaut
    Comme tu utilise Netbeans et Matisse, le plus simple serait de réserver un JPanel dans Integration, pour y mettre ton AxisCamera.

    Pourrais-tu me dire quel JPanel tu voudrais utiliser ?

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    140
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 140
    Points : 31
    Points
    31
    Par défaut
    je voudrais utiliser jPanelPhoto

    Merci encore pour l'aide

  6. #6
    Membre émérite
    Avatar de gifffftane
    Profil pro
    Inscrit en
    Février 2007
    Messages
    2 354
    Détails du profil
    Informations personnelles :
    Localisation : France, Loire (Rhône Alpes)

    Informations forums :
    Inscription : Février 2007
    Messages : 2 354
    Points : 2 582
    Points
    2 582
    Par défaut
    Oui, mais à ce que je peux voir il y a déjà quelque chose dans jPanelPhoto (un truc qui s'appelle photo). Il serait possible de le faire, selon la méthode que je t'ai indiquée plus haut, mais comme tu semble un peu paumé...

    Il faudrait que tu places dans ta GUI faites avec Matisse un panneau, dans lequel tu ne mets rien avec Matisse, et dans lequel, par ton propre code, tu ne mettras que un AxisCamera.

  7. #7
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    140
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 140
    Points : 31
    Points
    31
    Par défaut
    non pardon pour l'instant c'est dans le jPanel1 que je veux afficher ma caméra. Mais que dois-je ajouter ou supprimer dans mes 2 fichiers? Car, si je fais un jPanel1.add(); je met quoi dans mes paramètres? Merci encore.

  8. #8
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    140
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 140
    Points : 31
    Points
    31
    Par défaut
    j'ai fait ceci dans le fichier Integrateur:

    AxisCamera cam = new AxisCamera();
    jPanel1.add(cam);

    mais je ne sais pas si c'est correct, car j'ai une erreur sur AxisCamera(), il me dit qu'il n'y a pas de constructeur.

    merci bien.

  9. #9
    Membre émérite
    Avatar de gifffftane
    Profil pro
    Inscrit en
    Février 2007
    Messages
    2 354
    Détails du profil
    Informations personnelles :
    Localisation : France, Loire (Rhône Alpes)

    Informations forums :
    Inscription : Février 2007
    Messages : 2 354
    Points : 2 582
    Points
    2 582
    Par défaut
    Il me semble que, avant de te lancer dans des interfaces graphiques, tu devrais apprendre les bases du langage.

    Oui, c'est la bonne piste que de faire panel.add(camera). Si le new AxisCamera() ne fonctionne pas, c'est simplement parce qu'il n'y a pas de constructeur sans argument. Soit tu fais new AxisCamera(jPanel1), soit tu supprimes le paramètre dans le constructeur, ce paramètre ne sert à rien.

    Et pour la prochaine fois consulte la doc.

  10. #10
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    140
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 140
    Points : 31
    Points
    31
    Par défaut
    j'ai fait ceci, est-ce que vous pensez que ça pourrait fonctionner? Car je ne peux pas tester, je n'ai pas la cam sur place.

    Voici mon premier fichier GestionCamAxis:
    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
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package Test;
     
    import java.net.*; 
    import com.sun.image.codec.jpeg.*; 
    import java.io.*; 
    import java.awt.*; 
    import java.awt.event.*; 
    import java.awt.image.*; 
    import javax.swing.*; 
    /**
     *
     * @author GRESLON Jérémy
     */
    public class GestionCamAxis extends JPanel {
     
        public boolean useMJPGStream = true; 
        public String jpgURL="http://10.104.100.101/axis-cgi/jpg/image.cgi?resolution=704x480"; 
        public String mjpgURL="http://10.104.100.101/axis-cgi/mjpg/video.cgi?resolution=704x480";  //URL de connexion
        DataInputStream dis;    //flux de données d'éntrée 
        private Image image=null;   
        public Dimension imageSize = null; 
        public boolean connected = false; 
        private boolean initCompleted = false; 
        HttpURLConnection huc=null;     
        Component parent;
     
        /*GestionCamAxis (Component parent_) { 
            parent = parent_; 
            //initComponents();     
        }*/
     
         public void connect(){ 
            try{ 
                URL u = new URL(useMJPGStream?mjpgURL:jpgURL); 
                huc = (HttpURLConnection) u.openConnection(); 
                //System.out.println(huc.getContentType()); 
                InputStream is = huc.getInputStream(); 
                connected = true; 
                BufferedInputStream bis = new BufferedInputStream(is); 
                dis= new DataInputStream(bis); 
                if (!initCompleted) initDisplay(); 
            }catch(IOException e){ //Si aucune connexion n'existe, on attend pour se reconnecter à nouveau 
                try{ 
                    huc.disconnect(); 
                    Thread.sleep(60); 
                }catch(InterruptedException ie){huc.disconnect();connect();} 
                    connect(); 
            }catch(Exception e){;} 
        } 
     
        public void initDisplay(){ //Configuration de l'affichage
            if (useMJPGStream)readMJPGStream(); 
            else {readJPG();disconnect();} 
            //imageSize = new Dimension(image.getWidth(this), image.getHeight(this)); 
              //centrage de la fenêtre
            Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            //this.setLocation((screenSize.width-this.getWidth())/2, (screenSize.height-this.getHeight())/2);
            //setPreferredSize(imageSize); 
            parent.setSize(imageSize); 
     
            parent.validate(); 
            initCompleted = true; 
        } 
     
        public void disconnect(){ 
        try{ 
            if(connected){ 
            dis.close(); 
            connected = false; 
        } 
        }catch(Exception e){;} 
        } 
     
     
        public void paint(Graphics g) { //On fixe l'image dans le Panel
            //if (image != null) 
            //g.drawImage(image, 0, 0, this); 
        } 
     
     
        public void readStream(){ //Lecture des flux continu
        try{ 
            if (useMJPGStream){ 
            while(true){ 
            readMJPGStream(); 
            parent.repaint(); 
            } 
        } 
        else{ 
            while(true){ 
            connect(); 
            readJPG(); 
            parent.repaint(); 
            disconnect(); 
     
            } 
        } 
     
        }catch(Exception e){;} 
        } 
     
     
        public void readMJPGStream(){ //lecture du flux mjpg 
            readLine(3,dis); //Lecture à partir de la 3ème ligne
            readJPG(); 
            readLine(2,dis); //on retire les 2 dernières lignes
        }
     
        public void readJPG(){ //Lecture de l'image jpeg incorporée 
        try{ 
            JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(dis); 
            image = decoder.decodeAsBufferedImage(); 
            }catch(Exception e){e.printStackTrace();disconnect();} 
        } 
     
        public void readLine(int n, DataInputStream dis){ //utilisée pour sauter les lignes d'en-tête
        for (int i=0; i<n;i++){ 
            readLine(dis); 
        } 
        } 
        public void readLine(DataInputStream dis){ 
        try{ 
            boolean end = false; 
            String lineEnd = "\n"; //On suppose que la fin de la ligne est marqué
            byte[] lineEndBytes = lineEnd.getBytes(); 
            byte[] byteBuf = new byte[lineEndBytes.length]; 
     
            while(!end){ 
            dis.read(byteBuf,0,lineEndBytes.length); 
            String t = new String(byteBuf); 
            //System.out.print(t); //décommenter pour voir à quoi ressemble les lignes
            if(t.equals(lineEnd)) end=true; 
        } 
        }catch(Exception e){e.printStackTrace();} 
     
     
        } 
        public void run() { 
            connect(); 
            readStream(); 
        } 
     
     
     
    }
    Et mon second fichier (le JFrame) d'où je fais appel à mon fichier GestionCamAxis:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    GestionCamAxis cam = new GestionCamAxis();
    jPanel1.add(cam);
    Merci encore.

  11. #11
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    140
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 140
    Points : 31
    Points
    31
    Par défaut
    j'ai fait ceci, je n'ai pas d'erreur mais ma caméra ne s'affiche pas.

    1er fichier: AxisCamera
    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
    package Test;
     
     
    import java.net.*; 
    import com.sun.image.codec.jpeg.*; 
    import java.io.*; 
    import java.awt.*; 
    import java.awt.event.*; 
    import java.awt.image.*; 
    import javax.swing.*; 
     
    /**********************************************/
     
    public class AxisCamera extends JPanel implements Runnable { 
     
        public boolean useMJPGStream = true; 
        public String jpgURL="http://10.104.100.101/axis-cgi/jpg/image.cgi?resolution=704x480"; 
        public String mjpgURL="http://10.104.100.101/axis-cgi/mjpg/video.cgi?resolution=704x480";  //URL de connexion
        DataInputStream dis;    //flux de données d'éntrée 
        private Image image=null;   
        public Dimension imageSize = null; 
        public boolean connected = false; 
        private boolean initCompleted = false; 
        HttpURLConnection huc=null;     
        Component parent;
     
     
        /** Crée une nouvelle instance de AxisCamera */ 
        AxisCamera (/*Component parent_*/) { 
            //parent = parent_; 
            //initComponents();     
        }
     
     
     
     
        public void connect(){ 
            try{ 
                URL u = new URL(useMJPGStream?mjpgURL:jpgURL); 
                huc = (HttpURLConnection) u.openConnection(); 
                //System.out.println(huc.getContentType()); 
                InputStream is = huc.getInputStream(); 
                connected = true; 
                BufferedInputStream bis = new BufferedInputStream(is); 
                dis= new DataInputStream(bis); 
                if (!initCompleted) initDisplay(); 
            }catch(IOException e){ //Si aucune connexion n'existe, on attend pour se reconnecter à nouveau 
                try{ 
                    huc.disconnect(); 
                    Thread.sleep(60); 
                }catch(InterruptedException ie){huc.disconnect();connect();} 
                    connect(); 
            }catch(Exception e){;} 
        } 
     
        public void initDisplay(){ //Configuration de l'affichage
            if (useMJPGStream)readMJPGStream(); 
            else {readJPG();disconnect();} 
            imageSize = new Dimension(image.getWidth(this), image.getHeight(this)); 
              //centrage de la fenêtre
            Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            this.setLocation((screenSize.width-this.getWidth())/2, (screenSize.height-this.getHeight())/2);
            setPreferredSize(imageSize); 
            parent.setSize(imageSize); 
     
            parent.validate(); 
            initCompleted = true; 
        } 
     
        public void disconnect(){ 
        try{ 
            if(connected){ 
            dis.close(); 
            connected = false; 
        } 
        }catch(Exception e){;} 
        } 
     
     
        public void paint(Graphics g) { //On fixe l'image dans le Panel
            if (image != null) 
            g.drawImage(image, 0, 0, this); 
        } 
     
     
        public void readStream(){ //Lecture des flux continu
        try{ 
            if (useMJPGStream){ 
            while(true){ 
            readMJPGStream(); 
            parent.repaint(); 
            } 
        } 
        else{ 
            while(true){ 
            connect(); 
            readJPG(); 
            parent.repaint(); 
            disconnect(); 
     
            } 
        } 
     
        }catch(Exception e){;} 
        } 
     
     
        public void readMJPGStream(){ //lecture du flux mjpg 
            readLine(3,dis); //Lecture à partir de la 3ème ligne
            readJPG(); 
            readLine(2,dis); //on retire les 2 dernières lignes
        }
     
        public void readJPG(){ //Lecture de l'image jpeg incorporée 
        try{ 
            JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(dis); 
            image = decoder.decodeAsBufferedImage(); 
            }catch(Exception e){e.printStackTrace();disconnect();} 
        } 
     
        public void readLine(int n, DataInputStream dis){ //utilisée pour sauter les lignes d'en-tête
        for (int i=0; i<n;i++){ 
            readLine(dis); 
        } 
        } 
        public void readLine(DataInputStream dis){ 
        try{ 
            boolean end = false; 
            String lineEnd = "\n"; //On suppose que la fin de la ligne est marqué
            byte[] lineEndBytes = lineEnd.getBytes(); 
            byte[] byteBuf = new byte[lineEndBytes.length]; 
     
            while(!end){ 
            dis.read(byteBuf,0,lineEndBytes.length); 
            String t = new String(byteBuf); 
            //System.out.print(t); //décommenter pour voir à quoi ressemble les lignes
            if(t.equals(lineEnd)) end=true; 
        } 
        }catch(Exception e){e.printStackTrace();} 
     
     
        } 
        public void run() { 
            connect(); 
            readStream(); 
        } 
     
     
     
        public static void main(String[] args) { 
     
     
            /* java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new JFrame().setVisible(true);
                }
            });*/
        } 
     
     
     
    }
    mon 2ème fichier: GestionSystemeGardien (JFrame):
    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
    package Test;
     
    import java.awt.Dimension;
    import java.util.*;
    import java.util.logging.*;
    import javax.swing.*;
    import sun.audio.AudioPlayer;
     
     
    /**
     *
     * @author  GRESLON Jérémy
     */
    public class GestionSystemeGardien extends javax.swing.JFrame {
     
        /** Creates new form Integration */
        public GestionSystemeGardien() {
            initComponents();
     
     
            AxisCamera cam = new AxisCamera();
            jPanelCam.add(cam);
     
             //centrage de la fenêtre
            Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            this.pack();
            this.setLocation((screenSize.width - this.getWidth()) / 2, (screenSize.height - this.getHeight()) / 2);
        }
     
        /** 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() {
     
            jPanelPhoto = new javax.swing.JPanel();
            jButtonBadge = new javax.swing.JButton();
            jPanelCam = new javax.swing.JPanel();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jPanelAlarme = new javax.swing.JPanel();
            jButtonAlarme = new javax.swing.JButton();
            jLabelAutorisation = new javax.swing.JLabel();
            jToggleButtonPorte = new javax.swing.JToggleButton();
            jSeparator1 = new javax.swing.JSeparator();
            jLabel4 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jTextFieldAutorisation = new javax.swing.JTextField();
            jTextFieldNumBadge = new javax.swing.JTextField();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
            jPanelPhoto.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
     
            javax.swing.GroupLayout jPanelPhotoLayout = new javax.swing.GroupLayout(jPanelPhoto);
            jPanelPhoto.setLayout(jPanelPhotoLayout);
            jPanelPhotoLayout.setHorizontalGroup(
                jPanelPhotoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 294, Short.MAX_VALUE)
            );
            jPanelPhotoLayout.setVerticalGroup(
                jPanelPhotoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 276, Short.MAX_VALUE)
            );
     
            jButtonBadge.setText("Passage du badge");
            jButtonBadge.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButtonBadgeActionPerformed(evt);
                }
            });
     
            jPanelCam.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
     
            javax.swing.GroupLayout jPanelCamLayout = new javax.swing.GroupLayout(jPanelCam);
            jPanelCam.setLayout(jPanelCamLayout);
            jPanelCamLayout.setHorizontalGroup(
                jPanelCamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 297, Short.MAX_VALUE)
            );
            jPanelCamLayout.setVerticalGroup(
                jPanelCamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 276, Short.MAX_VALUE)
            );
     
            jLabel1.setText("Caméra extérieure:");
     
            jLabel2.setText("Photo de l'utilisateur:");
     
            jPanelAlarme.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
     
            javax.swing.GroupLayout jPanelAlarmeLayout = new javax.swing.GroupLayout(jPanelAlarme);
            jPanelAlarme.setLayout(jPanelAlarmeLayout);
            jPanelAlarmeLayout.setHorizontalGroup(
                jPanelAlarmeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 105, Short.MAX_VALUE)
            );
            jPanelAlarmeLayout.setVerticalGroup(
                jPanelAlarmeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 100, Short.MAX_VALUE)
            );
     
            jButtonAlarme.setText("Alarme");
            jButtonAlarme.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButtonAlarmeActionPerformed(evt);
                }
            });
     
            jLabelAutorisation.setText("La porte est fermée");
     
            jToggleButtonPorte.setText("Ouverture/Fermeture porte");
            jToggleButtonPorte.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jToggleButtonPorteActionPerformed(evt);
                }
            });
     
            jLabel4.setText("Simulation de la porte d'entrée:");
     
            jLabel3.setText("Intervention de la sécurité:");
     
            jTextFieldNumBadge.setEditable(false);
            jTextFieldNumBadge.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jTextFieldNumBadgeActionPerformed(evt);
                }
            });
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(122, 122, 122)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jPanelCam, 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.LEADING)
                            .addComponent(jTextFieldNumBadge, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                            .addComponent(jTextFieldAutorisation, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                            .addComponent(jLabel1)))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(63, 63, 63)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jPanelPhoto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(80, 80, 80)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jPanelAlarme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGroup(layout.createSequentialGroup()
                                                    .addGap(10, 10, 10)
                                                    .addComponent(jButtonAlarme, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                            .addGap(66, 66, 66))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 54, Short.MAX_VALUE)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                .addComponent(jToggleButtonPorte, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jSeparator1)
                                                .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabelAutorisation, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGap(36, 36, 36)))
                                    .addContainerGap(19, Short.MAX_VALUE))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel2)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 264, Short.MAX_VALUE)
                                    .addComponent(jLabel3)
                                    .addGap(76, 76, 76))))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addGap(140, 140, 140)
                            .addComponent(jButtonBadge, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(340, 340, 340))))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(42, 42, 42)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(jLabel2)
                        .addComponent(jLabel3))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jPanelAlarme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jButtonAlarme, javax.swing.GroupLayout.PREFERRED_SIZE, 68, 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.RELATED)
                            .addComponent(jLabel4)
                            .addGap(18, 18, 18)
                            .addComponent(jLabelAutorisation, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jToggleButtonPorte))
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jPanelCam, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanelPhoto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 30, Short.MAX_VALUE)
                            .addComponent(jTextFieldNumBadge, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(3, 3, 3)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButtonBadge)
                        .addComponent(jTextFieldAutorisation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap())
            );
     
            pack();
        }// </editor-fold>                        
     
        private void jButtonBadgeActionPerformed(java.awt.event.ActionEvent evt) {                                             
            // TODO add your handling code here:
     
            GestionBdD BdD = new GestionBdD();
            BdD.Connection();
     
             //Connexion FTP
            GestionDownloadPhoto test = new GestionDownloadPhoto();
            test.Connexion("127.0.0.1", 21); //hôte + port auquel on veut se connecter
     
     
            //Affichage de la photo dans le panel          
            ImageIcon icone = new ImageIcon("C:\\Documents and Settings\\GRESLON Jérémy\\Mes documents\\Photos_telechargees\\25.jpg");
            JLabel photo = new JLabel (icone);  
            photo.setSize(jPanelPhoto.getWidth(), jPanelPhoto.getHeight());
            jPanelPhoto.add(photo);
            jPanelPhoto.repaint();
            this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
     
             try {
                GestionSonore audioPlayer = new GestionSonore("file:/C:/Documents and Settings/GRESLON Jérémy/Mes documents/Photos_employes/Windows XP Démarrage.wav");
     
                audioPlayer.start();      
            } catch (Exception ex) {
                Logger.getLogger(AudioPlayer.class.getName()).log(Level.SEVERE, null, ex);
            }                   //GestionSonore
    }                                            
     
        private void jButtonAlarmeActionPerformed(java.awt.event.ActionEvent evt) {                                              
            // TODO add your handling code here:
     
    }                                             
     
        private void jToggleButtonPorteActionPerformed(java.awt.event.ActionEvent evt) {                                                   
            // TODO add your handling code here:
     
            GestionPortique porte = new GestionPortique();
            AbstractButton bouton = (AbstractButton) evt.getSource();
            boolean selected = bouton.getModel().isSelected();
            if (selected) {
                porte.PorteOuverte();
            } else {
                porte.PorteFermee();
            }
        }                                                  
     
        private void jTextFieldNumBadgeActionPerformed(java.awt.event.ActionEvent evt) {                                                   
            // TODO add your handling code here:
        }                                                  
     
     
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new GestionSystemeGardien().setVisible(true);
                }
            });
        }
     
        // Variables declaration - do not modify                     
        private javax.swing.JButton jButtonAlarme;
        private javax.swing.JButton jButtonBadge;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        public static javax.swing.JLabel jLabelAutorisation;
        private javax.swing.JPanel jPanelAlarme;
        private javax.swing.JPanel jPanelCam;
        private javax.swing.JPanel jPanelPhoto;
        private javax.swing.JSeparator jSeparator1;
        public static javax.swing.JTextField jTextFieldAutorisation;
        public static javax.swing.JTextField jTextFieldNumBadge;
        private javax.swing.JToggleButton jToggleButtonPorte;
        // End of variables declaration                   
    }
    Merci encore

Discussions similaires

  1. CMake projet C/C++, problème de liens entre les fichiers
    Par LaMainSurLeKatana dans le forum C++
    Réponses: 1
    Dernier message: 16/08/2010, 15h53
  2. Recherche d'un outil analyser les dépendances entres les fichiers d'un site web PHP
    Par nkdb dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 5
    Dernier message: 06/01/2007, 20h38
  3. Labyrinthe : problème de lien entres les cases
    Par spax dans le forum Prolog
    Réponses: 3
    Dernier message: 20/12/2006, 16h05
  4. [HTML & CSS] Problème d'espace entre les <li>
    Par Yoshidu62 dans le forum Mise en page CSS
    Réponses: 5
    Dernier message: 17/05/2006, 18h53
  5. [Upload] Problème de lien entre mes fichiers
    Par temperature dans le forum Langage
    Réponses: 18
    Dernier message: 25/04/2006, 12h15

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