Browse Source

Test

master
nobody 4 years ago
parent
commit
3333785517

+ 68
- 0
src/kommunikation/Start.java View File

@@ -0,0 +1,68 @@
/*
* 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;

import javax.swing.JOptionPane;
import kommunikation.controller.ConnectController;
import kommunikation.controller.GrafikController;
import kommunikation.controller.ReceiveAdapter;
import kommunikation.controller.SendController;
import kommunikation.transmitter.BilderKom;
import kommunikation.view.ViewChat;


/**
* Builder Class
* @author Alexander_Christoph
*/
public class Start
{
public Start()
{
Object[] options = {"Client","Server"};
int selected = JOptionPane.showOptionDialog(null,"Wollen Sie Client oder Server sein","Konfiguration",JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE,null, options, options[0]);
if(selected < 0)
{
JOptionPane.showMessageDialog(null, "Sie müssen entweder Client oder Server sein. Bitte starten Sie das Programm erneut und wählen eine Option","Fehler", JOptionPane.ERROR_MESSAGE);
}
else
{
ViewChat view = new ViewChat();
BilderKom model = new BilderKom(selected);
model.registerEvents();

if(selected == 1)
{
view.setTitle("Server");
}
view.getGrafikViewChat().setModel(model.getModel());
GrafikController gcontrol= new GrafikController(view.getGrafikViewChat(),model);
gcontrol.registerEvents();
ConnectController control = new ConnectController(view,model);
control.registerEvents();

SendController send = new SendController(view,model);
send.registerEvents();

ReceiveAdapter adapter = new ReceiveAdapter(view,model);
adapter.registerEvents();

view.setVisible(true);
}
}

/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
new Start();
}
}

+ 53
- 0
src/kommunikation/controller/ConnectController.java View File

@@ -0,0 +1,53 @@
/*
* 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();
}
}

+ 104
- 0
src/kommunikation/controller/GrafikController.java View File

@@ -0,0 +1,104 @@
/*
* 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.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import kommunikation.transmitter.BilderKom;
import kommunikation.transmitter.Figur;
import kommunikation.view.GrafikView;


/**
*
* @author le
*/
public class GrafikController implements MouseMotionListener, MouseListener
{
private GrafikView view;
private BilderKom model;
private Figur f;
private Boolean neu;
private Boolean ersterPunkt;
private Point zwischenSpeicher;
public GrafikController(GrafikView view, BilderKom model)
{
this.view = view;
this.model = model;
neu = true;
zwischenSpeicher = new Point();
ersterPunkt = true;
}

public void registerEvents()
{
view.addMouseMotionListener(this);
view.addMouseListener(this);
}
@Override
public void mouseDragged(MouseEvent evt)
{
Point p = evt.getPoint();
view.drawPoint(p);
f.addPoint(p);
if(!ersterPunkt)
{
view.line(zwischenSpeicher, p);
}
zwischenSpeicher = p;
ersterPunkt = false;
}

@Override
public void mouseMoved(MouseEvent e)
{
}

@Override
public void mouseClicked(MouseEvent e)
{
}

@Override
public void mousePressed(MouseEvent e)
{
if(neu)
{
f = new Figur();
neu = false;
}
}

@Override
public void mouseReleased(MouseEvent evt)
{
if (evt.getButton() == MouseEvent.BUTTON3)
{
view.doPrint();
}
model.addFigur(f);
model.senden(f);
neu = true;
ersterPunkt = true;
}

@Override
public void mouseEntered(MouseEvent e)
{
}

@Override
public void mouseExited(MouseEvent e)
{
}
}

+ 58
- 0
src/kommunikation/controller/ReceiveAdapter.java View File

