我MyApplet
JApplet
延长JEditorPane centralPane
。
package view;
import java.awt.HeadlessException;
import javax.swing.JApplet;
import javax.swing.JEditorPane;
import javax.swing.SwingUtilities;
import controller.Manager;
public class MyApplet extends JApplet implements View {
/**
*
*/
private static final long serialVersionUID = 1L;
private JEditorPane centralPane;
/**
* @throws HeadlessException
*/
public MyApplet() throws HeadlessException {
centralPane = new JEditorPane();
}
/* (non-Javadoc)
* @see java.applet.Applet#init()
*/
@Override
public void init() {
this.setSize(500, 500);
super.init();
add(centralPane);
}
/* (non-Javadoc)
* @see vue.Vue#fillPane(java.lang.String)
*/
@Override
public void fillPane(String s) {
centralPane.setText(s);
}
/**
* @param args
*/
public static void main(String[] args) {
//System.out.println("test");
View v = null;
v = new myApplet();
Manager.getManager().link(v);
}
}
但是当我打电话给fillPane时,没有任何事情发生......
(fillPane由Manager
调用,我尝试运行作为Java应用程序来检查centralPane
的内容,并且我的String
...但是如果我作为Java Applet运行则不行!
我尝试了repaint()
或revalidate()
,但没有任何作品......