JTextPane Append error

For some reason i cant append text on to my JTextPane...

here is my full code....

Its the chatWindow JTextPane and i'm tryong to append a message i read in i'm getting the error that append append(string) is unidentified for the type JTextPane

/**

* Auction.java

* A very simple auction client. Works with server Auctioneer.java

* Responds to callbacks from the server via the Notifiable interface.

*

* Does not check that bids are higher than previous ones.

* Does not call an end to the auction.

*

* DG. Feb. 2000

*/

import java.awt.*;

import java.awt.event.*;

import java.rmi.*;

import java.rmi.server.*;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.JScrollPane;

import javax.swing.JTextField;

import javax.swing.JTextPane;

import javax.swing.WindowConstants;

public class Auction extends JFrame

implements ActionListener, Notifiable

{

JTextField chatField;

JTextPane chatWindow;

Label currentBidLabel, productLabel;

JButton Chat, Exit, Clear;

private String currentBid = "";

private String product = "";

private String msg = "";

AuctionInterface auctioneer;

public Auction() {

try {

setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

{

JPanel jPanel1 = new JPanel();

getContentPane().add(jPanel1, BorderLayout.CENTER);

jPanel1.setPreferredSize(new java.awt.Dimension(392, 134));

{

JPanel viewPanel = new JPanel();

jPanel1.add(viewPanel);

viewPanel.setPreferredSize(new java.awt.Dimension(390, 198));

{

JScrollPane jScrollPane1 = new JScrollPane();

viewPanel.add(jScrollPane1);

jScrollPane1.setPreferredSize(new java.awt.Dimension(242, 192));

{

chatWindow = new JTextPane();

jScrollPane1.setViewportView(chatWindow);

}

}

{

JTextPane userList = new JTextPane();

viewPanel.add(userList);

userList.setText("List of Users....");

userList.setPreferredSize(new java.awt.Dimension(127, 195));

}

}

{

JPanel buttonPanel = new JPanel();

jPanel1.add(buttonPanel);

buttonPanel.setPreferredSize(new java.awt.Dimension(390, 33));

{

Chat = new JButton();

buttonPanel.add(Chat);

Chat.setText("Enter");

Chat.setPreferredSize(new java.awt.Dimension(123, 22));

Chat.addActionListener(this);

}

{

Clear = new JButton();

buttonPanel.add(Clear);

Clear.setText("Clear");

Clear.setPreferredSize(new java.awt.Dimension(123, 22));

Clear.addActionListener(this);

}

{

Exit = new JButton();

buttonPanel.add(Exit);

Exit.setText("Close");

Exit.setPreferredSize(new java.awt.Dimension(123, 22));

Exit.addActionListener(this);

}

}

{

chatField = new JTextField();

jPanel1.add(chatField);

chatField.setText("Enter Username");

chatField.setPreferredSize(new java.awt.Dimension(385, 29));

}

}

pack();

setSize(400, 300);

} catch (Exception e) {

e.printStackTrace();

}

// setBounds(50, 50, 300, 200);

setVisible(true);

}

public void actionPerformed(ActionEvent ae) {

Component listener = (Component)ae.getSource();

if(listener == this.Chat){

msg = this.chatField.getText();

chatWindow.append(msg + "");

System.out.println("check");

chatField.setText("");

}

else if(listener == this.Exit){

dispose();

System.exit(0);

}

}

public void notify(Integer reason) {

if(reason.intValue() == 0) {

/* try {

// currentBid = auctioneer.getCurrentBid();

// currentBidLabel.setText(currentBid);

}

catch (RemoteException re) {

re.printStackTrace();

}*/

}

}

public static void main(String [] args) {

//System.setSecurityManager(new RMISecurityManager());

String serverName = "rmi://localhost/chat";

Auction auc = new Auction();

// auc.productLabel.setText("somethimg");

try {

auc.auctioneer = (AuctionInterface) Naming.lookup(serverName);

auc.auctioneer.registerForNotification(auc);

//auc.bid.setText(auc.auctioneer.getMinBid());

}

catch (NotBoundException nbe) {

nbe.printStackTrace();

}

catch(Exception e) {

e.printStackTrace();

}

}

}

[4634 byte] By [RoryOSullivana] at [2007-11-26 21:44:22]
# 1
Post a Short compilable code with tags.>>chatWindow.append(msg + ""); //You cannot append text this wayTake a look at this, http://java.sun.com/docs/books/tutorial/uiswing/components/text.html
watfora at 2007-7-10 3:32:06 > top of Java-index,Desktop,Core GUI APIs...
# 2

Only a JTextArea supports the append(...) method. If you don't need styled text then use a JTextArea. If you need styled text then use the Document.insertString(...) method. And read the above link for more information on using styled text.

If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the posted code retains its original formatting.

camickra at 2007-7-10 3:32:06 > top of Java-index,Desktop,Core GUI APIs...