Hello
I am currently having problems with writing to a text area. In the code below i create a JTextArea which is appended to by other classes namely Tcpdump. Unfortuntaley when the first line is written to no more text is written to the JTextArea or that can be seen anyway. Have i set up wordwrap correctly or is there a way that when you call append on my textarea in the tcpdump class it adds a newline character.
Heres my code anyway
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import jpcap.*;
import java.io.*;
public class Serverside1 extends JFrame
{
private JFrame window;
private MenuBar bar;
private MenuItem start;
private Menu capture;
public JTextArea text;
public Tcpdump td;
public Serverside1()
{
// Create frame and panels for GUI
window = new JFrame("Network Packet Sniffer");
window.setSize(700,500);
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
GridLayout gridLayout = new GridLayout(2,1);
panel.setLayout(gridLayout);
JTextArea text = new JTextArea("",18, 30);
text.setWrapStyleWord(true);
panel.add(text);
window.getContentPane().add(panel);
window.show();
bar = new MenuBar();
window.setMenuBar(bar);
start = new MenuItem("Start");
capture = new Menu("Capture");
capture.add(start);
bar.add(capture);
window.setVisible(true);
Tcpdump td = new Tcpdump();
try
{
td.printOutput(text);
}
catch(IOException e){
System.out.println("Bollox");}
}
public static void main(
String[] args)throws java.io.IOException{
Serverside1 s = new Serverside1();
}
}
Many thanks