Monday, March 10, 2014

Server/Client from JButtonl
































































































































































































































































































































































































































































































































Server is a class. when i run the server separetly with its main it works fine. and now i wanna run it from a button (JFrame application having 2 buttons: Server Start && Client Start)
































































































































































































































































































































































































































































































































for the Server Start button:
































































































































































































































































































































































































































































































































































































































































































































































































Java Code:









































































































































































































































































































































































































































































































































JButton btnserver = new JButton("Start Server");
btnserver.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
Server s = new Server();
s.run();
}
});







































































































































































































































































































































































































































































































































for the Client Start button:































































































































































































































































































































































































































































































































Java Code:









































































































































































































































































































































































































































































































































JButton btnclient = new JButton("Start Client");
btnclient.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Client c = new Client();
c.run();
}
});






































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































No comments:

Post a Comment