2014-04-16 55 views
2

我有一個用戶界面類CarSimulation,下面是一個名爲「Cars」的車輛遊戲。我希望能夠運行與汽車對象相關的CarSimulation,以及與Car的不同對象相關聯的每個CarSimulation的第二,第三等CarSimulaion窗口。Java中的多個窗口

你能給我一些指導嗎?

public class CarSimulation implements SimulationListener 

    public static void main(String[] args) { 
    EventQueue.invokeLater(new Runnable() { 
     @Override 
     public void run() { 
      try { 
       CarSimulation window = new CarSimulation(); 
       window.CarSimulation.setVisible(true); 
       Cars cargame = new Cars(); 

      } catch (Exception e) { 
       e.printStackTrace(); 
      } 
     } 
    }); 
} 
+2

嘗試JinternalFrame。允許您在同一時間擁有許多打開的子窗口 – ErrorNotFoundException

回答

1

您可以爲主窗口使用JFrame。然後,爲您運行的每個模擬實例使用一個JDialog。