Ejemplo n.º 1
0
  public MainFrame() {
    super("GVmakerSE");
    keyBoard = new KeyBoard();
    gvm =
        JGVM.newGVM(
            new GvmConfig(),
            new DefaultFileModel(new FileSysSE("GVM_ROOT")),
            keyBoard.getKeyModel());
    screenPane = new ScreenPane(gvm);
    fileChooser = new JFileChooser("GVM_ROOT");
    fileChooser.addChoosableFileFilter(
        new FileFilter() {

          public boolean accept(File f) {
            if (f.isDirectory()) {
              return true;
            } else {
              return f.getName().toLowerCase().endsWith(".lav");
            }
          }

          public String getDescription() {
            return "GVmaker Application";
          }
        });

    msgLabel = new JLabel(" 结束");
    add(screenPane, BorderLayout.NORTH);
    add(msgLabel, BorderLayout.CENTER);
    add(keyBoard, BorderLayout.SOUTH);

    setJMenuBar(createMenuBar());
    pack();
    setResizable(false);
  }
Ejemplo n.º 2
0
 private void openLavFile() {
   int res = fileChooser.showOpenDialog(this);
   if (res == JFileChooser.APPROVE_OPTION) {
     InputStream in = null;
     try {
       in = new FileInputStream(fileChooser.getSelectedFile());
     } catch (FileNotFoundException ex) {
       System.err.println(ex);
     }
     LavApp lavApp = LavApp.createLavApp(in);
     if (worker != null && worker.isAlive()) {
       worker.interrupt();
       try {
         worker.join();
       } catch (InterruptedException ex) {
         System.out.println(ex);
       }
     }
     gvm.loadApp(lavApp);
     worker = new Worker();
     worker.start();
     setMsg("运行");
   } else {
     if (worker != null && worker.isAlive()) {
       worker.setPaused(false);
       setMsg("运行");
     } else {
       setMsg("结束");
     }
   }
 }