@@ -0,0 +1,58 @@
/*
* 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.util.Observable;
import java.util.Observer;
import java.util.logging.Logger;
import kommunikation.transmitter.BilderKom;
import kommunikation.transmitter.Figur;
import kommunikation.view.ViewChat;

/**
*
* @author Alexander_Christoph
*/
public class ReceiveAdapter implements Observer
{
ViewChat view;
BilderKom model;
Logger lg =Logger.getLogger("observer");
public ReceiveAdapter(ViewChat view, BilderKom model)
{
this.view = view;
this.model = model;
}
public void registerEvents()
{
model.addObserver(this);
}
@Override
public void update(Observable arg0, Object arg1)
{
lg.info("in update");
Object obj;
obj = model.getNachricht();
if(obj instanceof String)
{
String text = obj.toString() + "\n";
view.getTaChat().append("Freund: " + text);
}
if(obj instanceof Figur)
{
model.addFigurFremd((Figur)obj); //muss eventuell noch gezeichnet werden nachdem es hinzugefügt wurde !!!
view.repaint();
}
}
}


+ 43
- 0
src/kommunikation/controller/SendController.java View File

@@ -0,0 +1,43 @@
/*
* 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 kommunikation.transmitter.BilderKom;
import kommunikation.view.ViewChat;

/**
*
* @author Alexander_Christoph
*/
public class SendController implements ActionListener
{
ViewChat view;
BilderKom model;
public SendController(ViewChat view, BilderKom model)
{
this.view = view;
this.model = model;
}
public void registerEvents()
{
view.getTfMessage().addActionListener(this);
}

@Override
public void actionPerformed(ActionEvent arg0)
{
String text = view.getTfMessage().getText();
view.getTaChat().append("Ich: "+ text+"\n");
model.senden(text);
view.getTfMessage().setText("");
}
}

+ 30
- 0
src/kommunikation/logger/MyFormatter.java View File

@@ -0,0 +1,30 @@
/*
* 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.logger;

import java.util.logging.LogRecord;
import java.util.logging.SimpleFormatter;

/**
*
* @author nobody
*/
public class MyFormatter extends SimpleFormatter
{
public MyFormatter()
{

}
@Override
public String format(LogRecord record)
{
String str = "| " + record.getMillis() + " | " + record.getLevel()+ " | " + record.getSourceClassName() + " | " + record.getMessage() + " |\n";
return str;
}
}

+ 58
- 0
src/kommunikation/logger/OhmLogger.java View File

@@ -0,0 +1,58 @@
package kommunikation.logger;
/**
*
* @author nobody
*/

import java.io.File;
import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;

public class OhmLogger
{
private static Logger lg = null;

public static Logger getLogger()
{
if (lg == null)
{
lg = Logger.getLogger("OhmLogger");
initLogger();
}

return lg;
}

private static void initLogger()
{
try
{
// Besser: Die Log-Datei über eine Properties-Dateieinstellbar machen
// Hier wird in das temporäre Verzeichnis desBetriebssytems geloggt.

String datei = System.getProperty("java.io.tmpdir") + File.separator + "log.txt";
FileHandler fh = new FileHandler(datei);
ConsoleHandler ch = new ConsoleHandler();
lg.setUseParentHandlers(false);

// Text-Ausgabe --> SimpleFormatter
// Standard = Default: XMLFormatter --> xml-Format
//fh.setFormatter(new SimpleFormatter());
lg.addHandler(fh);

// besser eigener Formatter:
ch.setFormatter(new MyFormatter());

lg.addHandler(ch);

lg.setLevel(Level.ALL);
}
catch (IOException ioex)
{
System.err.println(ioex);
}
}
}

+ 112
- 0
src/kommunikation/transmitter/BilderKom.java View File

