Initial commit. Teste efi.git.
Programm fertig gestellt.
This commit is contained in:
parent
dc9d1d749a
commit
0b043a0715
@ -1,9 +1,3 @@
|
||||
/*
|
||||
* 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 chatprogramm;
|
||||
|
||||
import chatprogramm.controller.ConnectController;
|
||||
@ -13,20 +7,27 @@ import chatprogramm.model.Transmitter;
|
||||
import chatprogramm.view.ChatView;
|
||||
|
||||
/**
|
||||
* Builder Class
|
||||
* @author le
|
||||
*
|
||||
* @author Marian
|
||||
*/
|
||||
public class Start
|
||||
{
|
||||
public class Start {
|
||||
|
||||
public Start()
|
||||
{
|
||||
ChatView view = new ChatView();
|
||||
Transmitter model = new Transmitter();
|
||||
ConnectController conCon = new ConnectController(view, model);
|
||||
ReceiveAdapterController reiAdapCon = new ReceiveAdapterController(view, model);
|
||||
SendController sendCon = new SendController(view, model);
|
||||
view.setVisible(true);
|
||||
|
||||
ConnectController controllerConnect = new ConnectController(model, view);
|
||||
controllerConnect.registerEvents();
|
||||
|
||||
SendController controllerSend = new SendController(model, view);
|
||||
controllerSend.registerEvents();
|
||||
|
||||
ReceiveAdapterController rxAdapter = new ReceiveAdapterController(view);
|
||||
model.addObserver(rxAdapter);
|
||||
|
||||
view.setTitle("ICQ 0.1 xD");
|
||||
view.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,6 +35,7 @@ public class Start
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Start();
|
||||
Start start = new Start();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,87 +1,95 @@
|
||||
/*
|
||||
* 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 chatprogramm.controller;
|
||||
|
||||
import chatprogramm.logger.OhmLogger;
|
||||
import chatprogramm.model.Transmitter;
|
||||
import chatprogramm.logger.OhmLogger;
|
||||
import chatprogramm.view.ChatView;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Gerhard
|
||||
* @author Marian
|
||||
*/
|
||||
public class ConnectController
|
||||
public class ConnectController implements ActionListener
|
||||
{
|
||||
private ChatView view;
|
||||
private Transmitter model;
|
||||
private static final Logger logger = OhmLogger.getLogger();
|
||||
private String ip = null;
|
||||
private int port = 0;
|
||||
private ChatView view;
|
||||
private static Logger logger = OhmLogger.getLogger();
|
||||
|
||||
public ConnectController(ChatView view, Transmitter model)
|
||||
public ConnectController(Transmitter m, ChatView v)
|
||||
{
|
||||
this.view = view;
|
||||
this.model = model;
|
||||
chooseConnection();
|
||||
this.model = m;
|
||||
this.view = v;
|
||||
}
|
||||
|
||||
void chooseConnection()
|
||||
public void registerEvents()
|
||||
{
|
||||
Object[] options = {"Client", "Server"};
|
||||
int choice = JOptionPane.showOptionDialog(view, "Wähle deine Verbindungsart:", "Client oder Server", 0, 1, null, options, null);
|
||||
this.view.getBtConnect().addActionListener(this);
|
||||
this.view.getRbClient().addActionListener(this);
|
||||
this.view.getRbServer().addActionListener(this);
|
||||
}
|
||||
|
||||
if(choice == 1)
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ae)
|
||||
{
|
||||
logger.info("Server");
|
||||
String port = JOptionPane.showInputDialog(view, "PORT eingeben");
|
||||
Object o = ae.getSource();
|
||||
|
||||
logger.info("Port für Server ist: localhost:" + port);
|
||||
startServer();
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.info("Client");
|
||||
port = Integer.parseInt(JOptionPane.showInputDialog(view, "PORT eingeben"));
|
||||
ip = JOptionPane.showInputDialog(view, "IP vom Server bitte");
|
||||
|
||||
logger.info("Client IP Adresse und Port ist: " + ip + ":" + port);
|
||||
startClient();
|
||||
if (o == view.getBtConnect()) {
|
||||
int port = -1;
|
||||
|
||||
try {
|
||||
port = Integer.parseInt(view.getTfPort().getText());
|
||||
} catch (NumberFormatException e) {
|
||||
JOptionPane.showMessageDialog(view, "Port ungültig! Muss eine Zahl sein");
|
||||
logger.severe(e.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (view.getRbClient().isSelected() && (validIP(view.getTfIP().getText()) == false)) {
|
||||
JOptionPane.showMessageDialog(view, "Ungültige IP-Adresse!");
|
||||
logger.severe("IP-Adresse ungültig");
|
||||
return;
|
||||
}
|
||||
|
||||
public void startServer()
|
||||
{
|
||||
try
|
||||
{
|
||||
model.createServer(port);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger(ConnectController.class.getName()).log(Level.SEVERE, null, ex);
|
||||
model.connectToPeer(view.getRbServer().isSelected(), view.getTfIP().getText(), port);
|
||||
|
||||
view.getRbClient().setEnabled(false);
|
||||
view.getRbServer().setEnabled(false);
|
||||
view.getTfIP().setEnabled(false);
|
||||
view.getTfPort().setEnabled(false);
|
||||
} else {
|
||||
view.getTfIP().setEnabled(view.getRbClient().isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
public void startClient()
|
||||
{
|
||||
try
|
||||
{
|
||||
model.createClient(port, ip);
|
||||
private boolean validIP (String ip) {
|
||||
try {
|
||||
if ( ip == null || ip.isEmpty() ) {
|
||||
return false;
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger(ConnectController.class.getName()).log(Level.SEVERE, null, ex);
|
||||
|
||||
String[] parts = ip.split( "\\." );
|
||||
if ( parts.length != 4 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( String s : parts ) {
|
||||
int i = Integer.parseInt( s );
|
||||
if ( (i < 0) || (i > 255) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ( ip.endsWith(".") ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
logger.severe(e.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,33 +1,28 @@
|
||||
/*
|
||||
* 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 chatprogramm.controller;
|
||||
|
||||
import chatprogramm.model.Transmitter;
|
||||
import chatprogramm.view.ChatView;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Gerhard
|
||||
* @author Marian
|
||||
*/
|
||||
public class ReceiveAdapterController implements Observer
|
||||
{
|
||||
private ChatView view;
|
||||
private Transmitter model;
|
||||
|
||||
public ReceiveAdapterController(ChatView view, Transmitter model)
|
||||
public ReceiveAdapterController(ChatView view)
|
||||
{
|
||||
this.view = view;
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Observable o, Object arg)
|
||||
public void update(Observable observable, Object object)
|
||||
{
|
||||
String msg = (String)object;
|
||||
|
||||
view.getTaCommunication().append(msg + "\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,26 +1,35 @@
|
||||
/*
|
||||
* 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 chatprogramm.controller;
|
||||
|
||||
import chatprogramm.model.Transmitter;
|
||||
import chatprogramm.view.ChatView;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Gerhard
|
||||
* @author Marian
|
||||
*/
|
||||
public class SendController
|
||||
public class SendController implements ActionListener
|
||||
{
|
||||
private ChatView view;
|
||||
private Transmitter model;
|
||||
private ChatView view;
|
||||
|
||||
public SendController(ChatView view, Transmitter model)
|
||||
public SendController(Transmitter m, ChatView v)
|
||||
{
|
||||
this.view = view;
|
||||
this.model = model;
|
||||
this.model = m;
|
||||
this.view = v;
|
||||
}
|
||||
|
||||
public void registerEvents()
|
||||
{
|
||||
this.view.getBtSend().addActionListener(this);
|
||||
this.view.getTfMessage().addActionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ae)
|
||||
{
|
||||
model.sendMessage(view.getTfMessage().getText());
|
||||
view.getTfMessage().setText("");
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,3 @@
|
||||
/*
|
||||
* 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 chatprogramm.model;
|
||||
|
||||
import chatprogramm.logger.OhmLogger;
|
||||
@ -14,54 +8,128 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Socket;
|
||||
import java.util.Observable;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Builder Class
|
||||
* @author le
|
||||
*
|
||||
* @author Marian
|
||||
*/
|
||||
public class Client
|
||||
public class Client extends Observable implements Runnable
|
||||
{
|
||||
private static final Logger lg = OhmLogger.getLogger();
|
||||
private static int PORT = 35000;
|
||||
private static String IP_ADRESSE = "127.0.0.1";
|
||||
private Socket socket;
|
||||
private BufferedReader reader;
|
||||
private PrintWriter writer;
|
||||
private boolean ready;
|
||||
private Thread thd;
|
||||
private String ip;
|
||||
private int port;
|
||||
private static Logger logger = OhmLogger.getLogger();
|
||||
|
||||
public Client(int port, String ip) throws IOException
|
||||
|
||||
public Client(String ip, int port)
|
||||
{
|
||||
if(port != 0) {this.PORT = port;};
|
||||
if(ip != null | ip != "") {this.IP_ADRESSE = ip;};
|
||||
|
||||
lg.info("Client: verbinde ...");
|
||||
Socket s = new Socket(IP_ADRESSE, PORT); // Achtung: blockiert!
|
||||
lg.info("Client: Verbindung hergestellt");
|
||||
InputStream iStream = s.getInputStream();
|
||||
OutputStream oStream = s.getOutputStream();
|
||||
|
||||
InputStreamReader isr = new InputStreamReader(iStream, "UTF-8");
|
||||
OutputStreamWriter osr = new OutputStreamWriter(oStream, "UTF-8");
|
||||
|
||||
BufferedReader in = new BufferedReader(isr);
|
||||
//BufferedWriter out = new BufferedWriter(osr);
|
||||
PrintWriter out = new PrintWriter(osr);
|
||||
|
||||
lg.info("Client: Stream initialisiert");
|
||||
|
||||
out.println("Hallo Du Server Du - ich bin der client");
|
||||
out.flush(); // wirklich absenden!!
|
||||
|
||||
lg.info("Client: Nachricht versendet");
|
||||
|
||||
String quittung = in.readLine(); // Achtung blockiert
|
||||
lg.info("Client: Quittung empfangen");
|
||||
|
||||
System.out.println("Client: Quittung EMPFANGEN - " + quittung);
|
||||
|
||||
|
||||
|
||||
out.close();
|
||||
in.close();
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
this.socket = null;
|
||||
this.reader = null;
|
||||
this.writer = null;
|
||||
this.ready = false;
|
||||
this.thd = null;
|
||||
}
|
||||
|
||||
|
||||
public void init()
|
||||
{
|
||||
if (thd == null) {
|
||||
thd = new Thread(this);
|
||||
thd.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessage(String msg)
|
||||
{
|
||||
if (ready) {
|
||||
writer.println(msg);
|
||||
writer.flush();
|
||||
} else {
|
||||
logger.warning("Server not ready to send message. Connect first");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
logger.info("Running client...");
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (socket == null) {
|
||||
try {
|
||||
socket = new Socket(ip, port);
|
||||
logger.info("Connected to server");
|
||||
} catch (IOException e) {
|
||||
logger.severe(e.getMessage());
|
||||
socket = null;
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
InputStream iStream;
|
||||
try {
|
||||
iStream = socket.getInputStream();
|
||||
} catch (IOException e) {
|
||||
logger.severe(e.getMessage());
|
||||
return;
|
||||
}
|
||||
OutputStream oStream;
|
||||
try {
|
||||
oStream = socket.getOutputStream();
|
||||
} catch (IOException e) {
|
||||
logger.severe(e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
InputStreamReader isr;
|
||||
try {
|
||||
isr = new InputStreamReader(iStream, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.severe(e.getMessage());
|
||||
return;
|
||||
}
|
||||
OutputStreamWriter osr;
|
||||
try {
|
||||
osr = new OutputStreamWriter(oStream, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.severe(e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
reader = new BufferedReader(isr);
|
||||
writer = new PrintWriter(osr);
|
||||
|
||||
ready = true;
|
||||
}
|
||||
|
||||
if (ready) {
|
||||
String msg;
|
||||
try {
|
||||
logger.info("Waiting for message");
|
||||
msg = reader.readLine();
|
||||
} catch (IOException e) {
|
||||
logger.severe(e.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
this.setChanged();
|
||||
this.notifyObservers(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,3 @@
|
||||
/*
|
||||
* 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 chatprogramm.model;
|
||||
|
||||
import chatprogramm.logger.OhmLogger;
|
||||
@ -14,54 +8,140 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Observable;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Builder Class
|
||||
* @author le
|
||||
*
|
||||
* @author Marian
|
||||
*/
|
||||
public class Server
|
||||
public class Server extends Observable implements Runnable
|
||||
{
|
||||
private static final Logger lg = OhmLogger.getLogger();
|
||||
private static int PORT = 35000;
|
||||
private int port;
|
||||
private ServerSocket server;
|
||||
private Socket client;
|
||||
private static Logger logger = OhmLogger.getLogger();
|
||||
private BufferedReader reader;
|
||||
private PrintWriter writer;
|
||||
private volatile boolean ready;
|
||||
private Thread thd;
|
||||
private static final SimpleDateFormat sdf = new SimpleDateFormat("HH.mm.ss");
|
||||
|
||||
public Server(int port) throws IOException
|
||||
|
||||
public Server(int port)
|
||||
{
|
||||
if(port != 0)
|
||||
{
|
||||
this.PORT = port;
|
||||
this.port = port;
|
||||
this.server = null;
|
||||
this.client = null;
|
||||
this.reader = null;
|
||||
this.writer = null;
|
||||
this.ready = false;
|
||||
this.thd = null;
|
||||
}
|
||||
ServerSocket sSocket = new ServerSocket(PORT);
|
||||
lg.info("Server: Warte auf Verbindung ...");
|
||||
Socket s = sSocket.accept(); // Achtung: blockiert!
|
||||
lg.info("Server: Verbindung akzeptiert");
|
||||
InputStream iStream = s.getInputStream();
|
||||
OutputStream oStream = s.getOutputStream();
|
||||
|
||||
InputStreamReader isr = new InputStreamReader(iStream, "UTF-8");
|
||||
OutputStreamWriter osr = new OutputStreamWriter(oStream, "UTF-8");
|
||||
public void init()
|
||||
{
|
||||
if (thd == null) {
|
||||
thd = new Thread(this);
|
||||
thd.start();
|
||||
}
|
||||
}
|
||||
|
||||
BufferedReader in = new BufferedReader(isr);
|
||||
//BufferedWriter out = new BufferedWriter(osr);
|
||||
PrintWriter out = new PrintWriter(osr);
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
logger.info("Running server...");
|
||||
|
||||
lg.info("Server: Stream initialisiert");
|
||||
lg.info("Server: warte auf Nachricht ...");
|
||||
while (true)
|
||||
{
|
||||
if (server == null) {
|
||||
try {
|
||||
server = new ServerSocket(port);
|
||||
} catch (IOException e) {
|
||||
logger.severe(e.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
String nachricht = in.readLine(); // Achtung blockiert
|
||||
lg.info("Server: Nachricht empfangen");
|
||||
logger.info("Waiting for client to connect");
|
||||
try {
|
||||
client = server.accept();
|
||||
} catch (IOException e) {
|
||||
logger.severe(e.toString());
|
||||
return;
|
||||
}
|
||||
logger.info("Client connected");
|
||||
|
||||
System.out.println("Server: NACHRICHT EMPFANGEN - " + nachricht);
|
||||
InputStream iStream;
|
||||
try {
|
||||
iStream = client.getInputStream();
|
||||
} catch (IOException e) {
|
||||
logger.severe(e.toString());
|
||||
return;
|
||||
}
|
||||
OutputStream oStream;
|
||||
try {
|
||||
oStream = client.getOutputStream();
|
||||
} catch (IOException e) {
|
||||
logger.severe(e.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
out.println("Server -> ich habe die Nachricht erhalten");
|
||||
lg.info("Server: Quittung versendet");
|
||||
InputStreamReader isr;
|
||||
try {
|
||||
isr = new InputStreamReader(iStream, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.severe(e.toString());
|
||||
return;
|
||||
}
|
||||
OutputStreamWriter osr;
|
||||
try {
|
||||
osr = new OutputStreamWriter(oStream, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.severe(e.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
out.flush(); // wirklich absenden!!
|
||||
reader = new BufferedReader(isr);
|
||||
writer = new PrintWriter(osr);
|
||||
|
||||
out.close();
|
||||
in.close();
|
||||
ready = true;
|
||||
|
||||
}
|
||||
|
||||
if (ready) {
|
||||
try {
|
||||
logger.info("Waiting for message");
|
||||
String msg = reader.readLine();
|
||||
if (msg == null) {
|
||||
ready = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
this.setChanged();
|
||||
this.notifyObservers(msg);
|
||||
} catch (IOException e) {
|
||||
logger.severe(e.toString());
|
||||
ready = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessage(String msg)
|
||||
{
|
||||
if (ready) {
|
||||
writer.println(msg);
|
||||
writer.flush();
|
||||
} else {
|
||||
logger.warning("Server not ready to send message. Connect first");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,34 +1,78 @@
|
||||
/*
|
||||
* 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 chatprogramm.model;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import chatprogramm.controller.ReceiveAdapterController;
|
||||
import chatprogramm.logger.OhmLogger;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Gerhard
|
||||
* @author Marian
|
||||
*/
|
||||
public class Transmitter
|
||||
public class Transmitter extends Observable implements Observer
|
||||
{
|
||||
Server server;
|
||||
Client client;
|
||||
boolean connected;
|
||||
Server srv;
|
||||
Client cli;
|
||||
boolean mode;
|
||||
boolean initialized;
|
||||
ReceiveAdapterController Adapter;
|
||||
private static Logger logger = OhmLogger.getLogger();
|
||||
|
||||
public Transmitter()
|
||||
{
|
||||
|
||||
connected = false;
|
||||
mode = false;
|
||||
initialized = false;
|
||||
srv = null;
|
||||
cli = null;
|
||||
}
|
||||
|
||||
public void createServer(int port) throws IOException
|
||||
public void connectToPeer(boolean mode, String ip, int port)
|
||||
{
|
||||
server = new Server(port);
|
||||
if (initialized) {
|
||||
logger.info("Chat already running");
|
||||
return;
|
||||
}
|
||||
|
||||
public void createClient(int port, String ip) throws IOException
|
||||
this.mode = mode;
|
||||
|
||||
if (mode) {
|
||||
logger.info("Running as server");
|
||||
srv = new Server(port);
|
||||
srv.addObserver(this);
|
||||
srv.init();
|
||||
} else {
|
||||
logger.info("Running as client");
|
||||
cli = new Client(ip, port);
|
||||
cli.addObserver(this);
|
||||
cli.init();
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public void sendMessage(String msg)
|
||||
{
|
||||
client = new Client(port, ip);
|
||||
if (!initialized) {
|
||||
logger.warning("Chat not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode) {
|
||||
srv.sendMessage(msg);
|
||||
} else {
|
||||
cli.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Observable o, Object o1)
|
||||
{
|
||||
this.setChanged();
|
||||
this.notifyObservers(o1);
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Menu class="javax.swing.JMenuBar" name="jMenuBar1">
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="File"/>
|
||||
</Properties>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="jMenu3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Edit"/>
|
||||
</Properties>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
<Component class="javax.swing.ButtonGroup" name="bgSelect">
|
||||
</Component>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
@ -35,51 +22,72 @@
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-112,0,0,2,88"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JLayeredPane" name="chatControll">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Last"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="btnSend">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="send"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnClear">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="clear"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnServer">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jButton1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jButton1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JLayeredPane" name="chatContent">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
|
||||
<Property name="axis" type="int" value="3"/>
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="lbPort" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="tfPort" min="-2" pref="61" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lbIP" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="tfIP" min="-2" pref="191" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="34" max="32767" attributes="0"/>
|
||||
<Component id="btConnect" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="rbClient" min="-2" pref="64" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="rbServer" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jScrollPane1" alignment="1" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="tfMessage" max="32767" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="btSend" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jSeparator2" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="134" max="32767" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="tfMessage" alignment="3" min="-2" pref="25" max="-2" attributes="0"/>
|
||||
<Component id="btSend" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jSeparator2" min="-2" pref="6" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="rbServer" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="rbClient" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lbPort" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="tfPort" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="tfIP" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lbIP" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btConnect" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
@ -89,7 +97,7 @@
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="taEmpfangen">
|
||||
<Component class="javax.swing.JTextArea" name="taCommunication">
|
||||
<Properties>
|
||||
<Property name="columns" type="int" value="20"/>
|
||||
<Property name="rows" type="int" value="5"/>
|
||||
@ -97,22 +105,65 @@
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="taSenden">
|
||||
<Component class="javax.swing.JTextField" name="tfMessage">
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btSend">
|
||||
<Properties>
|
||||
<Property name="columns" type="int" value="20"/>
|
||||
<Property name="rows" type="int" value="5"/>
|
||||
<Property name="text" type="java.lang.String" value="send"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JTextField" name="tfPort">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="3210"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lbPort">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Port:"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lbIP">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="IP:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="tfIP">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="127.0.0.1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btConnect">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="connect"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="rbClient">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="bgSelect"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" value="Client"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rbClientActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="rbServer">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="bgSelect"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Server"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rbServerActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSeparator" name="jSeparator2">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -7,47 +7,84 @@ package chatprogramm.view;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Gerhard
|
||||
* @author max
|
||||
*/
|
||||
public class ChatView extends javax.swing.JFrame
|
||||
{
|
||||
public class ChatView extends javax.swing.JFrame {
|
||||
|
||||
/**
|
||||
* @return the btnClear
|
||||
* @return the rbClient
|
||||
*/
|
||||
public javax.swing.JButton getBtnClear()
|
||||
{
|
||||
return btnClear;
|
||||
public javax.swing.JRadioButton getRbClient() {
|
||||
return rbClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the btnSend
|
||||
* @return the rbServer
|
||||
*/
|
||||
public javax.swing.JButton getBtnSend()
|
||||
{
|
||||
return btnSend;
|
||||
public javax.swing.JRadioButton getRbServer() {
|
||||
return rbServer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the taEmpfangen
|
||||
* @return the btConnect
|
||||
*/
|
||||
public javax.swing.JTextArea getTaEmpfangen()
|
||||
{
|
||||
return taEmpfangen;
|
||||
public javax.swing.JButton getBtConnect() {
|
||||
return btConnect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the taSenden
|
||||
* @return the btSend
|
||||
*/
|
||||
public javax.swing.JTextArea getTaSenden()
|
||||
{
|
||||
return taSenden;
|
||||
public javax.swing.JButton getBtSend() {
|
||||
return btSend;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lbIP
|
||||
*/
|
||||
public javax.swing.JLabel getLbIP() {
|
||||
return lbIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lbPort
|
||||
*/
|
||||
public javax.swing.JLabel getLbPort() {
|
||||
return lbPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the taCommunication
|
||||
*/
|
||||
public javax.swing.JTextArea getTaCommunication() {
|
||||
return taCommunication;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tfIP
|
||||
*/
|
||||
public javax.swing.JTextField getTfIP() {
|
||||
return tfIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tfMessage
|
||||
*/
|
||||
public javax.swing.JTextField getTfMessage() {
|
||||
return tfMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tfPort
|
||||
*/
|
||||
public javax.swing.JTextField getTfPort() {
|
||||
return tfPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form ChatView
|
||||
*/
|
||||
public ChatView()
|
||||
{
|
||||
public ChatView() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@ -58,131 +95,174 @@ public class ChatView extends javax.swing.JFrame
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents()
|
||||
{
|
||||
private void initComponents() {
|
||||
|
||||
chatControll = new javax.swing.JLayeredPane();
|
||||
btnSend = new javax.swing.JButton();
|
||||
btnClear = new javax.swing.JButton();
|
||||
btnServer = new javax.swing.JButton();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
chatContent = new javax.swing.JLayeredPane();
|
||||
bgSelect = new javax.swing.ButtonGroup();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
taEmpfangen = new javax.swing.JTextArea();
|
||||
jScrollPane2 = new javax.swing.JScrollPane();
|
||||
taSenden = new javax.swing.JTextArea();
|
||||
jMenuBar1 = new javax.swing.JMenuBar();
|
||||
jMenu2 = new javax.swing.JMenu();
|
||||
jMenu3 = new javax.swing.JMenu();
|
||||
taCommunication = new javax.swing.JTextArea();
|
||||
tfMessage = new javax.swing.JTextField();
|
||||
btSend = new javax.swing.JButton();
|
||||
tfPort = new javax.swing.JTextField();
|
||||
lbPort = new javax.swing.JLabel();
|
||||
lbIP = new javax.swing.JLabel();
|
||||
tfIP = new javax.swing.JTextField();
|
||||
btConnect = new javax.swing.JButton();
|
||||
rbClient = new javax.swing.JRadioButton();
|
||||
rbServer = new javax.swing.JRadioButton();
|
||||
jSeparator2 = new javax.swing.JSeparator();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
|
||||
chatControll.setLayout(new java.awt.FlowLayout());
|
||||
taCommunication.setColumns(20);
|
||||
taCommunication.setRows(5);
|
||||
jScrollPane1.setViewportView(taCommunication);
|
||||
|
||||
btnSend.setText("send");
|
||||
chatControll.add(btnSend);
|
||||
btSend.setText("send");
|
||||
|
||||
btnClear.setText("clear");
|
||||
chatControll.add(btnClear);
|
||||
tfPort.setText("3210");
|
||||
tfPort.setToolTipText("");
|
||||
|
||||
btnServer.setText("jButton1");
|
||||
chatControll.add(btnServer);
|
||||
lbPort.setText("Port:");
|
||||
lbPort.setToolTipText("");
|
||||
|
||||
jButton1.setText("jButton1");
|
||||
chatControll.add(jButton1);
|
||||
lbIP.setText("IP:");
|
||||
|
||||
getContentPane().add(chatControll, java.awt.BorderLayout.PAGE_END);
|
||||
tfIP.setText("127.0.0.1");
|
||||
|
||||
chatContent.setLayout(new javax.swing.BoxLayout(chatContent, javax.swing.BoxLayout.PAGE_AXIS));
|
||||
btConnect.setText("connect");
|
||||
btConnect.setToolTipText("");
|
||||
|
||||
taEmpfangen.setColumns(20);
|
||||
taEmpfangen.setRows(5);
|
||||
jScrollPane1.setViewportView(taEmpfangen);
|
||||
bgSelect.add(rbClient);
|
||||
rbClient.setSelected(true);
|
||||
rbClient.setText("Client");
|
||||
rbClient.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
rbClientActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
chatContent.add(jScrollPane1);
|
||||
bgSelect.add(rbServer);
|
||||
rbServer.setText("Server");
|
||||
rbServer.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
rbServerActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
taSenden.setColumns(20);
|
||||
taSenden.setRows(5);
|
||||
jScrollPane2.setViewportView(taSenden);
|
||||
|
||||
chatContent.add(jScrollPane2);
|
||||
|
||||
getContentPane().add(chatContent, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jMenu2.setText("File");
|
||||
jMenuBar1.add(jMenu2);
|
||||
|
||||
jMenu3.setText("Edit");
|
||||
jMenuBar1.add(jMenu3);
|
||||
|
||||
setJMenuBar(jMenuBar1);
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addComponent(lbPort)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(tfPort, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lbIP)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(tfIP, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
|
||||
.addComponent(btConnect))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addComponent(rbClient, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(rbServer)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addComponent(jScrollPane1)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addComponent(tfMessage)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(btSend)))
|
||||
.addContainerGap())
|
||||
.addComponent(jSeparator2)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(tfMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(btSend))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(1, 1, 1)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(rbServer)
|
||||
.addComponent(rbClient))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lbPort)
|
||||
.addComponent(tfPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(tfIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lbIP)
|
||||
.addComponent(btConnect))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
setLocationRelativeTo(null);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void rbClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbClientActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_rbClientActionPerformed
|
||||
|
||||
private void rbServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbServerActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_rbServerActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[])
|
||||
{
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<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
|
||||
*/
|
||||
try
|
||||
{
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels())
|
||||
{
|
||||
if ("Nimbus".equals(info.getName()))
|
||||
{
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException ex)
|
||||
{
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (InstantiationException ex)
|
||||
{
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IllegalAccessException ex)
|
||||
{
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (javax.swing.UnsupportedLookAndFeelException ex)
|
||||
{
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the form */
|
||||
java.awt.EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new ChatView().setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnClear;
|
||||
private javax.swing.JButton btnSend;
|
||||
private javax.swing.JButton btnServer;
|
||||
private javax.swing.JLayeredPane chatContent;
|
||||
private javax.swing.JLayeredPane chatControll;
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JMenu jMenu2;
|
||||
private javax.swing.JMenu jMenu3;
|
||||
private javax.swing.JMenuBar jMenuBar1;
|
||||
private javax.swing.ButtonGroup bgSelect;
|
||||
private javax.swing.JButton btConnect;
|
||||
private javax.swing.JButton btSend;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JScrollPane jScrollPane2;
|
||||
private javax.swing.JTextArea taEmpfangen;
|
||||
private javax.swing.JTextArea taSenden;
|
||||
private javax.swing.JSeparator jSeparator2;
|
||||
private javax.swing.JLabel lbIP;
|
||||
private javax.swing.JLabel lbPort;
|
||||
private javax.swing.JRadioButton rbClient;
|
||||
private javax.swing.JRadioButton rbServer;
|
||||
private javax.swing.JTextArea taCommunication;
|
||||
private javax.swing.JTextField tfIP;
|
||||
private javax.swing.JTextField tfMessage;
|
||||
private javax.swing.JTextField tfPort;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user