SwingWindow.java 文件源码

java
阅读 38 收藏 0 点赞 0 评论 0

项目:Java-Swing-Helper 作者:
/**
 * Load a new scene into the frame.</br>
 * This will clear out the old scene.
 * 
 * @param scene
 */
public void loadScene(Scene scene) {
    if (currentScene != null)
        currentScene.unloadScene();
    currentScene = scene;

    frame.getContentPane().removeAll();
    originalComps.clear();

    scene.loadScene(frame.getContentPane());

    addComponentToList(frame.getContentPane());
    // Used to avoid an infinite loop.
    originalComps.remove(System.identityHashCode(frame.getContentPane()));

    frame.setTitle(title + " - " + scene.getTitle());
    frame.getContentPane().repaint();

    frame.getContentPane().addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            pack();
        }
    });

    pack();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号