0

クリックすると、作成したツールを開く入力ボタンを持つ GUI を持つコーディングをいくつか書きましたが、jbutton で実行したいのは、最初の GUI を閉じてツールを開くことです。ステートメントを変更しようとしましたsetVisible(true/false);が、GUI を非表示にするだけで実行されません。

要約するとJButton、現在の GUI を閉じる機能と、作成したツールを開く機能の 2 つの機能が必要です。

enterButtonGUIを閉じるには、このコーディングと関係があると思います:

public void actionPerformed(ActionEvent e){ 
    if(e.getSource() == enterButton){
        // coding to make the GUI exit???
    }
}
4

1 に答える 1

2

System.exit(0)次のように使用できます。

public void actionPerformed(ActionEvent e){ 
    if(e.getSource() == enterButton){

        //coding to make the GUI exit???

        System.exit(0); 
    }
}

または使用dispose()

public void actionPerformed(ActionEvent e){ 
    if(e.getSource() == enterButton){
        //coding to make the GUI exit???

        this.dispose();
    }
}
于 2013-02-22T16:04:54.997 に答える