chimo01 | 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 :
- 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 :
- 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 |