【Java】swing JFrame 任意の名前のウインドウを閉じる

windowtitleに消したいウインドウのタイトルを入れておき、

    Window[] win = Window.getWindows();
    for (Window w : win)    {
        if(((Frame) w).getTitle().equals(windowtitle)) {
            w.dispose();
        }
    }   

とする。

Leave a Reply

Your email address will not be published. Required fields are marked *