@@ -0,0 +1,112 @@
/*
* 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.transmitter;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.logging.Logger;
import kommunikation.logger.OhmLogger;

/**
*
* @author nobody
*/
public class BilderKom extends Observable implements Observer
{
protected static final Logger lg = OhmLogger.getLogger();
private GrafikModel grafik;
private Transmitter trans;
public BilderKom(int modus )
{
trans = new Transmitter(modus);
grafik = new GrafikModel();
}
public void registerEvents()
{
trans.addObserver(this);
}
public GrafikModel getModel()
{
return grafik;
}
public void start()
{
trans.start();
}
public void setIpPort(String ip,int port)
{
trans.setIpPort(ip, port);
}
public void senden(Object nachricht)
{
trans.senden(nachricht);
}
public Object getNachricht()
{
return trans.getNachricht();
}
public void addFigur(Figur f)
{
grafik.addFigur(f);
}
public void addFigurFremd(Figur f)
{
grafik.addFigurFremd(f);
}
public List<Figur> getFigur()
{
return grafik.getFigur();
}
public void speichereFiguren(File datei)
{
try
{
grafik.speichereFiguren(datei);
}
catch (IOException ex)
{
Logger.getLogger(BilderKom.class.getName()).log(Level.SEVERE, null, ex);
}
}
@SuppressWarnings("unchecked")
public void ladeFiguren(File dateiname)
{
try
{
grafik.ladeFiguren(dateiname);
}
catch (IOException | ClassNotFoundException ex)
{
lg.severe((Supplier<String>) ex);
}
}

@Override
public void update(Observable o, Object arg)
{
this.setChanged();
this.notifyObservers();
}
}

+ 45
- 0
src/kommunikation/transmitter/Client.java View File

@@ -0,0 +1,45 @@
/*
* 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.transmitter;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;


/**
*
* @author Alexander_Christoph
*/
public class Client extends Kommunikationspartner
{
public Client()
{
this.ip = "127.0.0.0";
lg.info("Client erstellt");
}
@Override
public void verbinde()
{
try
{
Socket s = new Socket(ip, port); // Achtung: blockiert!
lg.info("Client: socket erstellt");
out = new ObjectOutputStream(s.getOutputStream());
in = new ObjectInputStream(s.getInputStream());
lg.info("Client: Stream initialisiert");
}
catch (IOException ex)
{
lg.severe(ex.toString());
}
}
}

+ 38
- 0
src/kommunikation/transmitter/Figur.java View File

@@ -0,0 +1,38 @@
/*
* 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.transmitter;

import java.awt.Point;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
*
* @author nobody
*/
public class Figur implements Serializable
{
private ArrayList<Point> punkte;
public Figur()
{
punkte = new ArrayList<>();
}
public void addPoint(Point p)
{
punkte.add(p);
}
public List<Point> getPunkte()
{
return Collections.unmodifiableList(punkte);
}
}

+ 83
- 0
src/kommunikation/transmitter/GrafikModel.java View File

@@ -0,0 +1,83 @@
/*
* 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.transmitter;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Observable;
import java.util.logging.Logger;
import kommunikation.logger.OhmLogger;

/**
*
* @author le
*/
public class GrafikModel extends Observable
{
private ArrayList<Figur> figuren;
private ArrayList<Figur> figurenFremd;
private static final Logger lg = OhmLogger.getLogger();
public GrafikModel()
{
figuren = new ArrayList<>();
figurenFremd = new ArrayList<>();
}
public void addFigurFremd(Figur f)
{
figurenFremd.add(f);
lg.info("fremde Figur wurde hinzugefügt");
}
public void addFigur(Figur f)
{
figuren.add(f);
lg.info("Figur wurde hinzugefügt");
}

public List<Figur> getFigur()
{
return Collections.unmodifiableList(figuren);
}
public List<Figur> getFigurFremd()
{
return Collections.unmodifiableList(figurenFremd);
}
public void speichereFiguren(File datei) throws FileNotFoundException, IOException
{
FileOutputStream fos = new FileOutputStream(datei);
BufferedOutputStream bos = new BufferedOutputStream(fos);
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(figuren);
oos.flush();
oos.close();
}
public void ladeFiguren(File dateiname) throws FileNotFoundException, IOException, ClassNotFoundException
{
FileInputStream fis = new FileInputStream(dateiname);
BufferedInputStream buffin = new BufferedInputStream(fis);
ObjectInputStream ois = new ObjectInputStream(buffin);
figuren = (ArrayList<Figur>) ois.readObject();
ois.close();
}
}

