Murdoc
asked on
Thread problem
Hi
I'm trying to develope simple application with threads.
The problem is that i cannot in thread add line to table model
:((( (message: "cannot resolve symbol listmodel " " appears all the time )
'cause i'm newbie and because earlier i was using delphi which is a bit more friendly (but i have finished with delphi)
Here is my source code:
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ----
import java.util.Random;
import javax.swing.JSpinner;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class watek {
public static JFrame w = new JFrame();
public static JPanel jp = new JPanel();
public static JPanel jpa = new JPanel();
public static JPanel jpan = new JPanel();
public static DefaultListModel listModel = new DefaultListModel(); ;
public static JList list = new JList(listModel);
public static JRadioButton jrb = new JRadioButton();
public static JRadioButton jrb1 = new JRadioButton();
public static JLabel jl = new JLabel();
public static JLabel jl1 = new JLabel();
public static JTextField jtf = new JTextField();
public static JSpinner js = new JSpinner();
public static JButton jb = new JButton("Connect");
public static JTextField tf = new JTextField();
public static JButton jb1 = new JButton("Disconnect");
public static void main(String args[])
{
//listModel.addElement(in. readLine() );
jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEven t event)
{
// listModel = new DefaultListModel();
myThread newThread = new myThread("bialystok.ircnet .pl","6667 ");
Thread thisThread = new Thread ( newThread );
thisThread.start();
}
});
w.setDefaultCloseOperation (JFrame.EX IT_ON_CLOS E);
Container content = w.getContentPane();
//jp.setBackground(Color.b lue);
//jpa.setBackground(Color. red);
//jpan.setBackground(Color .yellow);
js.setPreferredSize(new java.awt.Dimension(55, 18));
list.setPreferredSize(new java.awt.Dimension(200,100 ));
jtf.setPreferredSize(new java.awt.Dimension(65,18)) ;
jrb.setText("UDP");
jrb1.setText("TCP");
jl.setText("Host:");
jl1.setText("Port:");
jp.setLayout(new BoxLayout(jp,BoxLayout.LIN E_AXIS));
jp.add(jrb);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(jrb1);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(jl);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(jtf);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(jl1);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(js);
jpa.setLayout(new BoxLayout(jpa,BoxLayout.LI NE_AXIS));
jpa.add(jb);
jpa.add(Box.createHorizont alStrut(5) );
jpa.add(new JSeparator(SwingConstants. VERTICAL)) ;
jpa.add(Box.createHorizont alStrut(5) );
jpa.add(tf);
jpa.add(Box.createHorizont alStrut(5) );
jpa.add(new JSeparator(SwingConstants. VERTICAL)) ;
jpa.add(Box.createHorizont alStrut(5) );
jpa.add(jb1);
w.getContentPane().add(jp, BorderLayo ut.PAGE_ST ART);
w.getContentPane().add(lis t,BorderLa yout.CENTE R);
w.getContentPane().add(jpa ,BorderLay out.PAGE_E ND);
//setSize(600,100);
w.pack();
w.setVisible(true);
}
}
class myThread implements Runnable {
private String leport,lehost;
public myThread (String host, String port)
{
lehost=host;
leport=port;
}
public void run() {
try {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.i n));
Socket kkSocket = null;
PrintWriter out = null;
BufferedReader in = null;
kkSocket = new Socket(lehost,Integer.valu eOf(leport .toString( )).intValu e());
out = new PrintWriter(kkSocket.getOu tputStream (), true); //
in = new BufferedReader(new InputStreamReader(kkSocket .getInputS tream()));
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.i n));
String fromServer, fromUser;
out.println("NICK jobob");
while ((fromServer = in.readLine()) != null)
{
boolean lpuh=fromServer.equals("NO TICE AUTH :*** Looking up your hostname...");
if (lpuh==true)
{
out.println("USER Murdoc localhost localhost :Dont bother");
System.out.println("System : NOTICE AUTH :*** Looking up your hostname...");
listModel.addElement(in.re adLine());
}
boolean nir=fromServer.equals("NOT ICE AUTH :*** No Ident response");
if (nir==true)
{
out.println("USERHOST jobob");
out.println("MODE jobob +i");
System.out.println("System : NOTICE AUTH :*** No Ident response");
}
//listModel.addElement(in. readLine() );
System.out.println("Server : " + fromServer);
if (fromServer.equals("exit") || fromServer.equals("quit"))
{
System.out.println("kicked from server");
break;
}
// a=a+1;
}
out.close();
in.close();
stdIn.close();
kkSocket.close();
} catch (Exception e) {
}
}
}
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -----
I'd like to allow display text in listmodel which is inside the thread but cannot.....
any ideas ??
P.S. If you could show the easiest way how to correct listning 'cause it's very difficult for me to change everything ....
Regards
I'm trying to develope simple application with threads.
The problem is that i cannot in thread add line to table model
:((( (message: "cannot resolve symbol listmodel " " appears all the time )
'cause i'm newbie and because earlier i was using delphi which is a bit more friendly (but i have finished with delphi)
Here is my source code:
--------------------------
import java.util.Random;
import javax.swing.JSpinner;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class watek {
public static JFrame w = new JFrame();
public static JPanel jp = new JPanel();
public static JPanel jpa = new JPanel();
public static JPanel jpan = new JPanel();
public static DefaultListModel listModel = new DefaultListModel(); ;
public static JList list = new JList(listModel);
public static JRadioButton jrb = new JRadioButton();
public static JRadioButton jrb1 = new JRadioButton();
public static JLabel jl = new JLabel();
public static JLabel jl1 = new JLabel();
public static JTextField jtf = new JTextField();
public static JSpinner js = new JSpinner();
public static JButton jb = new JButton("Connect");
public static JTextField tf = new JTextField();
public static JButton jb1 = new JButton("Disconnect");
public static void main(String args[])
{
//listModel.addElement(in.
jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEven
{
// listModel = new DefaultListModel();
myThread newThread = new myThread("bialystok.ircnet
Thread thisThread = new Thread ( newThread );
thisThread.start();
}
});
w.setDefaultCloseOperation
Container content = w.getContentPane();
//jp.setBackground(Color.b
//jpa.setBackground(Color.
//jpan.setBackground(Color
js.setPreferredSize(new java.awt.Dimension(55, 18));
list.setPreferredSize(new java.awt.Dimension(200,100
jtf.setPreferredSize(new java.awt.Dimension(65,18))
jrb.setText("UDP");
jrb1.setText("TCP");
jl.setText("Host:");
jl1.setText("Port:");
jp.setLayout(new BoxLayout(jp,BoxLayout.LIN
jp.add(jrb);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(jrb1);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(jl);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(jtf);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(jl1);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(js);
jpa.setLayout(new BoxLayout(jpa,BoxLayout.LI
jpa.add(jb);
jpa.add(Box.createHorizont
jpa.add(new JSeparator(SwingConstants.
jpa.add(Box.createHorizont
jpa.add(tf);
jpa.add(Box.createHorizont
jpa.add(new JSeparator(SwingConstants.
jpa.add(Box.createHorizont
jpa.add(jb1);
w.getContentPane().add(jp,
w.getContentPane().add(lis
w.getContentPane().add(jpa
//setSize(600,100);
w.pack();
w.setVisible(true);
}
}
class myThread implements Runnable {
private String leport,lehost;
public myThread (String host, String port)
{
lehost=host;
leport=port;
}
public void run() {
try {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.i
Socket kkSocket = null;
PrintWriter out = null;
BufferedReader in = null;
kkSocket = new Socket(lehost,Integer.valu
out = new PrintWriter(kkSocket.getOu
in = new BufferedReader(new InputStreamReader(kkSocket
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.i
String fromServer, fromUser;
out.println("NICK jobob");
while ((fromServer = in.readLine()) != null)
{
boolean lpuh=fromServer.equals("NO
if (lpuh==true)
{
out.println("USER Murdoc localhost localhost :Dont bother");
System.out.println("System
listModel.addElement(in.re
}
boolean nir=fromServer.equals("NOT
if (nir==true)
{
out.println("USERHOST jobob");
out.println("MODE jobob +i");
System.out.println("System
}
//listModel.addElement(in.
System.out.println("Server
if (fromServer.equals("exit")
{
System.out.println("kicked
break;
}
// a=a+1;
}
out.close();
in.close();
stdIn.close();
kkSocket.close();
} catch (Exception e) {
}
}
}
--------------------------
I'd like to allow display text in listmodel which is inside the thread but cannot.....
any ideas ??
P.S. If you could show the easiest way how to correct listning 'cause it's very difficult for me to change everything ....
Regards
listmodel is probably not visible in the scope of the area of code where it appears. Can you check that?
It compiles now, but whether it is what you want to do or not ... ?
import java.util.Random;
import javax.swing.JSpinner;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class watek {
public static JFrame w = new JFrame();
public static JPanel jp = new JPanel();
public static JPanel jpa = new JPanel();
public static JPanel jpan = new JPanel();
public static DefaultListModel listModel = new DefaultListModel(); ;
public static JList list = new JList(listModel);
public static JRadioButton jrb = new JRadioButton();
public static JRadioButton jrb1 = new JRadioButton();
public static JLabel jl = new JLabel();
public static JLabel jl1 = new JLabel();
public static JTextField jtf = new JTextField();
public static JSpinner js = new JSpinner();
public static JButton jb = new JButton("Connect");
public static JTextField tf = new JTextField();
public static JButton jb1 = new JButton("Disconnect");
static BufferedReader input = new BufferedReader(new InputStreamReader(System.i n));
public static void main(String args[])
{
//listModel.addElement(inp ut.readLin e());
jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEven t event)
{
// listModel = new DefaultListModel();
listModel = new DefaultListModel();
try{
listModel.addElement(input .readLine( ));
}catch(IOException ioe){}
myThread newThread = new myThread("bialystok.ircnet .pl","6667 ");
Thread thisThread = new Thread ( newThread );
thisThread.start();
}
});
w.setDefaultCloseOperation (JFrame.EX IT_ON_CLOS E);
Container content = w.getContentPane();
//jp.setBackground(Color.b lue);
//jpa.setBackground(Color. red);
//jpan.setBackground(Color .yellow);
js.setPreferredSize(new java.awt.Dimension(55, 18));
list.setPreferredSize(new java.awt.Dimension(200,100 ));
jtf.setPreferredSize(new java.awt.Dimension(65,18)) ;
jrb.setText("UDP");
jrb1.setText("TCP");
jl.setText("Host:");
jl1.setText("Port:");
jp.setLayout(new BoxLayout(jp,BoxLayout.LIN E_AXIS));
jp.add(jrb);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(jrb1);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(jl);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(jtf);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(jl1);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(js);
jpa.setLayout(new BoxLayout(jpa,BoxLayout.LI NE_AXIS));
jpa.add(jb);
jpa.add(Box.createHorizont alStrut(5) );
jpa.add(new JSeparator(SwingConstants. VERTICAL)) ;
jpa.add(Box.createHorizont alStrut(5) );
jpa.add(tf);
jpa.add(Box.createHorizont alStrut(5) );
jpa.add(new JSeparator(SwingConstants. VERTICAL)) ;
jpa.add(Box.createHorizont alStrut(5) );
jpa.add(jb1);
w.getContentPane().add(jp, BorderLayo ut.PAGE_ST ART);
w.getContentPane().add(lis t,BorderLa yout.CENTE R);
w.getContentPane().add(jpa ,BorderLay out.PAGE_E ND);
//setSize(600,100);
w.pack();
w.setVisible(true);
}
//}
static class myThread implements Runnable {
private String leport,lehost;
public myThread (String host, String port)
{
lehost=host;
leport=port;
}
public void run() {
try {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.i n));
Socket kkSocket = null;
PrintWriter out = null;
BufferedReader in = null;
kkSocket = new Socket(lehost,Integer.valu eOf(leport .toString( )).intValu e());
out = new PrintWriter(kkSocket.getOu tputStream (), true); //
in = new BufferedReader(new InputStreamReader(kkSocket .getInputS tream()));
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.i n));
String fromServer, fromUser;
out.println("NICK jobob");
while ((fromServer = in.readLine()) != null)
{
boolean lpuh=fromServer.equals("NO TICE AUTH :*** Looking up your hostname...");
if (lpuh==true)
{
out.println("USER Murdoc localhost localhost :Dont bother");
System.out.println("System : NOTICE AUTH :*** Looking up your hostname...");
listModel.addElement(in.re adLine());
}
boolean nir=fromServer.equals("NOT ICE AUTH :*** No Ident response");
if (nir==true)
{
out.println("USERHOST jobob");
out.println("MODE jobob +i");
System.out.println("System : NOTICE AUTH :*** No Ident response");
}
//listModel.addElement(in. readLine() );
System.out.println("Server : " + fromServer);
if (fromServer.equals("exit") || fromServer.equals("quit"))
{
System.out.println("kicked from server");
break;
}
// a=a+1;
}
out.close();
in.close();
stdIn.close();
kkSocket.close();
} catch (Exception e) {
}
}
}
}
import java.util.Random;
import javax.swing.JSpinner;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class watek {
public static JFrame w = new JFrame();
public static JPanel jp = new JPanel();
public static JPanel jpa = new JPanel();
public static JPanel jpan = new JPanel();
public static DefaultListModel listModel = new DefaultListModel(); ;
public static JList list = new JList(listModel);
public static JRadioButton jrb = new JRadioButton();
public static JRadioButton jrb1 = new JRadioButton();
public static JLabel jl = new JLabel();
public static JLabel jl1 = new JLabel();
public static JTextField jtf = new JTextField();
public static JSpinner js = new JSpinner();
public static JButton jb = new JButton("Connect");
public static JTextField tf = new JTextField();
public static JButton jb1 = new JButton("Disconnect");
static BufferedReader input = new BufferedReader(new InputStreamReader(System.i
public static void main(String args[])
{
//listModel.addElement(inp
jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEven
{
// listModel = new DefaultListModel();
listModel = new DefaultListModel();
try{
listModel.addElement(input
}catch(IOException ioe){}
myThread newThread = new myThread("bialystok.ircnet
Thread thisThread = new Thread ( newThread );
thisThread.start();
}
});
w.setDefaultCloseOperation
Container content = w.getContentPane();
//jp.setBackground(Color.b
//jpa.setBackground(Color.
//jpan.setBackground(Color
js.setPreferredSize(new java.awt.Dimension(55, 18));
list.setPreferredSize(new java.awt.Dimension(200,100
jtf.setPreferredSize(new java.awt.Dimension(65,18))
jrb.setText("UDP");
jrb1.setText("TCP");
jl.setText("Host:");
jl1.setText("Port:");
jp.setLayout(new BoxLayout(jp,BoxLayout.LIN
jp.add(jrb);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(jrb1);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(jl);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(jtf);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(jl1);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(js);
jpa.setLayout(new BoxLayout(jpa,BoxLayout.LI
jpa.add(jb);
jpa.add(Box.createHorizont
jpa.add(new JSeparator(SwingConstants.
jpa.add(Box.createHorizont
jpa.add(tf);
jpa.add(Box.createHorizont
jpa.add(new JSeparator(SwingConstants.
jpa.add(Box.createHorizont
jpa.add(jb1);
w.getContentPane().add(jp,
w.getContentPane().add(lis
w.getContentPane().add(jpa
//setSize(600,100);
w.pack();
w.setVisible(true);
}
//}
static class myThread implements Runnable {
private String leport,lehost;
public myThread (String host, String port)
{
lehost=host;
leport=port;
}
public void run() {
try {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.i
Socket kkSocket = null;
PrintWriter out = null;
BufferedReader in = null;
kkSocket = new Socket(lehost,Integer.valu
out = new PrintWriter(kkSocket.getOu
in = new BufferedReader(new InputStreamReader(kkSocket
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.i
String fromServer, fromUser;
out.println("NICK jobob");
while ((fromServer = in.readLine()) != null)
{
boolean lpuh=fromServer.equals("NO
if (lpuh==true)
{
out.println("USER Murdoc localhost localhost :Dont bother");
System.out.println("System
listModel.addElement(in.re
}
boolean nir=fromServer.equals("NOT
if (nir==true)
{
out.println("USERHOST jobob");
out.println("MODE jobob +i");
System.out.println("System
}
//listModel.addElement(in.
System.out.println("Server
if (fromServer.equals("exit")
{
System.out.println("kicked
break;
}
// a=a+1;
}
out.close();
in.close();
stdIn.close();
kkSocket.close();
} catch (Exception e) {
}
}
}
}
ASKER
it's not adding to table any text :((
you should connect to bialystok.ircnet.pl on port 6667 ..
you should connect to bialystok.ircnet.pl on port 6667 ..
ASKER
form freezes :((
I'm not sure what this code does, but comment it out, as it's blocking your thread:
>>
listModel = new DefaultListModel();
try {
listModel.addElement(input .readLine( ));
}
catch (IOException ioe) {}
>>
>>
listModel = new DefaultListModel();
try {
listModel.addElement(input
}
catch (IOException ioe) {}
>>
ASKER
This program is connecting to irc server ..and in my code above if you will compile(without listModel.addElement(in.re adLine()); ) it and run from msdos or console you will get all messages that server sends to you
All i want is to display this messages in Table
Regards
All i want is to display this messages in Table
Regards
That was the reason for the problem you were having.
>>All i want is to display this messages in Table
It would be much better to display them in a text component
>>All i want is to display this messages in Table
It would be much better to display them in a text component
ASKER
the problem is that "cannot resolve symbol listmodel " , propably there would be the same problem with text component
regards
regards
So like CEHJ said, remove that bit, compile this code, and you receive your messages.
import java.util.Random;
import javax.swing.JSpinner;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class watek {
public static JFrame w = new JFrame();
public static JPanel jp = new JPanel();
public static JPanel jpa = new JPanel();
public static JPanel jpan = new JPanel();
//public static DefaultListModel listModel = new DefaultListModel(); ;
//public static JList list = new JList(listModel);
public static JRadioButton jrb = new JRadioButton();
public static JRadioButton jrb1 = new JRadioButton();
public static JLabel jl = new JLabel();
public static JLabel jl1 = new JLabel();
public static JTextField jtf = new JTextField();
public static JSpinner js = new JSpinner();
public static JButton jb = new JButton("Connect");
public static JTextField tf = new JTextField();
public static JButton jb1 = new JButton("Disconnect");
static BufferedReader input = new BufferedReader(new InputStreamReader(System.i n));
public static void main(String args[])
{
//listModel.addElement(inp ut.readLin e());
jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEven t event)
{
// listModel = new DefaultListModel();
// listModel = new DefaultListModel();
//try{
// listModel.addElement(input .readLine( ));
//}catch(IOException ioe){}
myThread newThread = new myThread("bialystok.ircnet .pl","6667 ");
Thread thisThread = new Thread ( newThread );
thisThread.start();
}
});
w.setDefaultCloseOperation (JFrame.EX IT_ON_CLOS E);
Container content = w.getContentPane();
//jp.setBackground(Color.b lue);
//jpa.setBackground(Color. red);
//jpan.setBackground(Color .yellow);
js.setPreferredSize(new java.awt.Dimension(55, 18));
//list.setPreferredSize(ne w java.awt.Dimension(200,100 ));
jtf.setPreferredSize(new java.awt.Dimension(65,18)) ;
jrb.setText("UDP");
jrb1.setText("TCP");
jl.setText("Host:");
jl1.setText("Port:");
jp.setLayout(new BoxLayout(jp,BoxLayout.LIN E_AXIS));
jp.add(jrb);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(jrb1);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(jl);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(jtf);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(jl1);
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(new JSeparator(SwingConstants. VERTICAL)) ;
jp.add(Box.createHorizonta lStrut(5)) ;
jp.add(js);
jpa.setLayout(new BoxLayout(jpa,BoxLayout.LI NE_AXIS));
jpa.add(jb);
jpa.add(Box.createHorizont alStrut(5) );
jpa.add(new JSeparator(SwingConstants. VERTICAL)) ;
jpa.add(Box.createHorizont alStrut(5) );
jpa.add(tf);
jpa.add(Box.createHorizont alStrut(5) );
jpa.add(new JSeparator(SwingConstants. VERTICAL)) ;
jpa.add(Box.createHorizont alStrut(5) );
jpa.add(jb1);
w.getContentPane().add(jp, BorderLayo ut.PAGE_ST ART);
//w.getContentPane().add(l ist,Border Layout.CEN TER);
w.getContentPane().add(jpa ,BorderLay out.PAGE_E ND);
//setSize(600,100);
w.pack();
w.setVisible(true);
}
//}
static class myThread implements Runnable {
private String leport,lehost;
public myThread (String host, String port)
{
lehost=host;
leport=port;
}
public void run() {
try {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.i n));
Socket kkSocket = null;
PrintWriter out = null;
BufferedReader in = null;
kkSocket = new Socket(lehost,Integer.valu eOf(leport .toString( )).intValu e());
out = new PrintWriter(kkSocket.getOu tputStream (), true); //
in = new BufferedReader(new InputStreamReader(kkSocket .getInputS tream()));
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.i n));
String fromServer, fromUser;
out.println("NICK jobob");
while ((fromServer = in.readLine()) != null)
{
boolean lpuh=fromServer.equals("NO TICE AUTH :*** Looking up your hostname...");
if (lpuh==true)
{
out.println("USER Murdoc localhost localhost :Dont bother");
System.out.println("System : NOTICE AUTH :*** Looking up your hostname...");
// listModel.addElement(in.re adLine());
}
boolean nir=fromServer.equals("NOT ICE AUTH :*** No Ident response");
if (nir==true)
{
out.println("USERHOST jobob");
out.println("MODE jobob +i");
System.out.println("System : NOTICE AUTH :*** No Ident response");
}
// listModel.addElement(in.re adLine());
System.out.println("Server : " + fromServer);
if (fromServer.equals("exit") || fromServer.equals("quit"))
{
System.out.println("kicked from server");
break;
}
// a=a+1;
}
out.close();
in.close();
stdIn.close();
kkSocket.close();
} catch (Exception e) {
}
}
}
}
import java.util.Random;
import javax.swing.JSpinner;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class watek {
public static JFrame w = new JFrame();
public static JPanel jp = new JPanel();
public static JPanel jpa = new JPanel();
public static JPanel jpan = new JPanel();
//public static DefaultListModel listModel = new DefaultListModel(); ;
//public static JList list = new JList(listModel);
public static JRadioButton jrb = new JRadioButton();
public static JRadioButton jrb1 = new JRadioButton();
public static JLabel jl = new JLabel();
public static JLabel jl1 = new JLabel();
public static JTextField jtf = new JTextField();
public static JSpinner js = new JSpinner();
public static JButton jb = new JButton("Connect");
public static JTextField tf = new JTextField();
public static JButton jb1 = new JButton("Disconnect");
static BufferedReader input = new BufferedReader(new InputStreamReader(System.i
public static void main(String args[])
{
//listModel.addElement(inp
jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEven
{
// listModel = new DefaultListModel();
// listModel = new DefaultListModel();
//try{
// listModel.addElement(input
//}catch(IOException ioe){}
myThread newThread = new myThread("bialystok.ircnet
Thread thisThread = new Thread ( newThread );
thisThread.start();
}
});
w.setDefaultCloseOperation
Container content = w.getContentPane();
//jp.setBackground(Color.b
//jpa.setBackground(Color.
//jpan.setBackground(Color
js.setPreferredSize(new java.awt.Dimension(55, 18));
//list.setPreferredSize(ne
jtf.setPreferredSize(new java.awt.Dimension(65,18))
jrb.setText("UDP");
jrb1.setText("TCP");
jl.setText("Host:");
jl1.setText("Port:");
jp.setLayout(new BoxLayout(jp,BoxLayout.LIN
jp.add(jrb);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(jrb1);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(jl);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(jtf);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(jl1);
jp.add(Box.createHorizonta
jp.add(new JSeparator(SwingConstants.
jp.add(Box.createHorizonta
jp.add(js);
jpa.setLayout(new BoxLayout(jpa,BoxLayout.LI
jpa.add(jb);
jpa.add(Box.createHorizont
jpa.add(new JSeparator(SwingConstants.
jpa.add(Box.createHorizont
jpa.add(tf);
jpa.add(Box.createHorizont
jpa.add(new JSeparator(SwingConstants.
jpa.add(Box.createHorizont
jpa.add(jb1);
w.getContentPane().add(jp,
//w.getContentPane().add(l
w.getContentPane().add(jpa
//setSize(600,100);
w.pack();
w.setVisible(true);
}
//}
static class myThread implements Runnable {
private String leport,lehost;
public myThread (String host, String port)
{
lehost=host;
leport=port;
}
public void run() {
try {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.i
Socket kkSocket = null;
PrintWriter out = null;
BufferedReader in = null;
kkSocket = new Socket(lehost,Integer.valu
out = new PrintWriter(kkSocket.getOu
in = new BufferedReader(new InputStreamReader(kkSocket
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.i
String fromServer, fromUser;
out.println("NICK jobob");
while ((fromServer = in.readLine()) != null)
{
boolean lpuh=fromServer.equals("NO
if (lpuh==true)
{
out.println("USER Murdoc localhost localhost :Dont bother");
System.out.println("System
// listModel.addElement(in.re
}
boolean nir=fromServer.equals("NOT
if (nir==true)
{
out.println("USERHOST jobob");
out.println("MODE jobob +i");
System.out.println("System
}
// listModel.addElement(in.re
System.out.println("Server
if (fromServer.equals("exit")
{
System.out.println("kicked
break;
}
// a=a+1;
}
out.close();
in.close();
stdIn.close();
kkSocket.close();
} catch (Exception e) {
}
}
}
}
ASKER
still doesen't display in JTable.................... ........:( ((
>>still doesen't display in JTable.................... ........:( ((
Which JTable, there isn't even one in the code you posted?
Which JTable, there isn't even one in the code you posted?
ASKER
sorry..my fault JList of course .....
ASKER
I'm thinking about JList but I'm typing JTable.....in my question is full source code
Regards
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ooops ...you get the points
ASKER
btw. Could you Cehj send me your source code on my address (wthouting ziping , etc): photo_delphi@wp.pl
Make sure you're using the same code as i:
http://www.cehjohnson.uklinux.net/aire/watek.java
Also, (nearly?) all of those public static variables should be private and not static
http://www.cehjohnson.uklinux.net/aire/watek.java
Also, (nearly?) all of those public static variables should be private and not static
Don't post your address - you'll get spammed like mad ;-) If you're bothered, ask Community Support to delete that
8-)
ASKER
One of my mailbox is so spammed so I'm not even trying to retrieve any of the message , besides this mailbox I posted has some kind of spam protection
ASKER
Anywat thanks for help
Regards
Regards