當在JEditorPane
中設置的子類JFrame
中的新文本時,我遇到問題。在JEditorPane中設置新文本
package gui;
...
public class Index extends JFrame {
JEditorPane editorPaneMR = new JEditorPane();
public static void main(String[] args) {
...
}
public Index() {
JButton SearchButton = new JButton("OK");
SearchButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
parser GooBlog = new parser(url);
try {
GooBlog.hello(); // Go to subclass parser
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
而這個所謂的解析器
子類的代碼package gui;
public class parser extends Index{
String url;
public parser (String urlInput){
this.url = urlInput;
}
public void hello() throws IOException{
editorPaneMR.setText("Hello World");
}
}
問題是,當我按下OK按鈕它不顯示我的JEditorPane文本「世界,你好!」並沒有顯示任何錯誤,只是沒有發生任何事情。
檢查內容類型(或的EditorKit)。如果它是例如HTML提供正確的HTML,但不是純文本。 – StanislavL 2013-05-07 09:49:19
參見[*編輯窗格與文本窗格*](http://docs.oracle.com/javase/tutorial/uiswing/components/editorpane.html#recap)。 – trashgod 2013-05-07 11:31:55
我不認爲圍繞編輯器類型的pbm我認爲它是圍繞着如何在子類中的editotpaneMR字段工作! – 2013-05-07 14:06:02