Bonjour ,

mon projet consiste à réaliser une application de scan réseau et de port
mes problèmes :
1/ au niveau de l'interface scan de port le menu est visible au début mais lorsque je démarre le scan , le sous menu devient invisible
2/ comment je fait l'opération d'enregistrer sous des listes des ports retouvés (dans le textarea).
3/ dans le menu édition j'ai les opération couper, copier et coller . est ce que je doit mettre dans chaque évenement
4/au niveau de l'interface scan réseau, j'ai fait l'affichage des adresses ip , hostname et adresse mac. comment je peut afficher directement l'adresse ip de la machine retrouvée dans champ adresse ip de l'interface scan de port.

voici mes codes :


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
 
package lanscanner;
 
 
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
 
 
public class PortScanner extends JFrame{
 
	Socket s;
	int startPort,endPort;
	Label l1;
	TextField hostName,fromPort,toPort;
	TextArea log;
	Label host,from,to,label;
	Button scan,reset;
	int fp,tp;
	String h;
	static boolean close=false;
	Dialog d;
 
	JFrame f=new JFrame("Scanner de ports");
	JMenuBar barre = new JMenuBar();
 
	public PortScanner(){
 
 
		/*      MENU     */
 
		JMenuBar barre = new JMenuBar();
		JMenu fichier = new JMenu("Fichier");
		JMenu edition = new JMenu("Edition");
		JMenu aide = new JMenu("Aide");
 
		JMenuItem enregistrer = new JMenuItem("Enregistrer sous...");
		JMenuItem quitter = new JMenuItem("Quitter");
		JMenuItem couper = new JMenuItem("Couper");
		JMenuItem copier = new JMenuItem("Copier");
		JMenuItem coller = new JMenuItem("Coller");
		JMenuItem about = new JMenuItem("About");
 
		barre.add(fichier);
		barre.add(edition);
		barre.add(aide);
 
		fichier.add(enregistrer);
		fichier.addSeparator();
		fichier.add(quitter);
 
		edition.add(couper);
		edition.add(copier);
		edition.add(coller);
 
		aide.add(about);
 
 
		enregistrer.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,KeyEvent.CTRL_MASK));
		fichier.add(enregistrer);
 
		quitter.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,KeyEvent.CTRL_MASK));
		fichier.add(quitter);
 
		couper.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,KeyEvent.CTRL_MASK));
		edition.add(couper);
 
		copier.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,KeyEvent.CTRL_MASK));
		edition.add(copier);
 
		coller.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,KeyEvent.CTRL_MASK));
		edition.add(coller);
 
 
		quitter.addActionListener(new ActionListener() {
		         public void actionPerformed(ActionEvent e) {
		            System.exit(0);
		         }
		 });
 
 
		copier.addActionListener(new ActionListener() {
	         public void actionPerformed(ActionEvent e) {
 
	         }
	 });
 
 
		couper.addActionListener(new ActionListener() {
	         public void actionPerformed(ActionEvent e) {
 
	         }
	 });
 
 
		coller.addActionListener(new ActionListener() {
	         public void actionPerformed(ActionEvent e) {
 
	         }
	 });
 
		enregistrer.addActionListener(new ActionListener() {
	         public void actionPerformed(ActionEvent e) {
 
	         }
	 });
 
 
 
 
		f.setJMenuBar(barre);
		f.setBackground(Color.LIGHT_GRAY);
		f.pack();
		f.setVisible(true);
		f.setSize( 320,500);
		f.setLocationRelativeTo(null);
		f.setLayout(new GridLayout(5,1));
		//f.setDefaultCloseOperation(EXIT_ON_CLOSE);
 
		           		/* SCAN */
 
		l1=new Label("Port Scanner",Label.CENTER);
		l1.setForeground(Color.red);
		l1.setFont(new Font("TimesRoman",Font.BOLD,25));
		f.add(l1);
 
		Panel p1=new Panel(new GridLayout(3,3));
		host=new Label("Adresse IP :");
		host.setForeground(Color.blue);
		host.setFont(new Font("TimesRoman",Font.BOLD,15));
		p1.add(host);
 
		hostName=new TextField(15);
		p1.add(hostName);
 
		from=new Label("Port Début:");
		from.setForeground(Color.blue);
		from.setFont(new Font("TimesRoman",Font.BOLD,15));
		p1.add(from);
		fromPort=new TextField(15);
		p1.add(fromPort);
 
		to=new Label("Port Fin:");
		to.setForeground(Color.blue);
		to.setFont(new Font("TimesRoman",Font.BOLD,15));
		p1.add(to);
		toPort=new TextField(15);
		p1.add(toPort);
		f.add(p1);
 
		Panel p2=new Panel();
		scan=new Button("Scan");
		scan.addActionListener(new ActionListener(){
 
			public void actionPerformed(ActionEvent r){
					if(hostName.getText().equals("")){
							JOptionPane.showMessageDialog(null, "VEUILLEZ REMPLIR TOUS LES CHAMPS");
							return;}
					else if (fromPort.getText().equals("")){
							JOptionPane.showMessageDialog(null, "VEUILLEZ REMPLIR TOUS LES CHAMPS");
							return;}
					else if(toPort.getText().equals("")){
							JOptionPane.showMessageDialog(null, "VEUILLEZ REMPLIR TOUS LES CHAMPS");
							return;}		
					close=false;
					Thread run1=new Thread(){
 
						public void run(){
							scan.setEnabled(false);
							reset.setLabel("Stop");
							log.setText("");
							log.repaint();
 
							h=hostName.getText();
							fp=Integer.parseInt(fromPort.getText());
							tp=Integer.parseInt(toPort.getText());
 
							for(int i=fp;i<=tp;i++){
								label.setText("Port "+i+" en cour de test...");
								if(close)
									break;
								try{
									s=new Socket(h,i);
									log.append("Port "+i+" est ouvert."+"\n");
									log.repaint();
									s.close();
									}
								catch(Exception er){
									continue;}
							}
 
							scan.setEnabled(true);
							reset.setLabel("Reset");
							label.setText("Press Scan to start.");
						}
					};
					run1.start();
			}
		});
 
		reset=new Button("Reset");
		reset.addActionListener(new ActionListener(){
 
			public void actionPerformed(ActionEvent t){
				Thread run2=new Thread(){
					public void run(){
						close=true;
						hostName.setText("");
						fromPort.setText("");
						toPort.setText("");
					}
				};
				run2.start();
			}
		});
 
		Label empty=new Label();
		p2.add(scan);
		p2.add(empty);
		p2.add(reset);
		f.add(p2);
 
		log=new TextArea();
		f.add(log);
 
		label=new Label("Cliquez sur Scan.");
		label.setForeground(Color.blue);
		f.add(label);
 
		f.repaint();
		f.setResizable(false);
 
		/*f.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){
				System.exit(1);
			}
		});*/
 
 
	}
 
 
}


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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
 
 
package GUI;
 
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import lanscanner.CommandLine;
import lanscanner.IpObject;
import lanscanner.PortScanner;
import lanscanner.ScannerClass;
 
