Trouble updating a JtextArea from a JTable ListSelectionListener..

Hi, I'm having trouble updating a JtextArea from a JTable ListSelectionListener, it is working for another JTextArea but I have created JNMTextArea which extends JTextArea and I am getting no data passed to it.

Any help is really greatly appreciated. Im a relative newbie to Java.

Here is the class declaration for JNMTextArea

/////////////////////////////////////////////////////////////

publicclass JNMTextAreaextends JTextArea

{

//Constructor

public JNMTextArea(String text){

super(text);

setLineWrap(true);

setEditable(false);

}

//Constructor

public JNMTextArea()

{

this(new String());

}

//This sets the data in setText, works ok.

void displayPacket(Packet p){

//Function works fine

//Need to pass this data to the JNMTextArea!!!

setText(buffer.toString());

setCaretPosition(0);

}

}

//////////////////////////////////////////////////////

Here is where I use JNMTextArea, Im

///////////////////////////////////////////////////////

class JNMGuiextends JFrameimplements ActionListener, WindowListener{

publicstatic JNMTextArea txtPktContent;

//Constructor

JNMGui(){

buildGUI();

}

privatevoid buildGUI(){

mainWindow =new JFrame("Monitor");

tblPacket =new JTable(tblPacketM);

tblPacket.setToolTipText("Packet Panel");

tblPacket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

if (ALLOW_ROW_SELECTION){

ListSelectionModel rowSM = tblPacket.getSelectionModel();

rowSM.addListSelectionListener(new ListSelectionListener(){publicvoid valueChanged(ListSelectionEvent e){

if (e.getValueIsAdjusting())

return;

ListSelectionModel lsm =(ListSelectionModel)e.getSource();

if (lsm.isSelectionEmpty()){

System.out.println("No rows are selected.");

}

else{

int selectedRow = lsm.getMinSelectionIndex();

selectedRow++;

String str;// = "";

//Unsure if I need to create this here!

txtPktContent =new JNMTextArea();

//This works perfectly

txtPktType.append ("Packet No: " + Integer.toString(selectedRow) +"\n\n");

Packet pkt =new Packet();

pkt = (Packet) CaptureEngine.packets.elementAt(selectedRow);

if(pkt.datalink!=null && pkt.datalinkinstanceof EthernetPacket){

str ="Ethernet ";

//THis works txtPktType is another JTextArea!!

txtPktType.append ( s );

//This is not working

//I realise displayPacket return type is void but how do get

//the setText it created to append to the JNMTextArea?

txtPktContent.displayPacket(pkt);

//Adding to ScrollPane

tblPane =new JScrollPane(tblPacket);

txtPktTypePane =new JScrollPane ( txtPktType );

txtPktTypePane.setToolTipText("Packet Type");

txtPktContentPane =new JScrollPane ( txtPktContent );

txtPktContentPane.setToolTipText("Packet Payload");

panel.add( tblPane, BorderLayout.CENTER );

//End Class JNMGui

[5569 byte] By [totalfreeloadera] at [2007-10-2 17:24:11]
# 1
void displayPacket(Packet p){//Function works fine//Need to pass this data to the JNMTextArea!!!setText(buffer.toString());setCaretPosition(0);}This seems really odd. Notice that you pass in "p" but use "buffer". Where is "buffer" defined?
BaltimoreJohna at 2007-7-13 18:40:24 > top of Java-index,Desktop,Core GUI APIs...