Example #1
0
  /**
   * the main window for MProbe
   *
   * @param pModel
   */
  public MainWin(MProbeController ctrl, ProblemInstance inst) {
    super(title);

    control = ctrl;
    model = inst;

    model.addObserver(this);

    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(this);

    Container content = getContentPane();
    content.setLayout(new FlowLayout());

    // set MenuBar
    JMenuBar MainMenu = new JMenuBar();
    // set the file menu
    JMenu file = new JMenu("file");
    filepath = new JMenuItem("set file path");
    load = new JMenuItem("load file");
    close = new JMenuItem("exit");
    file.add(filepath);
    file.add(load);
    file.add(close);
    // set the help menu
    JMenu help = new JMenu("help");
    helpinfo = new JMenuItem("help contents");
    about = new JMenuItem("about MProbe");
    help.add(helpinfo);
    help.add(about);
    // add the menus to menuBar
    MainMenu.add(file);
    MainMenu.add(help);
    this.setJMenuBar(MainMenu);

    // set the buttons in the main window
    statisticSummary = new JButton(showStatisticSummary);
    variableWorkshop = new JButton(showVariableWorkshop);
    constraintWorkshop = new JButton(showConstrainWorkshop);
    objectiveWorkshop = new JButton(showObjectWorkshop);
    analysisSettings = new JButton(showAnalysisSettings);

    enableButtons(false);
    content.add(statisticSummary);
    content.add(Box.createRigidArea(new Dimension(0, 15)));
    content.add(variableWorkshop);
    content.add(Box.createRigidArea(new Dimension(0, 15)));
    content.add(constraintWorkshop);
    content.add(Box.createRigidArea(new Dimension(0, 15)));
    content.add(objectiveWorkshop);
    content.add(Box.createRigidArea(new Dimension(0, 15)));
    content.add(analysisSettings);

    this.setSize(400, 400);
    setVisible(true);

    load.addActionListener(this);
    helpinfo.addActionListener(this);
    about.addActionListener(this);
    close.addActionListener(this);
    filepath.addActionListener(this);
    statisticSummary.addActionListener(this);
    variableWorkshop.addActionListener(this);
    constraintWorkshop.addActionListener(this);
    objectiveWorkshop.addActionListener(this);
    analysisSettings.addActionListener(this);
  }
Example #2
0
 @Override
 public void update(Observable o, Object arg) {
   if ((Object) o == (Object) model) enableButtons(model.loaded());
 }