+ 86
- 0
src/kommunikation/transmitter/Kommunikationspartner.java View File

@@ -0,0 +1,86 @@
/*
* 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.transmitter;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.logging.Logger;
import kommunikation.logger.OhmLogger;



/**
*
* @author Alexander_Christoph
*/
public abstract class Kommunikationspartner
{
protected static final Logger lg = OhmLogger.getLogger();
protected int port;
protected String ip;
protected Object nachricht;
protected Figur figur;
protected ObjectInputStream in;
protected ObjectOutputStream out;
public Kommunikationspartner()
{
port = 35000;
ip = "";
}
public abstract void verbinde();
public void senden(Object nachricht)
{
try
{
out.writeObject(nachricht);
}
catch (IOException ex)
{
lg.severe(ex.toString());
}
lg.info("Grafik versendet");
}
public void empfangen()
{
try
{
lg.info("Warte auf Nachricht ...");
nachricht = in.readObject();
lg.info("Nachricht empfangen");
}
catch (IOException | ClassNotFoundException ex)
{
lg.severe(ex.toString());
}
}
public Object getNachricht()
{
return nachricht;
}
public void setPort(int port)
{
this.port = port;
lg.info("Port auf " + port + " gesetzt" );
}
public void setIp(String ip)
{
this.ip = ip;
lg.info("Ip auf " + ip + " gesetzt" );
}
}

+ 49
- 0
src/kommunikation/transmitter/Server.java View File

@@ -0,0 +1,49 @@
/*
* 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.transmitter;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import static kommunikation.transmitter.Kommunikationspartner.lg;

/**
*
* @author Alexander_Christoph
*/
public class Server extends Kommunikationspartner
{
public Server()
{
lg.info("Server erstellt");
}
@Override
public void verbinde()
{
try
{
ServerSocket sSocket = new ServerSocket(port);
lg.info("Server: Warte auf Verbindung ...");
Socket s = sSocket.accept();
lg.info("Server: Verbindung akzeptiert");
out = new ObjectOutputStream(s.getOutputStream());
in = new ObjectInputStream(s.getInputStream());
}
catch (IOException ex)
{
lg.severe(ex.toString());
}
}
}

+ 93
- 0
src/kommunikation/transmitter/Transmitter.java View File

@@ -0,0 +1,93 @@
/*
* 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.transmitter;

import java.util.Observable;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import kommunikation.logger.OhmLogger;

/**
*
* @author Alexander_Christoph
*/
public class Transmitter extends Observable implements Runnable
{
protected static final Logger lg = OhmLogger.getLogger();
private Kommunikationspartner kom;
private Boolean verbindung;
private Thread thd;

public Transmitter(int modus)
{
if (modus == 0)
{
kom = new Client();
}

if (modus == 1)
{
kom = new Server();
}

verbindung = false;
thd = null;
}

public void start()
{
if (thd == null)
{
thd = new Thread(this);
thd.start();
}

}

@Override
public void run()
{
while (true)
{
if (!verbindung)
{
kom.verbinde();
verbindung = true;
}
synchronized (this)
{
kom.empfangen();
}
lg.info("empfangen");
this.setChanged();
this.notifyObservers();
}
}

public void setIpPort(String ip, int port)
{
kom.setPort(port);
kom.setIp(ip);
}

public void senden(Object nachricht)
{
if (verbindung)
{
kom.senden(nachricht);
}
else
{
JOptionPane.showMessageDialog(null, "Bauen Sie zuerst eine Verbindung auf", "Keine Verbindung", JOptionPane.INFORMATION_MESSAGE);
}
}

public Object getNachricht()
{
return kom.getNachricht();
}

}

+ 160
- 0
src/kommunikation/view/GrafikView.java View File

