Hi peeps,
Im a beginner with Java and im trying to make a program that listen's to a certain port and then views the information (information sent to that port) in my Jframe
i've made the framework(wich took me a while), but now i'm stuck...
Does anybody know a simple code that makes it listen to a port and then views the information received in the Jframe? it would help me alot
Thanks, i appreciate it.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.io.*;
public class Myframe extends JFrame {
static JTextArea tekstarea;
JButton startb;
JButton refreshb;
static InputStream input;
static boolean start;
String s;
public Myframe()
{
.
setTitle("Test frame");
setSize(new Dimension(800, 700));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tekstarea=new JTextArea(20,20);
tekstarea.setEditable(false);
tekstarea.setForeground(Color.black);
JScrollPane panel1=new JScrollPane(tekstarea,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
panel1.setPreferredSize(new Dimension(200,800));
add(panel1,BorderLayout.WEST);
tekstarea.append("Info Read:\n\n");
startb=new JButton("Start Reading");
refreshb=new JButton("Refresh");
JPanel panel2=new JPanel();
panel2.add(startb);
panel2.add(refreshb);
add(panel2,BorderLayout.CENTER);
ActionListener listener1=new StartHandler();
startb.addActionListener(listener1);
ActionListener listener2=new RefreshHandler();
refreshb.addActionListener(listener2);
setVisible(true);
start=false;
}
class StartHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
start=true;
}
}
class RefreshHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
}
}
public static void main(String[] args)
{
Myframe tc=new Myframe();
while(start==false){
try
{Thread.sleep(500);
}
catch(InterruptedException exception){};
};
}
}
Im a beginner with Java and im trying to make a program that listen's to a certain port and then views the information (information sent to that port) in my Jframe
i've made the framework(wich took me a while), but now i'm stuck...
Does anybody know a simple code that makes it listen to a port and then views the information received in the Jframe? it would help me alot
Thanks, i appreciate it.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.io.*;
public class Myframe extends JFrame {
static JTextArea tekstarea;
JButton startb;
JButton refreshb;
static InputStream input;
static boolean start;
String s;
public Myframe()
{
.
setTitle("Test frame");
setSize(new Dimension(800, 700));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tekstarea=new JTextArea(20,20);
tekstarea.setEditable(false);
tekstarea.setForeground(Color.black);
JScrollPane panel1=new JScrollPane(tekstarea,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
panel1.setPreferredSize(new Dimension(200,800));
add(panel1,BorderLayout.WEST);
tekstarea.append("Info Read:\n\n");
startb=new JButton("Start Reading");
refreshb=new JButton("Refresh");
JPanel panel2=new JPanel();
panel2.add(startb);
panel2.add(refreshb);
add(panel2,BorderLayout.CENTER);
ActionListener listener1=new StartHandler();
startb.addActionListener(listener1);
ActionListener listener2=new RefreshHandler();
refreshb.addActionListener(listener2);
setVisible(true);
start=false;
}
class StartHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
start=true;
}
}
class RefreshHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
}
}
public static void main(String[] args)
{
Myframe tc=new Myframe();
while(start==false){
try
{Thread.sleep(500);
}
catch(InterruptedException exception){};
};
}
}