1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- /*
- * 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 netz.controller;
-
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.util.logging.Logger;
- import netz.model.ChatModel;
- import netz.view2.ChatView;
- import ohmlogger.OhmLogger;
-
- /**
- *
- * @author chris
- */
- public class BtnController implements ActionListener
- {
- private ChatView view;
- private ChatModel model;
- private static Logger lg = OhmLogger.getLogger();
-
- /**
- *
- * @param view
- * @param model
- */
- public BtnController(ChatView view, ChatModel model)
- {
- this.view = view;
- this.model = model;
- }
-
- public void registerEvents()
- {
- view.getBtnSetClient().addActionListener(this);
- view.getBtnSetServer().addActionListener(this);
- }
-
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if(e.getSource() == view.getBtnSetClient())
- {
- view.getLblType().setText("Client");
- try
- {
- model.startClient(36000, "127.0.0.1",new ChatController(view, model));
- }
- catch (Exception ex)
- {
- System.err.println(ex);
- ex.printStackTrace();
- }
- } else {
- view.getLblType().setText("Server");
- try
- {
- model.startServer(36000, new ChatController(view, model));
- }
- catch (Exception ex)
- {
- System.err.println(ex);
- ex.printStackTrace();
- }
- }
- }
-
-
-
- }
|