@@ -0,0 +1,160 @@
/*
* 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.view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.util.logging.Logger;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.standard.DialogTypeSelection;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import kommunikation.transmitter.Figur;
import kommunikation.transmitter.GrafikModel;


/**
*
* @author le
*/
public class GrafikView extends JComponent implements Printable
{
private final static Dimension EINS = new Dimension(1, 1);
private final static Logger lg = Logger.getLogger("mvcGrafik");
private Rectangle2D.Float pixel;
private Line2D.Float linie;
private GrafikModel model;

public GrafikView()
{
pixel = new Rectangle2D.Float();
linie = new Line2D.Float();
this.setBackground(Color.WHITE);
}

public void setModel(GrafikModel model)
{
this.model = model;
}

public void drawPoint(Point p)
{
Graphics2D g2 = (Graphics2D) this.getGraphics();
pixel.setFrame(p, EINS);
g2.draw(pixel);
g2.dispose(); // VERY, VERY WICHTIG
}

@Override
public void paintComponent(Graphics g)
{
if (model == null)
{
lg.severe("keine Referenz auf Model vorhanden");
return;
}
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
Point zwischenSpeicher = new Point();
for (Figur f : model.getFigur())
{
g2.setColor(Color.BLACK);
Boolean first = true;
for (Point p : f.getPunkte())
{
pixel.setFrame(p, EINS);
g2.draw(pixel);
if(!first)
{
linie.setLine(zwischenSpeicher, p);
g2.draw(linie);
}
zwischenSpeicher = p;
first = false;
}
}
for (Figur f : model.getFigurFremd())
{
Boolean first = true;
g2.setColor(Color.RED);
for (Point p : f.getPunkte())
{
pixel.setFrame(p, EINS);
g2.draw(pixel);
if(!first)
{
linie.setLine(zwischenSpeicher, p);
g2.draw(linie);
}
zwischenSpeicher = p;
first = false;
}
}
}
public void line(Point p1, Point p2)
{
Graphics2D g2 = (Graphics2D) this.getGraphics();
Line2D.Float lin = new Line2D.Float(p1, p2);
g2.draw(lin);
g2.dispose();
}
public void doPrint()
{
HashPrintRequestAttributeSet printSet =
new HashPrintRequestAttributeSet();
printSet.add(DialogTypeSelection.NATIVE);
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(this);
// Druckdialog
if (pj.printDialog(printSet))
{
try
{
pj.print(printSet);
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(this, ex.toString());
}
}
}

@Override
public int print(Graphics gp, PageFormat pf, int pageIndex) throws PrinterException
{
Graphics2D g2p = (Graphics2D) gp;
Logger lg = Logger.getLogger("mvcGrafik");
lg.info("pgIndex: " + Integer.toString(pageIndex));
if (pageIndex == 0)
{
g2p.translate(pf.getImageableX(), pf.getImageableY());
g2p.scale(pf.getImageableWidth()/this.getWidth(),
pf.getImageableHeight() / this.getHeight());
super.print(g2p);
lg.info("Druck ist möglich");
return Printable.PAGE_EXISTS;
}
else
{
lg.info("Druck ist unmöglich");
return Printable.NO_SUCH_PAGE;
}
}

}

+ 113
- 0
src/kommunikation/view/ViewChat.form View File

@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
<Property name="title" type="java.lang.String" value="Client"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSize" 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,2,119,0,0,3,37"/>
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<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"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Component class="javax.swing.JTextField" name="tfMessage">
<Properties>
<Property name="text" type="java.lang.String" value="Nachricht"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Last"/>
</Constraint>
</Constraints>
</Component>
<Container class="javax.swing.JPanel" name="pnlConnect">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="First"/>
</Constraint>
</Constraints>

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="lblPort">
<Properties>
<Property name="text" type="java.lang.String" value="PORT"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="tfPort">
<Properties>
<Property name="columns" type="int" value="6"/>
<Property name="text" type="java.lang.String" value="port"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblIp">
<Properties>
<Property name="text" type="java.lang.String" value="IP_ADRESSE"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="tfIp">
<Properties>
<Property name="columns" type="int" value="15"/>
<Property name="text" type="java.lang.String" value="ip-Adresse"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnConnect">
<Properties>
<Property name="text" type="java.lang.String" value="Connect"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="pnlChat">
<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.DesignGridLayout">
<Property name="columns" type="int" value="2"/>
<Property name="rows" type="int" value="0"/>
</Layout>
<SubComponents>
<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="taChat">
<Properties>
<Property name="columns" type="int" value="20"/>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="kommunikation.view.GrafikView" name="grafikViewChat">

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

