更新(重新加载?)一个JEditorPane

时间:2017-02-07 09:14:57

标签: java swing user-interface japplet jeditorpane

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(),但没有任何作品......

0 个答案:

没有答案