/* * 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 kommunikation.controller; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JOptionPane; import kommunikation.transmitter.BilderKom; import kommunikation.transmitter.Transmitter; import kommunikation.view.ViewChat; /** * * @author Alexander_Christoph */ public class ConnectController implements ActionListener { ViewChat view; BilderKom model; public ConnectController(ViewChat view, BilderKom model) { this.view = view; this.model = model; } public void registerEvents() { view.getBtnConnect().addActionListener(this); } @Override public void actionPerformed(ActionEvent arg0) { try { String ip = view.getTfIp().getText(); int port = Integer.parseInt(view.getTfPort().getText()); model.setIpPort(ip, port); } catch(NumberFormatException ex) { JOptionPane.showMessageDialog(null, "Bitte geben sie eine Zahl ein","Fehler", JOptionPane.ERROR_MESSAGE); } view.getTaChat().append("Verbinde\n"); model.start(); } }