import java.awt.*;
import java.io.*;
import java.applet.Applet;
import java.net.*;
import sun.audio.*;
import symantec.itools.awt.Label3D;
import javax.swing.JOptionPane;
import java.text.*;
import java.applet.AudioClip;
import java.net.URL;
import java.net.MalformedURLException;
public class Frame1 extends Frame
{
BufferedReader in = null;
PrintWriter out = null;
BufferedReader eingabe = null;
Socket client = null;
//Thread writeThread;
writeThread write = null;
String text = null;
int port = 0;
String host = null;
String nick = null;
public Frame1()
{
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setLayout(null);
setBackground(java.awt.Color.black);
setSize(451,362);
setVisible(false);
add(tf1);
tf1.setBackground(java.awt.Color.white);
tf1.setForeground(java.awt.Color.darkGray);
tf1.setBounds(12,84,132,24);
add(tf2);
tf2.setBackground(java.awt.Color.white);
tf2.setBounds(12,120,132,24);
add(tf3);
tf3.setBackground(java.awt.Color.white);
tf3.setBounds(12,156,132,24);
add(Tausgabe);
Tausgabe.setBackground(java.awt.Color.white);
Tausgabe.setBounds(12,228,228,120);
button1.setLabel("Verbinden");
add(button1);
button1.setBackground(java.awt.Color.lightGray);
button1.setBounds(324,120,98,25);
button2.setLabel("Senden");
add(button2);
button2.setBackground(java.awt.Color.lightGray);
button2.setBounds(324,192,98,25);
panel3.setLayout(null);
add(panel3);
panel3.setBackground(java.awt.Color.orange);
panel3.setForeground(java.awt.Color.orange);
panel3.setBounds(108,12,12,37);
button3.setLabel("Beenden");
add(button3);
button3.setBackground(java.awt.Color.lightGray);
button3.setBounds(324,156,98,25);
add(text1);
text1.setBackground(java.awt.Color.white);
text1.setBounds(12,192,132,24);
label1.setText("IP-Nummer");
add(label1);
label1.setForeground(java.awt.Color.orange);
label1.setBounds(156,84,75,26);
label2.setText("Port");
add(label2);
label2.setForeground(java.awt.Color.orange);
label2.setBounds(156,120,48,24);
label3.setText("Nickname");
add(label3);
label3.setForeground(java.awt.Color.orange);
label3.setBounds(156,156,60,24);
label4.setText("Nachricht eingeben");
add(label4);
label4.setForeground(java.awt.Color.orange);
label4.setBounds(156,192,108,24);
panel1.setLayout(null);
add(panel1);
panel1.setBackground(java.awt.Color.orange);
panel1.setBounds(0,48,447,12);
panel2.setLayout(null);
add(panel2);
panel2.setBackground(java.awt.Color.orange);
panel2.setBounds(0,0,447,12);
label5.setText("Chat");
label5.setAlignment(java.awt.Label.CENTER);
add(label5);
label5.setForeground(java.awt.Color.white);
label5.setFont(new Font("Dialog", Font.PLAIN, 40));
label5.setBounds(168,12,96,36);
panel4.setLayout(null);
add(panel4);
panel4.setBackground(java.awt.Color.orange);
panel4.setForeground(java.awt.Color.orange);
panel4.setBounds(312,12,12,37);
panel5.setLayout(null);
add(panel5);
panel5.setBackground(java.awt.Color.orange);
panel5.setForeground(java.awt.Color.orange);
panel5.setBounds(48,12,12,37);
panel6.setLayout(null);
add(panel6);
panel6.setBackground(java.awt.Color.orange);
panel6.setForeground(java.awt.Color.orange);
panel6.setBounds(372,12,12,37);
button5.setLabel("?");
add(button5);
button5.setBackground(java.awt.Color.lightGray);
button5.setBounds(240,84,12,24);
button6.setLabel("?");
add(button6);
button6.setBackground(java.awt.Color.lightGray);
button6.setBounds(204,120,12,24);
button7.setLabel("?");
add(button7);
button7.setBackground(java.awt.Color.lightGray);
button7.setBounds(228,156,12,24);
button4.setLabel("?");
add(button4);
button4.setBackground(java.awt.Color.lightGray);
button4.setBounds(276,192,12,24);
button8.setLabel("Anleitung");
add(button8);
button8.setBackground(java.awt.Color.lightGray);
button8.setBounds(324,228,98,25);
label6.setText("©PhantomFreak");
add(label6);
label6.setBackground(java.awt.Color.white);
label6.setBounds(348,348,93,12);
setTitle("A Simple Frame");
//}}
//{{INIT_MENUS
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymAction lSymAction = new SymAction();
button1.addActionListener(lSymAction);
button2.addActionListener(lSymAction);
button3.addActionListener(lSymAction);
button5.addActionListener(lSymAction);
button6.addActionListener(lSymAction);
button7.addActionListener(lSymAction);
button4.addActionListener(lSymAction);
button8.addActionListener(lSymAction);
//}}
}
public Frame1(String title)
{
this();
setTitle(title);
}
/**
* Shows or hides the component depending on the boolean flag b.
* @param b if true, show the component; otherwise, hide the component.
* @see java.awt.Component#isVisible
*/
public void setVisible(boolean b)
{
if(b)
{
setLocation(50, 50);
}
super.setVisible(b);
}
static public void main(String args[])
{
(new Frame1()).setVisible(true);
}
public void addNotify()
{
// Record the size of the window prior to calling parents addNotify.
Dimension d = getSize();
super.addNotify();
if (fComponentsAdjusted)
return;
// Adjust components according to the insets
Insets insets = getInsets();
setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height);
Component components[] = getComponents();
for (int i = 0; i < components.length; i++)
{
Point p = components[i].getLocation();
p.translate(insets.left, insets.top);
components[i].setLocation(p);
}
fComponentsAdjusted = true;
}
// Used for addNotify check.
boolean fComponentsAdjusted = false;
//{{DECLARE_CONTROLS
java.awt.TextField tf1 = new java.awt.TextField();
java.awt.TextField tf2 = new java.awt.TextField();
java.awt.TextField tf3 = new java.awt.TextField();
java.awt.TextArea Tausgabe = new java.awt.TextArea();
java.awt.Button button1 = new java.awt.Button();
java.awt.Button button2 = new java.awt.Button();
java.awt.Panel panel3 = new java.awt.Panel();
java.awt.Button button3 = new java.awt.Button();
java.awt.TextField text1 = new java.awt.TextField();
java.awt.Label label1 = new java.awt.Label();
java.awt.Label label2 = new java.awt.Label();
java.awt.Label label3 = new java.awt.Label();
java.awt.Label label4 = new java.awt.Label();
java.awt.Panel panel1 = new java.awt.Panel();
java.awt.Panel panel2 = new java.awt.Panel();
java.awt.Label label5 = new java.awt.Label();
java.awt.Panel panel4 = new java.awt.Panel();
java.awt.Panel panel5 = new java.awt.Panel();
java.awt.Panel panel6 = new java.awt.Panel();
java.awt.Button button5 = new java.awt.Button();
java.awt.Button button6 = new java.awt.Button();
java.awt.Button button7 = new java.awt.Button();
java.awt.Button button4 = new java.awt.Button();
java.awt.Button button8 = new java.awt.Button();
java.awt.Label label6 = new java.awt.Label();
//}}
//{{DECLARE_MENUS
//}}
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == Frame1.this)
Frame1_WindowClosing(event);
}
}
void Frame1_WindowClosing(java.awt.event.WindowEvent event)
{
setVisible(false); // hide the Frame
}
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == button1)
button1_ActionPerformed(event);
else if (object == button2)
button2_ActionPerformed(event);
else if (object == button3)
button3_ActionPerformed(event);
if (object == button5)
button5_ActionPerformed(event);
else if (object == button6)
button6_ActionPerformed(event);
else if (object == button7)
button7_ActionPerformed(event);
else if (object == button4)
button4_ActionPerformed(event);
else if (object == button8)
button8_ActionPerformed(event);
}
}
void button1_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
try
{
eingabe = new BufferedReader(new InputStreamReader(System.in));
host = (tf1.getText());//"192.168.110.106";//"wst.no-ip.com";
port = Integer.parseInt(tf2.getText());//8765;//6000
nick = (tf3.getText()) ; //Den eigenen Namen einfügen
client = new Socket(host, port);
System.out.println("\nVerbindung mit " + host + " auf Port " + port + " hergestellt ...");
//Tausgabe.setText("\nVerbindung mit " + host + " auf Port " + port + " hergestellt ...");
in = new BufferedReader(new InputStreamReader(client.getInputStream()));
out = new PrintWriter(client.getOutputStream(), true);
write = new writeThread(in);
write.start();
}
catch (IOException e)
{
// nichts
}
}
void button2_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
try
{
text=text1.getText();
//connect.play();
//System.out.println(nick+": "+text);
Tausgabe.append(nick+": "+text+"\n");
//connect.play();
}
catch (Exception e)
{
// nichts
}
}
void button3_ActionPerformed(java.awt.event.ActionEvent event)
{
// to do: code goes here.
try
{
client.close();
eingabe.close();
out.close();
}
catch (IOException e)
{
// nichts
}
} class writeThread extends Thread
{
BufferedReader in = null;
public writeThread(BufferedReader in)
{
this.in = in;
}
public void run()
{
try
{
while ((text = in.readLine())!=null)
{
Tausgabe.append(text+"\n");
}
}catch (IOException e)
{
// nichts
}
}
}
class chat
{
}