Я хочу написать приложение для обмена сообщениями с java. Я хочу отправить смайлики. Я написал этот код, но он не работает.help для назначения java
public class MyClient extends JFrame implements IClient {
...
JEditorPane editorPane=new JEditorPane();
final String SMILE = ClassLoader.getSystemClassLoader().getResource("images/1.gif").toString();
...
public void chat(String message) {
try {
StringBuffer bfr= new StringBuffer(message);
while(message.indexOf(":)") != -1) {
int index = message.indexOf(":)");
bfr.replace(index,index+2,"<IMG SRC=\""+SMILE +"\">");
message= bfr.toString();
}
try{
editorPane.getEditorKit().read(new java.io.StringReader(message+"\n"),
editorPane.getDocument(), editorPane.getDocument().getLength());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
editorPane.setCaretPosition(editorPane.getDocument().getLength());
}
... Но desnt показать SMILY в editorpane, выход: Это адрес, с которым Smily имеет были сохранены. я бросил такой код:
(HTMLEditorKit)editorPane.getEditorKit().read(new java.io.StringReader(message+"\n"),
editorPane.getDocument(), editorPane.getDocument().getLength());
, но это вызывает исключение, как это приведение не является правильным. Так что я могу сделать? спасибо