public class MainFrame extends javax.swing.JFrame {
 
    public ArrayList<IpObject> scanList;
    DefaultTableModel tbmdl;
    public int flag, state;
    ScannerClass scan;
    String fromIP, toIP;
    String currentIP;
    CommandLine command = new CommandLine();
 
 
    public MainFrame() {
 
        initComponents();
 
        tbmdl = new DefaultTableModel(new Object[][]{}, new String[]{"IP Adress", "Host Name", "MAC Adress"});
        scanResultList.setModel(tbmdl);
        state = 0;
    }
 
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
 
        rangeToolBar = new javax.swing.JToolBar();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        startButton = new javax.swing.JButton();
        statusLabel = new javax.swing.JLabel();
        fromField = new javax.swing.JTextField();
        toField = new javax.swing.JTextField();
        stopButton = new javax.swing.JButton();
        pingButton = new javax.swing.JButton();
        new javax.swing.JToolBar();
        new javax.swing.JPanel();
        new javax.swing.JProgressBar();
        new javax.swing.JLabel();
        new javax.swing.JLabel();
        new javax.swing.JLabel();
       // devicesLabel = new javax.swing.JLabel();
        scanResultPanel = new javax.swing.JPanel();
       deviceListScrollPane = new javax.swing.JScrollPane();
        scanResultList = new javax.swing.JTable();
        //sharedFoldersPanel = new javax.swing.JPanel();
        //folderListScrollPane = new javax.swing.JScrollPane();
        //sharedFoldersList = new javax.swing.JList();
        //sharedButton = new javax.swing.JButton();
       // onlineButton = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        exitMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        helpMenuItem = new javax.swing.JMenuItem();
        aboutMenuItem = new javax.swing.JMenuItem();
 
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Scanner Résaux");
        setLocationByPlatform(true);
 
