12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
- package chatProg.controller;
-
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.IOException;
- import java.util.logging.Logger;
- import chatProg.logger.OhmLogger;
- import chatProg.model.ChatModel;
- import chatProg.view.ChatView;
-
- /**
- *
- * @author hd, chris
- */
- public class CommandConnect implements ActionListener
- {
-
- private static Logger lg = OhmLogger.getLogger();
- ChatView view;
- ChatModel model;
-
- private static final int PORT = 35000;
- private static final String IP_ADRESSE = "127.0.0.1";
-
-
- public CommandConnect(ChatView view, ChatModel transmitter)
- {
- this.view = view;
- this.model = transmitter;
- }
-
- public void registerEvents(){
- view.getBtnSetServer().addActionListener(this);
- view.getBtnSetClient().addActionListener(this);
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
-
- Object src = e.getSource();
-
- // connect to server
- if(src == view.getBtnSetServer()){
- synchronized (this){
- try {
- view.getLblType().setText("Server");
- model.setServer(PORT);
- } catch (IOException ex) {
- lg.severe(ex.toString());
- }
- }
- }
-
- // connect to vlient
- if(src == view.getBtnSetClient()){
- synchronized (this){
- try {
- view.getLblType().setText("Client");
- model.setClient(PORT, IP_ADRESSE);
-
- } catch (IOException ex) {
- lg.severe(ex.toString());
- }
- }
- }
- }
- }
|