> OK,
> i have fixed the code, now it compiles with no errors. The problem is
[quoted text clipped - 12 lines]
>
> class Server extends JFrame{
here's a hint....
> JFrame mainFrame = null;
> JTextArea text = new JTextArea();
> JTextField line = new JTextField();
> JButton button = new JButton("Ijungti");
> JLabel label = new JLabel("");
> turnOn init;
snipped
Noodles Jefferson - 03 Dec 2005 00:26 GMT
> > OK,
> > i have fixed the code, now it compiles with no errors. The problem is
[quoted text clipped - 4 lines]
> > =============================================================
> > import java.lang.*;
You don't have to import java.lang.*;
It's already automatically imported into every program you write.
> > import java.util.*;
> > import java.io.*;
[quoted text clipped - 16 lines]
>
> snipped

Signature
Noodles Jefferson
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM
"Our earth is degenerate in these latter days, bribery and corruption
are common, children no longer obey their parents and the end of the
world is evidently approaching."
--Assyrian clay tablet 2800 B.C.
> OK,
> i have fixed the code, now it compiles with no errors. The problem is
[quoted text clipped - 10 lines]
> import javax.swing.*;
> import java.net.*;
This what you are actually using.. no big deal.
import java.awt.Container;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
Not sure why you have this. It is not used/referenced.
> JFrame mainFrame = null;
> JTextArea text = new JTextArea();
> JTextField line = new JTextField();
[quoted text clipped - 18 lines]
> button.setBounds(25, 100, 100, 25);
> label.setBounds(25, 50, 100, 25);
Add this..
this.setVisible(true);
> init = new turnOn();
> }

Signature
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
My style is to run through code, highlighting anything that pops out at
me (as not been written by myself). Don't take it personally...
> import java.lang.*;
> import java.util.*;
[quoted text clipped - 3 lines]
> import javax.swing.*;
> import java.net.*;
Is there anything you don't want? :) It generally makes things easier to
understand, test and debug if each (outer) class is in its own file and
has a definite field of responsibility.
> class Server extends JFrame{
It's also generally a bad idea to extend a class that you do not need to.
> JFrame mainFrame = null;
Particularly when you do this. :) Although you don't appear to have used it.
> text.setBounds(150, 0, 140, 150);
> line.setBounds(150, 155, 140, 18);
> button.setBounds(25, 100, 100, 25);
> label.setBounds(25, 50, 100, 25);
Learn the layout managers, for they obsolete this kind of nonsense. Just
skip SpringLayout, that sucks.
> class turnOn {
It's much easier to understand code if it all uses the same conventions.
Fortunately the Java conventions are well established.
> label.setText("error..");
> System.exit(-1);
That text is unlikely ever to see the light of day (unless you have a
SecurityManager set).
> while(true) {
> try {
> Socket clientSocket = serverSocket.accept();
Is this going to stop this thread inappropriately? Given that we have
used Swing components, we should be on the AWT Event Dispatch Thread
(EDT), and therefore should return promptly. In your case, to return
promptly to main, where you setVisible on the frame. This appears to be
your problem.
> public class client extends Thread {
Again, don't extend classes you do not need to. Implement Runnable and
pass that to a Thread constructor.
> in = new BufferedReader(new
> InputStreamReader(soket.getInputStream()));
> out = new PrintWriter(new
> OutputStreamWriter(soket.getOutputStream()));
You probably want to specify the character set for InputStreamReader and
OutputStreamWriter. The default is to pick up whatever the server
happens to be configured for at the time. UTF-8 or ISO-8859-1 are useful
choices (see java.nio.charset.CharSet class description).
As you are (attempting) to close the socket it wouldn't matter in this
case, but to be very picky if, say, the BufferedReader were to fail
construction (OutOfMemoryError, say) then you would not be able to close
the underlying stream. But parts of java.io get that wrong anyway.
> while(run) {
> String klient = in.readLine();
BufferedReader.readLine will return null when the socket stream is closed.
> finally {
> try {
> in.close();
> out.close();
Depending on the failure, these streams may not have been created yet.
Further, in situations like this, if closing the first stream fails, the
second one will not even be attempted.
> public static void main(String[] arg) {
> new Server().setVisible(true);
> }
You need some outrageous boilerplate here (or somewhere) to run the
Swing code in the Event Dispatch Thread (EDT).
public static void main(String[] arg) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Server().setVisible(true);
}
});
}
It's probably worth googling for Swing threading articles. Although they
aren't all entirely accurate, they might be more helpful than me.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
>text.setBounds(150, 0, 140, 150);
> line.setBounds(150, 155, 140, 18);
> button.setBounds(25, 100, 100, 25);
> label.setBounds(25, 50, 100, 25);
you are coding in C here. See http://mindprod.com/jgloss/layout.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.