+ 197
- 0
src/kommunikation/view/ViewChat.java View File

@@ -0,0 +1,197 @@
/*
* 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.view;

/**
*
* @author Alexander_Christoph
*/
public class ViewChat extends javax.swing.JFrame
{
/**
* @return the grafikViewChat
*/
public kommunikation.view.GrafikView getGrafikViewChat()
{
return grafikViewChat;
}
/**
* @return the btnConnect
*/
public javax.swing.JButton getBtnConnect()
{
return btnConnect;
}

/**
* @return the taChat
*/
public javax.swing.JTextArea getTaChat()
{
return taChat;
}

/**
* @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 ViewServer
*/
public ViewChat()
{
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents()
{

tfMessage = new javax.swing.JTextField();
pnlConnect = new javax.swing.JPanel();
lblPort = new javax.swing.JLabel();
tfPort = new javax.swing.JTextField();
lblIp = new javax.swing.JLabel();
tfIp = new javax.swing.JTextField();
btnConnect = new javax.swing.JButton();
pnlChat = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane();
taChat = new javax.swing.JTextArea();
grafikViewChat = new kommunikation.view.GrafikView();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Client");

tfMessage.setText("Nachricht");
tfMessage.setToolTipText("");
getContentPane().add(tfMessage, java.awt.BorderLayout.PAGE_END);

lblPort.setText("PORT");
pnlConnect.add(lblPort);

tfPort.setColumns(6);
tfPort.setText("port");
pnlConnect.add(tfPort);

lblIp.setText("IP_ADRESSE");
pnlConnect.add(lblIp);

tfIp.setColumns(15);
tfIp.setText("ip-Adresse");
pnlConnect.add(tfIp);

btnConnect.setText("Connect");
pnlConnect.add(btnConnect);

getContentPane().add(pnlConnect, java.awt.BorderLayout.PAGE_START);

pnlChat.setLayout(new java.awt.GridLayout(0, 2));

taChat.setColumns(20);
taChat.setRows(5);
jScrollPane2.setViewportView(taChat);

pnlChat.add(jScrollPane2);
pnlChat.add(grafikViewChat);

getContentPane().add(pnlChat, java.awt.BorderLayout.CENTER);

setSize(new java.awt.Dimension(805, 631));
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents

/**
* @param args the command line arguments
*/
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()))
{
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
}
catch (ClassNotFoundException ex)
{
java.util.logging.Logger.getLogger(ViewChat.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
catch (InstantiationException ex)
{
java.util.logging.Logger.getLogger(ViewChat.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
catch (IllegalAccessException ex)
{
java.util.logging.Logger.getLogger(ViewChat.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
catch (javax.swing.UnsupportedLookAndFeelException ex)
{
java.util.logging.Logger.getLogger(ViewChat.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
//</editor-fold>
//</editor-fold>

/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
new ViewChat().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnConnect;
private kommunikation.view.GrafikView grafikViewChat;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JLabel lblIp;
private javax.swing.JLabel lblPort;
private javax.swing.JPanel pnlChat;
private javax.swing.JPanel pnlConnect;
private javax.swing.JTextArea taChat;
private javax.swing.JTextField tfIp;
private javax.swing.JTextField tfMessage;
private javax.swing.JTextField tfPort;
// End of variables declaration//GEN-END:variables
}

Loading…
Cancel
Save