/* | |||||
* 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; | package chatprogramm; | ||||
import chatprogramm.controller.ConnectController; | import chatprogramm.controller.ConnectController; | ||||
import chatprogramm.view.ChatView; | import chatprogramm.view.ChatView; | ||||
/** | /** | ||||
* Builder Class | |||||
* @author le | |||||
* | |||||
* @author Marian | |||||
*/ | */ | ||||
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); | |||||
} | |||||
public class Start { | |||||
/** | |||||
* @param args the command line arguments | |||||
*/ | |||||
public static void main(String[] args) | |||||
{ | |||||
new Start(); | |||||
} | |||||
public Start() | |||||
{ | |||||
ChatView view = new ChatView(); | |||||
Transmitter model = new Transmitter(); | |||||
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); | |||||
} | |||||
/** | |||||
* @param args the command line arguments | |||||
*/ | |||||
public static void main(String[] args) | |||||
{ | |||||
Start start = new Start(); | |||||
} | |||||
} | } |
/* | |||||
* 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; | package chatprogramm.controller; | ||||
import chatprogramm.logger.OhmLogger; | |||||
import chatprogramm.model.Transmitter; | import chatprogramm.model.Transmitter; | ||||
import chatprogramm.logger.OhmLogger; | |||||
import chatprogramm.view.ChatView; | 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 java.util.logging.Logger; | ||||
import javax.swing.JOptionPane; | 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; | |||||
public ConnectController(ChatView view, Transmitter model) | |||||
{ | |||||
this.view = view; | |||||
this.model = model; | |||||
chooseConnection(); | |||||
} | |||||
void chooseConnection() | |||||
{ | |||||
Object[] options = {"Client", "Server"}; | |||||
int choice = JOptionPane.showOptionDialog(view, "Wähle deine Verbindungsart:", "Client oder Server", 0, 1, null, options, null); | |||||
if(choice == 1) | |||||
{ | |||||
logger.info("Server"); | |||||
String port = JOptionPane.showInputDialog(view, "PORT eingeben"); | |||||
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(); | |||||
} | |||||
private Transmitter model; | |||||
private ChatView view; | |||||
private static Logger logger = OhmLogger.getLogger(); | |||||
} | |||||
public void startServer() | |||||
{ | |||||
try | |||||
public ConnectController(Transmitter m, ChatView v) | |||||
{ | { | ||||
model.createServer(port); | |||||
this.model = m; | |||||
this.view = v; | |||||
} | } | ||||
catch (IOException ex) | |||||
public void registerEvents() | |||||
{ | { | ||||
Logger.getLogger(ConnectController.class.getName()).log(Level.SEVERE, null, ex); | |||||
this.view.getBtConnect().addActionListener(this); | |||||
this.view.getRbClient().addActionListener(this); | |||||
this.view.getRbServer().addActionListener(this); | |||||
} | } | ||||
} | |||||
public void startClient() | |||||
{ | |||||
try | |||||
@Override | |||||
public void actionPerformed(ActionEvent ae) | |||||
{ | { | ||||
model.createClient(port, ip); | |||||
Object o = ae.getSource(); | |||||
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; | |||||
} | |||||
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()); | |||||
} | |||||
} | } | ||||
catch (IOException ex) | |||||
{ | |||||
Logger.getLogger(ConnectController.class.getName()).log(Level.SEVERE, null, ex); | |||||
private boolean validIP (String ip) { | |||||
try { | |||||
if ( ip == null || ip.isEmpty() ) { | |||||
return false; | |||||
} | |||||
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; | |||||
} | |||||
} | } | ||||
} | |||||
} | } |
/* | |||||
* 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; | package chatprogramm.controller; | ||||
import chatprogramm.model.Transmitter; | |||||
import chatprogramm.view.ChatView; | import chatprogramm.view.ChatView; | ||||
import java.util.Observable; | import java.util.Observable; | ||||
import java.util.Observer; | import java.util.Observer; | ||||
/** | /** | ||||
* | * | ||||
* @author Gerhard | |||||
* @author Marian | |||||
*/ | */ | ||||
public class ReceiveAdapterController implements Observer | public class ReceiveAdapterController implements Observer | ||||
{ | { | ||||
private ChatView view; | |||||
private Transmitter model; | |||||
public ReceiveAdapterController(ChatView view, Transmitter model) | |||||
{ | |||||
this.view = view; | |||||
this.model = model; | |||||
} | |||||
@Override | |||||
public void update(Observable o, Object arg) | |||||
{ | |||||
} | |||||
private ChatView view; | |||||
public ReceiveAdapterController(ChatView view) | |||||
{ | |||||
this.view = view; | |||||
} | |||||
@Override | |||||
public void update(Observable observable, Object object) | |||||
{ | |||||
String msg = (String)object; | |||||
view.getTaCommunication().append(msg + "\n"); | |||||
} | |||||
} | } |
/* | |||||
* 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; | package chatprogramm.controller; | ||||
import chatprogramm.model.Transmitter; | import chatprogramm.model.Transmitter; | ||||
import chatprogramm.view.ChatView; | 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; | |||||
public SendController(ChatView view, Transmitter model) | |||||
{ | |||||
this.view = view; | |||||
this.model = model; | |||||
} | |||||
private Transmitter model; | |||||
private ChatView view; | |||||
public SendController(Transmitter m, ChatView v) | |||||
{ | |||||
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(""); | |||||
} | |||||
} | } |
/* | |||||
* 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; | package chatprogramm.model; | ||||
import chatprogramm.logger.OhmLogger; | import chatprogramm.logger.OhmLogger; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
import java.io.UnsupportedEncodingException; | |||||
import java.net.Socket; | import java.net.Socket; | ||||
import java.util.Observable; | |||||
import java.util.logging.Level; | |||||
import java.util.logging.Logger; | 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"; | |||||
public Client(int port, String ip) throws IOException | |||||
{ | |||||
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"); | |||||
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(); | |||||
BufferedReader in = new BufferedReader(isr); | |||||
//BufferedWriter out = new BufferedWriter(osr); | |||||
PrintWriter out = new PrintWriter(osr); | |||||
lg.info("Client: Stream initialisiert"); | |||||
public Client(String ip, int port) | |||||
{ | |||||
this.ip = ip; | |||||
this.port = port; | |||||
this.socket = null; | |||||
this.reader = null; | |||||
this.writer = null; | |||||
this.ready = false; | |||||
this.thd = null; | |||||
} | |||||
out.println("Hallo Du Server Du - ich bin der client"); | |||||
out.flush(); // wirklich absenden!! | |||||
public void init() | |||||
{ | |||||
if (thd == null) { | |||||
thd = new Thread(this); | |||||
thd.start(); | |||||
} | |||||
} | |||||
lg.info("Client: Nachricht versendet"); | |||||
String quittung = in.readLine(); // Achtung blockiert | |||||
lg.info("Client: Quittung empfangen"); | |||||
public void sendMessage(String msg) | |||||
{ | |||||
if (ready) { | |||||
writer.println(msg); | |||||
writer.flush(); | |||||
} else { | |||||
logger.warning("Server not ready to send message. Connect first"); | |||||
} | |||||
} | |||||
System.out.println("Client: Quittung EMPFANGEN - " + quittung); | |||||
@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; | |||||
} | |||||
out.close(); | |||||
in.close(); | |||||
} | |||||
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); | |||||
} | |||||
} | |||||
} | |||||
} | } |
/* | |||||
* 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; | package chatprogramm.model; | ||||
import chatprogramm.logger.OhmLogger; | import chatprogramm.logger.OhmLogger; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
import java.io.UnsupportedEncodingException; | |||||
import java.net.ServerSocket; | import java.net.ServerSocket; | ||||
import java.net.Socket; | 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; | 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; | |||||
public Server(int port) throws IOException | |||||
{ | |||||
if(port != 0) | |||||
{ | |||||
this.PORT = port; | |||||
} | |||||
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(); | |||||
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"); | |||||
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("Server: Stream initialisiert"); | |||||
lg.info("Server: warte auf Nachricht ..."); | |||||
public Server(int port) | |||||
{ | |||||
this.port = port; | |||||
this.server = null; | |||||
this.client = null; | |||||
this.reader = null; | |||||
this.writer = null; | |||||
this.ready = false; | |||||
this.thd = null; | |||||
} | |||||
String nachricht = in.readLine(); // Achtung blockiert | |||||
lg.info("Server: Nachricht empfangen"); | |||||
public void init() | |||||
{ | |||||
if (thd == null) { | |||||
thd = new Thread(this); | |||||
thd.start(); | |||||
} | |||||
} | |||||
@Override | |||||
public void run() | |||||
{ | |||||
logger.info("Running server..."); | |||||
while (true) | |||||
{ | |||||
if (server == null) { | |||||
try { | |||||
server = new ServerSocket(port); | |||||
} catch (IOException e) { | |||||
logger.severe(e.toString()); | |||||
return; | |||||
} | |||||
logger.info("Waiting for client to connect"); | |||||
try { | |||||
client = server.accept(); | |||||
} catch (IOException e) { | |||||
logger.severe(e.toString()); | |||||
return; | |||||
} | |||||
logger.info("Client connected"); | |||||
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; | |||||
} | |||||
System.out.println("Server: NACHRICHT EMPFANGEN - " + nachricht); | |||||
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.println("Server -> ich habe die Nachricht erhalten"); | |||||
lg.info("Server: Quittung versendet"); | |||||
reader = new BufferedReader(isr); | |||||
writer = new PrintWriter(osr); | |||||
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; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
out.flush(); // wirklich absenden!! | |||||
public void sendMessage(String msg) | |||||
{ | |||||
if (ready) { | |||||
writer.println(msg); | |||||
writer.flush(); | |||||
} else { | |||||
logger.warning("Server not ready to send message. Connect first"); | |||||
} | |||||
} | |||||
out.close(); | |||||
in.close(); | |||||
} | |||||
} | } |
/* | |||||
* 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; | 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; | |||||
public Transmitter() | |||||
{ | |||||
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 connectToPeer(boolean mode, String ip, int port) | |||||
{ | |||||
if (initialized) { | |||||
logger.info("Chat already running"); | |||||
return; | |||||
} | |||||
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) | |||||
{ | |||||
if (!initialized) { | |||||
logger.warning("Chat not initialized"); | |||||
return; | |||||
} | |||||
if (mode) { | |||||
srv.sendMessage(msg); | |||||
} else { | |||||
cli.sendMessage(msg); | |||||
} | |||||
} | |||||
} | |||||
public void createServer(int port) throws IOException | |||||
{ | |||||
server = new Server(port); | |||||
} | |||||
public void createClient(int port, String ip) throws IOException | |||||
{ | |||||
client = new Client(port, ip); | |||||
} | |||||
@Override | |||||
public void update(Observable o, Object o1) | |||||
{ | |||||
this.setChanged(); | |||||
this.notifyObservers(o1); | |||||
} | |||||
} | } |
<?xml version="1.0" encoding="UTF-8" ?> | <?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> | <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> | </NonVisualComponents> | ||||
<Properties> | <Properties> | ||||
<Property name="defaultCloseOperation" type="int" value="3"/> | <Property name="defaultCloseOperation" type="int" value="3"/> | ||||
</Properties> | </Properties> | ||||
<SyntheticProperties> | <SyntheticProperties> | ||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> | |||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/> | <SyntheticProperty name="formSizePolicy" type="int" value="1"/> | ||||
<SyntheticProperty name="generateCenter" type="boolean" value="true"/> | |||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/> | |||||
</SyntheticProperties> | </SyntheticProperties> | ||||
<AuxValues> | <AuxValues> | ||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> | ||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> | ||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> | ||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> | <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> | </AuxValues> | ||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> | |||||
<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> | <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> | |||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1"> | |||||
<AuxValues> | |||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> | |||||
</AuxValues> | |||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> | |||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> | |||||
<SubComponents> | <SubComponents> | ||||
<Component class="javax.swing.JButton" name="btnSend"> | |||||
<Component class="javax.swing.JTextArea" name="taCommunication"> | |||||
<Properties> | <Properties> | ||||
<Property name="text" type="java.lang.String" value="send"/> | |||||
<Property name="columns" type="int" value="20"/> | |||||
<Property name="rows" type="int" value="5"/> | |||||
</Properties> | </Properties> | ||||
</Component> | </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> | |||||
<SubComponents> | |||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1"> | |||||
<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="taEmpfangen"> | |||||
<Properties> | |||||
<Property name="columns" type="int" value="20"/> | |||||
<Property name="rows" type="int" value="5"/> | |||||
</Properties> | |||||
</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"> | |||||
<Properties> | |||||
<Property name="columns" type="int" value="20"/> | |||||
<Property name="rows" type="int" value="5"/> | |||||
</Properties> | |||||
</Component> | |||||
</SubComponents> | |||||
</Container> | |||||
</SubComponents> | </SubComponents> | ||||
</Container> | </Container> | ||||
<Component class="javax.swing.JTextField" name="tfMessage"> | |||||
</Component> | |||||
<Component class="javax.swing.JButton" name="btSend"> | |||||
<Properties> | |||||
<Property name="text" type="java.lang.String" value="send"/> | |||||
</Properties> | |||||
</Component> | |||||
<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> | </SubComponents> | ||||
</Form> | </Form> |
/** | /** | ||||
* | * | ||||
* @author Gerhard | |||||
* @author max | |||||
*/ | */ | ||||
public class ChatView extends javax.swing.JFrame | |||||
{ | |||||
/** | |||||
* @return the btnClear | |||||
*/ | |||||
public javax.swing.JButton getBtnClear() | |||||
{ | |||||
return btnClear; | |||||
} | |||||
/** | |||||
* @return the btnSend | |||||
*/ | |||||
public javax.swing.JButton getBtnSend() | |||||
{ | |||||
return btnSend; | |||||
} | |||||
/** | |||||
* @return the taEmpfangen | |||||
*/ | |||||
public javax.swing.JTextArea getTaEmpfangen() | |||||
{ | |||||
return taEmpfangen; | |||||
} | |||||
/** | |||||
* @return the taSenden | |||||
*/ | |||||
public javax.swing.JTextArea getTaSenden() | |||||
{ | |||||
return taSenden; | |||||
} | |||||
/** | |||||
* Creates new form ChatView | |||||
*/ | |||||
public ChatView() | |||||
{ | |||||
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() | |||||
{ | |||||
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(); | |||||
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(); | |||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | |||||
chatControll.setLayout(new java.awt.FlowLayout()); | |||||
btnSend.setText("send"); | |||||
chatControll.add(btnSend); | |||||
btnClear.setText("clear"); | |||||
chatControll.add(btnClear); | |||||
btnServer.setText("jButton1"); | |||||
chatControll.add(btnServer); | |||||
jButton1.setText("jButton1"); | |||||
chatControll.add(jButton1); | |||||
getContentPane().add(chatControll, java.awt.BorderLayout.PAGE_END); | |||||
chatContent.setLayout(new javax.swing.BoxLayout(chatContent, javax.swing.BoxLayout.PAGE_AXIS)); | |||||
taEmpfangen.setColumns(20); | |||||
taEmpfangen.setRows(5); | |||||
jScrollPane1.setViewportView(taEmpfangen); | |||||
chatContent.add(jScrollPane1); | |||||
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); | |||||
pack(); | |||||
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 | |||||
public class ChatView extends javax.swing.JFrame { | |||||
/** | |||||
* @return the rbClient | |||||
*/ | */ | ||||
try | |||||
{ | |||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) | |||||
{ | |||||
if ("Nimbus".equals(info.getName())) | |||||
{ | |||||
javax.swing.UIManager.setLookAndFeel(info.getClassName()); | |||||
break; | |||||
} | |||||
} | |||||
public javax.swing.JRadioButton getRbClient() { | |||||
return rbClient; | |||||
} | } | ||||
catch (ClassNotFoundException ex) | |||||
{ | |||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |||||
/** | |||||
* @return the rbServer | |||||
*/ | |||||
public javax.swing.JRadioButton getRbServer() { | |||||
return rbServer; | |||||
} | |||||
/** | |||||
* @return the btConnect | |||||
*/ | |||||
public javax.swing.JButton getBtConnect() { | |||||
return btConnect; | |||||
} | } | ||||
catch (InstantiationException ex) | |||||
{ | |||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |||||
/** | |||||
* @return the btSend | |||||
*/ | |||||
public javax.swing.JButton getBtSend() { | |||||
return btSend; | |||||
} | } | ||||
catch (IllegalAccessException ex) | |||||
{ | |||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |||||
/** | |||||
* @return the lbIP | |||||
*/ | |||||
public javax.swing.JLabel getLbIP() { | |||||
return lbIP; | |||||
} | } | ||||
catch (javax.swing.UnsupportedLookAndFeelException ex) | |||||
{ | |||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |||||
/** | |||||
* @return the lbPort | |||||
*/ | |||||
public javax.swing.JLabel getLbPort() { | |||||
return lbPort; | |||||
} | } | ||||
//</editor-fold> | |||||
/* Create and display the form */ | |||||
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.JScrollPane jScrollPane1; | |||||
private javax.swing.JScrollPane jScrollPane2; | |||||
private javax.swing.JTextArea taEmpfangen; | |||||
private javax.swing.JTextArea taSenden; | |||||
// End of variables declaration//GEN-END:variables | |||||
/** | |||||
* @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() { | |||||
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() { | |||||
bgSelect = new javax.swing.ButtonGroup(); | |||||
jScrollPane1 = new javax.swing.JScrollPane(); | |||||
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); | |||||
taCommunication.setColumns(20); | |||||
taCommunication.setRows(5); | |||||
jScrollPane1.setViewportView(taCommunication); | |||||
btSend.setText("send"); | |||||
tfPort.setText("3210"); | |||||
tfPort.setToolTipText(""); | |||||
lbPort.setText("Port:"); | |||||
lbPort.setToolTipText(""); | |||||
lbIP.setText("IP:"); | |||||
tfIP.setText("127.0.0.1"); | |||||
btConnect.setText("connect"); | |||||
btConnect.setToolTipText(""); | |||||
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); | |||||
} | |||||
}); | |||||
bgSelect.add(rbServer); | |||||
rbServer.setText("Server"); | |||||
rbServer.addActionListener(new java.awt.event.ActionListener() { | |||||
public void actionPerformed(java.awt.event.ActionEvent evt) { | |||||
rbServerActionPerformed(evt); | |||||
} | |||||
}); | |||||
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(); | |||||
}// </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[]) { | |||||
/* 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(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); | |||||
} catch (InstantiationException ex) { | |||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, 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) { | |||||
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() { | |||||
new ChatView().setVisible(true); | |||||
} | |||||
}); | |||||
} | |||||
// Variables declaration - do not modify//GEN-BEGIN:variables | |||||
private javax.swing.ButtonGroup bgSelect; | |||||
private javax.swing.JButton btConnect; | |||||
private javax.swing.JButton btSend; | |||||
private javax.swing.JScrollPane jScrollPane1; | |||||
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 | |||||
} | } |