JEditorPane
에 Index
을 확장하는 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의 텍스트에 "Hello World"를 표시하지 않습니다입니다! 그리고 그것은 어떤 오류도 보여주지 않습니다. 아무 일도 없었습니다.
여기에 사용 된 콘텐츠 유형 (또는 editorkit)을 확인하십시오. 예를 들어 html은 올바른 html을 제공하지만 일반 텍스트는 제공하지 않습니다. – StanislavL
[* 편집기 창 대 텍스트 창 *] (http://docs.oracle.com/javase/tutorial/uiswing/components/editorpane.html#recap)도 참조하십시오. – trashgod
필자는 에디터 타입 주위의 pbm을 생각하지 않습니다. 서브 클래스에서 editotpaneMR 필드가 어떻게 작동하는지 생각해보십시오 !! –