        rangeToolBar.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        rangeToolBar.setRollover(true);
 
        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
 
        jLabel1.setText("Adresse ip de début :");
 
        jLabel2.setText("Adresse ip de fin :");
 
        startButton.setForeground(new java.awt.Color(0, 102, 0));
        startButton.setText("Scan");
        startButton.setToolTipText("Cliquez pour démarrer le Scan");
        startButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        startButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startButtonActionPerformed(evt);
            }
        });
 
 
        fromField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        fromField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        fromField.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        fromField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                fromFieldKeyTyped(evt);
            }
        });
 
        toField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        toField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        toField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                toFieldKeyTyped(evt);
            }
        });
 
        stopButton.setForeground(new java.awt.Color(204, 0, 0));
        stopButton.setText("Stop Scan");
        stopButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        stopButton.setEnabled(false);
        stopButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopButtonActionPerformed(evt);
            }
        });
 
        pingButton.setText("Scan port");
        //pingButton.setText("Ping");
        pingButton.setEnabled(false);
 
 
 
        pingButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pingButtonActionPerformed(evt);
 
            }
        });
 
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(fromField, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(toField, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(39, 39, 39)
                .addComponent(startButton, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(stopButton, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pingButton, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
                .addComponent(statusLabel)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(startButton)
                            .addComponent(stopButton)
                            .addComponent(pingButton)
                            .addComponent(statusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.CENTER, jPanel1Layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(fromField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1)))
                    .addGroup(javax.swing.GroupLayout.Alignment.CENTER, jPanel1Layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(toField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))))
                .addContainerGap())
        );
 
        rangeToolBar.add(jPanel1);
 
 
 
        scanResultPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Device List:", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP));
 
        scanResultList.setFont(new java.awt.Font("Tahoma", 1, 12));
        scanResultList.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "IP Adress", "Host Name", "MAC Adress"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false , false
            };
 
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        scanResultList.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        scanResultList.setGridColor(new java.awt.Color(255, 255, 255));
        scanResultList.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                scanResultListMouseClicked(evt);
            }
        });
       deviceListScrollPane.setViewportView(scanResultList);
 
        javax.swing.GroupLayout scanResultPanelLayout = new javax.swing.GroupLayout(scanResultPanel);
        scanResultPanel.setLayout(scanResultPanelLayout);
        scanResultPanelLayout.setHorizontalGroup(
            scanResultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(deviceListScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 635, Short.MAX_VALUE)
        );
        scanResultPanelLayout.setVerticalGroup(
            scanResultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(deviceListScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
        );
 
 
 
        fileMenu.setText("File");
 
        exitMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);
 
        jMenuBar1.add(fileMenu);
 
        helpMenu.setText("Help");
 
        helpMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.ALT_MASK));
        helpMenuItem.setText("Help");
        helpMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                helpMenuItemActionPerformed(evt);
            }
        });
        helpMenu.add(helpMenuItem);
 
        aboutMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.ALT_MASK));
        aboutMenuItem.setText("About");
        aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutMenuItemActionPerformed(evt);
            }
        });
        helpMenu.add(aboutMenuItem);
 
        jMenuBar1.add(helpMenu);
 
        setJMenuBar(jMenuBar1);
 
       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
 
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(rangeToolBar, javax.swing.GroupLayout.DEFAULT_SIZE, 967, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(scanResultPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                           )) );
 
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(rangeToolBar, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(scanResultPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        )) ); 
 
        pack();
    }// </editor-fold>//GEN-END:initComponents
 
    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        // TODO add your handling code here:
        System.exit(1);
    }//GEN-LAST:event_exitMenuItemActionPerformed
 
    private void helpMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpMenuItemActionPerformed
        // TODO add your handling code here:
        HelpFrame hf = new HelpFrame();
        hf.setLocationRelativeTo(null);
        hf.setVisible(true);
 
    }//GEN-LAST:event_helpMenuItemActionPerformed
 
    private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
        // TODO add your handling code here:
        AboutFrame af = new AboutFrame();
        af.setLocationRelativeTo(null);
        af.setVisible(true);
    }//GEN-LAST:event_aboutMenuItemActionPerformed
 
    private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed
        // TODO add your handling code here:
        if (fromField.getText().isEmpty()) {
            JOptionPane.showMessageDialog(null, "Veuillez entrer une adresse IP de début");
            return;
        }
        if (toField.getText().isEmpty()) {
            JOptionPane.showMessageDialog(null, "Veuillez entrer une adresse IP de fin");
            return;
        }
 
        startButton.setText("Scanning");
        startButton.setEnabled(false);
        stopButton.setEnabled(true);
        scanResultList.clearSelection();
 
        //lowerStatusLabel.setText("Scanning");
 
 
 
 
        state = flag = 0;
        tbmdl.setRowCount(0);
        scanList = new ArrayList<IpObject>();
       // sharedDevices = new ArrayList<IpObject>();
 
        fromIP = fromField.getText();
        toIP = toField.getText();
        String[] initialIP = fromIP.split("\\.");
        String[] finalIP = toIP.split("\\.");
 
        this.scan = new ScannerClass(initialIP, finalIP, this);
 
 
    }
 
    private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed
        state = 1;
 
        startButton.setText("Start Scan");
        startButton.setEnabled(true);
        stopButton.setEnabled(false);
 
 
    }
 
    private void scanResultListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_scanResultListMouseClicked
        // TODO add your handling code here:
        if (evt.getClickCount() == 1) {
 
            pingButton.setEnabled(true);
 
            int row = scanResultList.rowAtPoint(evt.getPoint());
            String selectedIP = scanResultList.getValueAt(row, 0).toString();
            currentIP = selectedIP;
            pingButton.setEnabled(true);
 
        }
 
 
    }
 
    private void fromFieldKeyTyped(java.awt.event.KeyEvent evt) {
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if (c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9' || c == '0' || c == '.' || c == evt.VK_BACK_SPACE) {
        } else {
            evt.consume();
        }
    }
 
    private void toFieldKeyTyped(java.awt.event.KeyEvent evt) {
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if (c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9' || c == '0' || c == '.' || c == evt.VK_BACK_SPACE) {
        } else {
            evt.consume();
        }
    }
 
    private void pingButtonActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
 
    	 new PortScanner();
 
        }
 
 
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
 
            public void run() {
                MainFrame mf = new MainFrame();
                mf.setLocationRelativeTo(null);
                mf.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JScrollPane deviceListScrollPane;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JTextField fromField;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JMenuItem helpMenuItem;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton pingButton;
    private javax.swing.JToolBar rangeToolBar;
    private javax.swing.JTable scanResultList;
    private javax.swing.JPanel scanResultPanel;
    private javax.swing.JButton startButton;
    private javax.swing.JLabel statusLabel;
    private javax.swing.JButton stopButton;
    private javax.swing.JTextField toField;
    // End of variables declaration//GEN-END:variables
 
    public void insertObj(IpObject obj) {
 
        int i = scanResultList.getRowCount();
        tbmdl.addRow(new Object[]{});
        scanResultList.setValueAt(obj.getIpAdress(), i, 0);
        scanResultList.setValueAt(obj.getHostName(), i, 1);
        scanResultList.setValueAt(obj.getMacAdress(), i, 2);
 
    }
 
 
}
image des interfaces pour mieux comprendre mes problèmes : http://www.mediafire.com/?zncpbzii7d4e2jk

merciii d'avance