0

こんにちは友達私はJFrameを拡張し、JInternalFramesを持っているswingアプリケーションを持っています。JInternalFrameのActionEventからメインフレームを更新する必要があります。私のメインフレーム(疑似)

    public class MainFrame extends JFrame{
    .................

    }
public void Refresh(){
    invalidate();
    validate();
    }

私のJInternalFrame(Pseud0)

public class EndOfTerm extends JInternalFrame implements ActionListener{

public void actionPerformed(ActionEvent ae){

.........
new MainFrame().Refresh();

}

}

ActionEventの後に2つのフレームが表示されます。1つはコンポーネントなしで、もう1つはコンポーネントがオーバーラップしているように見えます。助けてください。#初心者#

4

2 に答える 2

1

MainFrame を InternalFrame に保存する必要があります。

public class EndOfTerm extends JInternalFrame implements ActionListener{

    private MainFram mainFrame;

    public EndOfTerm(MainFrame mainFrame) {
        this.mainFrame = mainFrame;
    }

    public void actionPerformed(ActionEvent ae){

        .........
        mainFrame.Refresh();

    }

}

InternalFrame を作成するときは、MainFrame を渡す必要があります。

new InternalFrame(this);
于 2013-03-07T13:35:18.843 に答える
0

JInternalFrame 内で getParent(this) を呼び出して、囲んでいる JFrame への参照を取得することもできると思います。

于 2013-03-07T13:36:27.107 に答える