private void initialize() {
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    getTeamNameLabel().setAlignmentX(Component.LEFT_ALIGNMENT);
    add(getTeamNameLabel());
    JPanel p = new JPanel();

    p.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setAlignmentX(Component.LEFT_ALIGNMENT);
    getTeamNameField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getTeamNameField().setMaximumSize(getTeamNameField().getPreferredSize());
    // getVersionField().setMaximumSize(getVersionField().getPreferredSize());
    p.setMaximumSize(
        new Dimension(Integer.MAX_VALUE, getTeamNameField().getPreferredSize().height));
    p.add(getTeamPackageLabel());
    p.add(getTeamNameField());
    add(p);

    JLabel label = new JLabel(" ");

    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);
    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getDescriptionLabel());

    JScrollPane scrollPane =
        new JScrollPane(
            getDescriptionArea(),
            ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    scrollPane.setMaximumSize(scrollPane.getPreferredSize());
    scrollPane.setMinimumSize(new Dimension(100, scrollPane.getPreferredSize().height));
    scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(scrollPane);
    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);
    add(getAuthorLabel());
    getAuthorField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getAuthorField().setMaximumSize(getAuthorField().getPreferredSize());
    add(getAuthorField());
    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);
    add(getWebpageLabel());
    getWebpageField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getWebpageField().setMaximumSize(getWebpageField().getPreferredSize());
    add(getWebpageField());
    getWebpageHelpLabel().setAlignmentX(Component.LEFT_ALIGNMENT);
    add(getWebpageHelpLabel());
    JPanel panel = new JPanel();

    panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(panel);
    addComponentListener(eventHandler);
  }
  private void resetRemainderProblems() {

    problemDisplays = new RemainderProblemDisplay[round.getNumProblems()];

    JPanel panel = new JPanel();
    panel.setMinimumSize(new Dimension(2, 2));
    panel.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
    for (int i = round.getNumProblems() / 4 + (round.getNumProblems() % 4 == 0 ? 0 : 1);
        i >= 0;
        i--) {
      panel.setSize(new Dimension(370, panel.getSize().height + 60));
    }
    panel.setLayout(new Layout(0, 4));

    for (int i = 0; i < round.getNumProblems(); i++) {
      RemainderProblemDisplay problem =
          new RemainderProblemDisplay(
              round.getProblem(i), round.getGenerator().getParam().charAt(0));
      problemDisplays[i] = problem;
      panel.add(problem);
    }
    panel.revalidate();
    problems.setPreferredSize(new Dimension(388, 360));
    problems.setViewportView(panel);
    problems.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    problems.revalidate();
  }
    private JPanel createCompPanel() {
      filesets = new Vector();

      int count = installer.getIntegerProperty("comp.count");
      JPanel panel = new JPanel(new GridLayout(count, 1));

      String osClass = OperatingSystem.getOperatingSystem().getClass().getName();
      osClass = osClass.substring(osClass.indexOf('$') + 1);

      for (int i = 0; i < count; i++) {
        String os = installer.getProperty("comp." + i + ".os");

        if (os != null && !osClass.equals(os)) continue;

        JCheckBox checkBox =
            new JCheckBox(
                installer.getProperty("comp." + i + ".name")
                    + " ("
                    + installer.getProperty("comp." + i + ".disk-size")
                    + "Mb)");
        checkBox.getModel().setSelected(true);
        checkBox.addActionListener(this);
        checkBox.setRequestFocusEnabled(false);

        filesets.addElement(new Integer(i));

        panel.add(checkBox);
      }

      Dimension dim = panel.getPreferredSize();
      dim.width = Integer.MAX_VALUE;
      panel.setMaximumSize(dim);

      return panel;
    }
  private void initGui() {
    JComponent filler =
        new JComponent() {
          @Override
          public Dimension getPreferredSize() {
            return myTextLabel.getPreferredSize();
          }
        };
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(3, 20, 3, 20));

    add(myTextLabel, BorderLayout.WEST);
    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    JPanel panel = new JPanel(new GridLayout(1, myLabels.size(), 0, 0));
    for (final JComponent myLabel : myLabels) {
      panel.add(myLabel);
    }
    panel.setMaximumSize(panel.getPreferredSize());
    box.add(panel);
    box.add(Box.createHorizontalGlue());
    add(box, BorderLayout.CENTER);

    add(filler, BorderLayout.EAST);
  }
  /**
   * Loads the tileset defined in the constructor into a JPanel which it then returns. Makes no
   * assumptions about height or width, which means it needs to read an extra 64 tiles at worst (32
   * down to check height and 32 across for width), since the maximum height/width is 32 tiles.
   */
  public JPanel loadTileset() {
    int height = MAX_TILESET_SIZE;
    int width = MAX_TILESET_SIZE;

    boolean maxHeight = false;
    boolean maxWidth = false;

    // find width
    int j = 0;
    while (!maxWidth) {
      try {
        File f = new File(tileDir + "/" + j + "_" + 0 + ".png");
        ImageIO.read(f);
      } catch (IOException e) {
        width = j;
        maxWidth = true;
      }
      j += TILE_SIZE;
    }

    // find height
    int i = 0;
    while (!maxHeight) {
      try {
        File f = new File(tileDir + "/" + 0 + "_" + i + ".png");
        ImageIO.read(f);
      } catch (IOException e) {
        height = i;
        maxHeight = true;
      }
      i += TILE_SIZE;
    }

    JPanel tileDisplay = new JPanel();
    tileDisplay.setLayout(new GridLayout(height / TILE_SIZE, width / TILE_SIZE));
    tileDisplay.setMinimumSize(new Dimension(width, height));
    tileDisplay.setPreferredSize(new Dimension(width, height));
    tileDisplay.setMaximumSize(new Dimension(width, height));

    for (i = 0; i < height; i += TILE_SIZE) {
      for (j = 0; j < width; j += TILE_SIZE) {
        String fPath = tileDir + "/" + j + "_" + i;
        try {
          int[] mov = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};

          Image icon = getTile(tileDir, j, i, 1);
          Tile tile =
              new Tile(new ImageIcon(icon), "palette", 0, 0, mov, "none", false, "" + j + "_" + i);
          tile.addMouseListener(new PaletteButtonListener());
          tile.setMaximumSize(new Dimension(TILE_SIZE, TILE_SIZE));
          tile.setPreferredSize(new Dimension(TILE_SIZE, TILE_SIZE));
          tile.setMinimumSize(new Dimension(TILE_SIZE, TILE_SIZE));
          tileDisplay.add(tile);
        } catch (IOException e) {
        }
      }
    }
    return tileDisplay;
  }
  private JPanel addMethodCombo() {
    JPanel methodPanel = new JPanel(new BorderLayout());
    JComboBox<RestRequestInterface.RequestMethod> methodComboBox =
        new JComboBox<RestRequestInterface.RequestMethod>(new RestRequestMethodModel(getRequest()));
    methodComboBox.setSelectedItem(getRequest().getMethod());

    JLabel methodLabel = new JLabel("Method");
    methodPanel.add(methodLabel, BorderLayout.NORTH);
    methodPanel.add(methodComboBox, BorderLayout.SOUTH);
    methodPanel.setMinimumSize(new Dimension(75, STANDARD_TOOLBAR_HEIGHT));
    // TODO: remove hard coded height adjustment
    methodPanel.setMaximumSize(new Dimension(75, STANDARD_TOOLBAR_HEIGHT + 10));
    return methodPanel;
  }
 private void jbInit() throws Exception {
   setTitle("DIARIO CONTADO");
   frmDatosVenta = new FrmDatosVenta(engine);
   frmDatosVenta.setLocationRelativeTo(this);
   getContentPane().setLayout(borderLayout1);
   jLabel1.setFont(new java.awt.Font("Arial", Font.PLAIN, 18));
   jLabel1.setToolTipText("");
   jLabel1.setText("DIARIO DE ENTRADAS");
   pnlCentro.setLayout(borderLayout2);
   cmdCerrar.setText("CERRAR");
   cmdCerrar.addActionListener(new FrmDiarioDeEntradas_cmdCerrar_actionAdapter(this));
   cmdImprimir.setText("IMPRIMIR");
   tblDiario.setBackground(new Color(255, 240, 255));
   tblDiario.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
   tblDiario.setModel(modelDiarioVentasDeContado1);
   tblDiario.addMouseListener(new FrmDiarioDeEntradas_tblDiario_mouseAdapter(this));
   this.addWindowListener(new FrmDiarioDeEntradas_this_windowAdapter(this));
   jLabel2.setFont(new java.awt.Font("Arial", Font.BOLD, 20));
   jLabel2.setText("Total:");
   lblTotal.setFont(new java.awt.Font("Arial", Font.BOLD, 20));
   lblTotal.setText("");
   this.getContentPane().setBackground(Color.white);
   this.addKeyListener(new FrmDiarioDeEntradas_this_keyAdapter(this));
   pnlCentro.setBackground(Color.white);
   pnlNorte.setBackground(Color.white);
   pnlNorte.setLayout(borderLayout4);
   scrollDiario.getViewport().setBackground(Color.white);
   scrollDiario.setPreferredSize(new Dimension(800, 600));
   lblFecha.setFont(new java.awt.Font("Arial", Font.BOLD, 16));
   lblFecha.setText("");
   jPanel1.setLayout(borderLayout3);
   pnlSur.setMaximumSize(new Dimension(4000, 200));
   jPanel1.setBackground(Color.white);
   jPanel2.setBackground(Color.white);
   this.getContentPane().add(pnlCentro, java.awt.BorderLayout.CENTER);
   pnlCentro.add(pnlNorte, java.awt.BorderLayout.CENTER);
   pnlCentro.add(scrollDiario, java.awt.BorderLayout.NORTH);
   scrollDiario.getViewport().add(tblDiario);
   this.getContentPane().add(pnlSur, java.awt.BorderLayout.SOUTH);
   pnlSur.add(cmdImprimir);
   pnlSur.add(cmdCerrar);
   this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
   jPanel1.add(lblFecha, java.awt.BorderLayout.EAST);
   jPanel1.add(jLabel1, java.awt.BorderLayout.WEST);
   pnlNorte.add(jPanel2, java.awt.BorderLayout.EAST);
   jPanel2.add(jLabel2);
   jPanel2.add(lblTotal);
   this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
 }
Exemple #8
0
  /**
   * Constructor
   *
   * @param parent
   */
  public DisplayBar(MainDisplay parent) {

    this.parent = parent;

    // ---

    super.setLayout(new FlowLayout());
    super.setMaximumSize(new Dimension(GUIparams.displaybar_width, GUIparams.displaybar_height));

    // ---

    this.display_bar_content = new MonitorBar();
    this.add((JPanel) this.display_bar_content);
    this.content = Content.MONITOR_BAR;
  }
  /** Creates the property iterator panel initially disabled. */
  public GeneratorPropertyIteratorPanel() {

    String[] options = {"Disabled", "Enabled"};
    ComboBoxModel cbm = new DefaultComboBoxModel(options);
    m_StatusBox.setModel(cbm);
    m_StatusBox.setSelectedIndex(0);
    m_StatusBox.addActionListener(this);
    m_StatusBox.setEnabled(false);
    m_ConfigureBut.setEnabled(false);
    m_ConfigureBut.addActionListener(this);
    JPanel buttons = new JPanel();
    GridBagLayout gb = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    buttons.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
    //    buttons.setLayout(new GridLayout(1, 2));
    buttons.setLayout(gb);
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 5;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.insets = new Insets(0, 2, 0, 2);
    buttons.add(m_StatusBox, constraints);
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.weightx = 5;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    buttons.add(m_ConfigureBut, constraints);
    buttons.setMaximumSize(
        new Dimension(buttons.getMaximumSize().width, buttons.getMinimumSize().height));
    setBorder(BorderFactory.createTitledBorder("Generator properties"));
    setLayout(new BorderLayout());
    add(buttons, BorderLayout.NORTH);
    //    add(Box.createHorizontalGlue());
    m_ArrayEditor.setBorder(BorderFactory.createEtchedBorder());
    m_ArrayEditor.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            System.err.println("Updating experiment property iterator array");
            m_Exp.setPropertyArray(m_ArrayEditor.getValue());
          }
        });
    add(m_ArrayEditor, BorderLayout.CENTER);
  }
Exemple #10
0
  private JPanel getButtonsPanel() {
    if (buttonsPanel == null) {
      buttonsPanel = new JPanel();
      buttonsPanel.setPreferredSize(new Dimension(100, 30));
      buttonsPanel.setLayout(new GridBagLayout());
      buttonsPanel.setMinimumSize(new Dimension(20, 20));
      buttonsPanel.setMaximumSize(new Dimension(1000, 30));

      GridBagConstraints constraintsOKButton = new GridBagConstraints();

      constraintsOKButton.gridx = 1;
      constraintsOKButton.gridy = 1;
      constraintsOKButton.ipadx = 34;
      constraintsOKButton.insets = new Insets(2, 173, 3, 168);
      getButtonsPanel().add(getOkButton(), constraintsOKButton);
    }
    return buttonsPanel;
  }
Exemple #11
0
 public void addRow(Component... components) {
   remove(puff);
   final JPanel row = new JPanel();
   row.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mouseClicked(MouseEvent event) {
           gui.notifyObserver("/use " + rows.indexOf(event.getSource()));
         }
       });
   row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS));
   // row.add(Box.createHorizontalStrut(3));
   row.setMinimumSize(new Dimension(10, 30));
   row.setMaximumSize(new Dimension(250, 30));
   for (Component component : components) {
     row.add(component);
   }
   JButton red = new JButton("x");
   red.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent event) {
           int deleted = rows.indexOf(row);
           gui.notifyObserver("/use " + deleted);
           gui.notifyObserver("/disconnect");
         }
       });
   red.setBackground(Color.PINK.darker());
   red.setForeground(Color.WHITE);
   row.add(Box.createHorizontalGlue());
   row.add(red);
   rows.add(row);
   Component strut = Box.createVerticalStrut(5);
   struts.add(strut);
   add(row);
   add(strut);
   add(puff);
   repaint();
   updateUI();
 }
 private void populatePrepareDeck() {
   lblTitle.setText(
       "Quest Mode: Draft Tournament - "
           + FModel.getQuest().getAchievements().getCurrentDraft().getTitle());
   VHomeUI.SINGLETON_INSTANCE
       .getPnlDisplay()
       .setLayout(new MigLayout("insets 0, gap 0, ax center, wrap", "", "[][grow, center][][][]"));
   VHomeUI.SINGLETON_INSTANCE
       .getPnlDisplay()
       .add(lblTitle, "w 80%!, h 40px!, gap 20% 0 15px 35px, ax right");
   pnlDeckImage.setMaximumSize(new Dimension(680, 475));
   VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlDeckImage, "ax center, grow");
   VHomeUI.SINGLETON_INSTANCE
       .getPnlDisplay()
       .add(btnEditDeck, "w 150px, h 50px, gap 0 0 15px 0, ax center");
   VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(btnStartTournament, "gap 0 0 0 15px, ax center");
   VHomeUI.SINGLETON_INSTANCE
       .getPnlDisplay()
       .add(btnLeaveTournament, "w 150px, h 35px, gap 0 0 25px 10%, ax center");
   btnEditDeck.setFontSize(24);
   btnLeaveTournament.setFontSize(12);
 }
  public void addBackAndOpenButtons() {
    ApplicationManager.getApplication()
        .invokeLater(
            () -> {
              final JPanel panel = new JPanel();
              panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

              final JButton backButton =
                  makeGoButton("Click to go back", AllIcons.Actions.Back, -1);
              final JButton forwardButton =
                  makeGoButton("Click to go forward", AllIcons.Actions.Forward, 1);
              final JButton openInBrowser = new JButton(AllIcons.Actions.Browser_externalJavaDoc);
              openInBrowser.addActionListener(e -> BrowserUtil.browse(myEngine.getLocation()));
              openInBrowser.setToolTipText("Click to open link in browser");
              addButtonsAvailabilityListeners(backButton, forwardButton);

              panel.setMaximumSize(new Dimension(40, getPanel().getHeight()));
              panel.add(backButton);
              panel.add(forwardButton);
              panel.add(openInBrowser);

              add(panel, BorderLayout.PAGE_START);
            });
  }
Exemple #14
0
  /** Constructor for RestaurantGui class. Sets up all the gui components. */
  public RestaurantGui() {
    int WINDOWX = 600;
    int WINDOWY = 500;

    ButtonPanel = new JPanel();
    MrKrabs = new ImageIcon(getClass().getResource("/resources/MrKrabs.png"));
    Ramsay = new ImageIcon(getClass().getResource("/resources/Ramsay.png"));

    RestaurantPortion.setLayout(new BorderLayout());
    InformationPanel = new JPanel();
    InformationPanel.setLayout(new BorderLayout());
    buttonPanel = new JPanel();
    buttonPanel.setLayout(new BorderLayout());

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(25, 25, WINDOWX + 650, WINDOWY + 170);
    setVisible(true);

    setLayout(new BorderLayout());
    Dimension restDim = new Dimension(WINDOWX, (int) (WINDOWY * .86));
    restPanel.setPreferredSize(restDim);
    restPanel.setMinimumSize(restDim);
    restPanel.setMaximumSize(restDim);

    // pauseButton = new JButton("PAUSE");
    // pauseButton.addActionListener(this);
    refreshButton = new JButton("REFRESH");
    refreshButton.addActionListener(this);

    // CUSTOMER PANEL INFORMATION
    Dimension infoDimCustomer = new Dimension(WINDOWX, (int) (WINDOWY * .12));
    customerInformationPanel = new JPanel();
    customerInformationPanel.setPreferredSize(infoDimCustomer);
    customerInformationPanel.setMinimumSize(infoDimCustomer);
    customerInformationPanel.setMaximumSize(infoDimCustomer);
    customerInformationPanel.setBorder(BorderFactory.createTitledBorder("Customers"));

    customerStateCheckBox = new JCheckBox();
    customerStateCheckBox.setVisible(false);
    customerStateCheckBox.addActionListener(this);

    customerInformationPanel.setLayout(new GridLayout(1, 2, 30, 0));

    infoCustomerLabel = new JLabel();
    infoCustomerLabel.setText("<html><pre><i>There are no restaurant customers.</i></pre></html>");
    customerInformationPanel.add(infoCustomerLabel);
    customerInformationPanel.add(customerStateCheckBox);

    // WAITER PANEL INFORMATION/*
    /*
    Dimension infoDimWaiter = new Dimension(WINDOWX, (int) (WINDOWY * .12));
    waiterInformationPanel = new JPanel();
    waiterInformationPanel.setPreferredSize(infoDimWaiter);
    waiterInformationPanel.setMinimumSize(infoDimWaiter);
    waiterInformationPanel.setMaximumSize(infoDimWaiter);
    waiterInformationPanel.setBorder(BorderFactory.createTitledBorder("Waiters"));

    waiterON.addActionListener(this);
    waiterOFF.addActionListener(this);
    */
    // waiterInformationPanel.setLayout(new GridLayout(1, 2, 30, 0));

    infoWaiterLabel = new JLabel();
    infoWaiterLabel.setText("<html><pre><i>Click Add to make waiters</i></pre></html>");
    // waiterInformationPanel.add(infoWaiterLabel);
    waiterON.setVisible(false);
    waiterOFF.setVisible(false);
    // waiterInformationPanel.add(waiterON);
    // waiterInformationPanel.add(waiterOFF);
    RestaurantPortion.add(restPanel, BorderLayout.NORTH);
    InformationPanel.add(customerInformationPanel, BorderLayout.CENTER);
    MrKrabsButton = new JButton(MrKrabs);
    RamsayButton = new JButton(Ramsay);
    MrKrabsButton.addActionListener(this);
    RamsayButton.addActionListener(this);
    ButtonPanel.setLayout(new BorderLayout());
    ButtonPanel.add(MrKrabsButton, BorderLayout.WEST);
    ButtonPanel.add(RamsayButton, BorderLayout.EAST);
    InformationPanel.add(ButtonPanel, BorderLayout.SOUTH);
    // InformationPanel.add(waiterInformationPanel, BorderLayout.CENTER);
    RestaurantPortion.add(InformationPanel, BorderLayout.CENTER);
    // buttonPanel.add(pauseButton, BorderLayout.CENTER);
    buttonPanel.add(refreshButton, BorderLayout.CENTER);
    RestaurantPortion.add(buttonPanel, BorderLayout.SOUTH);

    add(animationPanel, BorderLayout.CENTER);
    add(RestaurantPortion, BorderLayout.EAST);
  }
Exemple #15
0
  public ThumbMaker() {
    super("ThumbMaker");

    // grab the preferences so that they can be used to fill out the layout
    ThumbMakerPreferences myPrefs = ThumbMakerPreferences.getInstance();

    // content pane
    JPanel pane = new JPanel();
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    setContentPane(pane);

    // top panel
    JPanel top = new JPanel();
    top.setLayout(new BoxLayout(top, BoxLayout.X_AXIS));
    pane.add(top);

    // left-hand panel
    JPanel left = new JPanel();
    left.setLayout(new BoxLayout(left, BoxLayout.Y_AXIS));
    top.add(left);

    // horizontal padding
    top.add(Box.createHorizontalStrut(5));

    // label for file list
    JLabel listLabel = GUIUtil.makeLabel("Files to process:");
    listLabel.setDisplayedMnemonic('f');
    String listTip = "List of files from which to create thumbnails";
    listLabel.setToolTipText(listTip);
    left.add(GUIUtil.pad(listLabel));

    // list of files to convert
    list = new JList();
    listLabel.setLabelFor(list);
    list.setToolTipText(listTip);
    list.setModel(new DefaultListModel());
    list.setDragEnabled(true);
    changeFilesInList = new ThumbTransferHandler();
    list.setTransferHandler(changeFilesInList);
    left.add(new JScrollPane(list));

    // progress bar
    progress = new JProgressBar(0, 1);
    progress.setString("[Drag and drop files onto list to begin]");
    progress.setStringPainted(true);
    progress.setToolTipText("Status of thumbnail processing operation");
    left.add(progress);

    // panel for process and remove buttons
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    // add files button
    addFiles = new JButton("Add Files");
    addFiles.setMnemonic('d');
    addFiles.setToolTipText("Add files to be processed.");
    addFiles.addActionListener(this);
    p.add(addFiles);

    p.add(Box.createHorizontalStrut(5));

    // process button
    process = new JButton("Process");
    process.setMnemonic('p');
    process.setToolTipText("Begin creating thumbnails");
    process.addActionListener(this);
    p.add(process);

    p.add(Box.createHorizontalStrut(5));

    // remove button
    remove = new JButton("Remove");
    remove.setMnemonic('v');
    remove.setToolTipText("Remove selected files from the list");
    remove.addActionListener(this);
    p.add(remove);

    left.add(GUIUtil.pad(p));

    // right-hand panel
    JPanel right = new JPanel();
    right.setLayout(new BoxLayout(right, BoxLayout.Y_AXIS));
    top.add(right);

    // panel for resolution settings
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    // resolution label
    JLabel resLabel = GUIUtil.makeLabel("Resolution: ");
    resLabel.setDisplayedMnemonic('s');
    resLabel.setToolTipText("Resolution of the thumbnails");
    p.add(resLabel);

    // x resolution text box
    xres =
        GUIUtil.makeTextField(myPrefs.getStringPref(ThumbMakerPreferences.RES_WIDTH_PREF_NAME), 2);
    resLabel.setLabelFor(xres);
    xres.setToolTipText("Thumbnail width");
    p.add(xres);

    // "by" label
    JLabel byLabel = GUIUtil.makeLabel(" by ");
    byLabel.setDisplayedMnemonic('y');
    p.add(byLabel);

    // y resolution text box
    yres =
        GUIUtil.makeTextField(myPrefs.getStringPref(ThumbMakerPreferences.RES_HEIGHT_PREF_NAME), 2);
    byLabel.setLabelFor(yres);
    yres.setToolTipText("Thumbnail height");
    p.add(yres);

    right.add(GUIUtil.pad(p));
    right.add(Box.createVerticalStrut(8));

    // aspect ratio checkbox
    aspect = new JCheckBox("Maintain aspect ratio", true);
    aspect.setMnemonic('m');
    aspect.setToolTipText(
        "When checked, thumbnails are not stretched, "
            + "but rather padded with the background color.");
    aspect.addActionListener(this);
    right.add(GUIUtil.pad(aspect));
    // make sure that the check box is initialized correctly
    aspect.setSelected(
        myPrefs
            .getStringPref(ThumbMakerPreferences.DO_MAINTAIN_ASPECT_PREF_NAME)
            .equalsIgnoreCase(ThumbMakerPreferences.BOOLEAN_TRUE_STRING));

    // panel for background color
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    // load the color values from the preferences
    int redValueNumber = myPrefs.getIntegerPref(ThumbMakerPreferences.RED_VALUE_PREF_NAME);
    int greenValueNumber = myPrefs.getIntegerPref(ThumbMakerPreferences.GREEN_VALUE_PREF_NAME);
    int blueValueNumber = myPrefs.getIntegerPref(ThumbMakerPreferences.BLUE_VALUE_PREF_NAME);

    // background color label
    colorLabel = GUIUtil.makeLabel("Background color: ");
    String colorTip = "Thumbnail background color";
    colorLabel.setToolTipText(colorTip);
    p.add(colorLabel);

    // background color
    colorBox = new JPanel();
    colorBox.setToolTipText(colorTip);
    colorBox.setBorder(new LineBorder(Color.black, 1));
    Dimension colorBoxSize = new Dimension(45, 15);
    colorBox.setMaximumSize(colorBoxSize);
    colorBox.setMinimumSize(colorBoxSize);
    colorBox.setPreferredSize(colorBoxSize);
    colorBox.setBackground(new Color(redValueNumber, greenValueNumber, blueValueNumber));
    p.add(colorBox);

    right.add(GUIUtil.pad(p));
    right.add(Box.createVerticalStrut(2));

    // red slider
    redLabel = GUIUtil.makeLabel("R");
    red = new JSlider(0, 255, redValueNumber);
    redValue = GUIUtil.makeLabel("" + redValueNumber);
    redValue.setToolTipText("Red color component slider");
    right.add(makeSlider(redLabel, red, redValue, "Red"));

    // green slider
    greenLabel = GUIUtil.makeLabel("G");
    green = new JSlider(0, 255, greenValueNumber);
    greenValue = GUIUtil.makeLabel("" + greenValueNumber);
    greenValue.setToolTipText("Green color component slider");
    right.add(makeSlider(greenLabel, green, greenValue, "Green"));

    // blue slider
    blueLabel = GUIUtil.makeLabel("B");
    blue = new JSlider(0, 255, blueValueNumber);
    blueValue = GUIUtil.makeLabel("" + blueValueNumber);
    right.add(makeSlider(blueLabel, blue, blueValue, "Blue"));

    right.add(Box.createVerticalStrut(8));

    // panel for algorithm
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    // algorithm label
    JLabel algorithmLabel = GUIUtil.makeLabel("Algorithm: ");
    algorithmLabel.setDisplayedMnemonic('l');
    String algorithmTip = "Resizing algorithm to use";
    algorithmLabel.setToolTipText(algorithmTip);
    p.add(algorithmLabel);

    // algorithm combo box
    algorithm =
        GUIUtil.makeComboBox(
            new String[] {"Smooth", "Standard", "Fast", "Replicate", "Area averaging"});
    algorithmLabel.setLabelFor(algorithm);
    algorithm.setToolTipText(algorithmTip);
    p.add(algorithm);
    // set the algorithm value from the preferences
    algorithm.setSelectedIndex(myPrefs.getIntegerPref(ThumbMakerPreferences.RESIZE_ALG_PREF_NAME));

    right.add(GUIUtil.pad(p));

    // panel for output format
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    // format label
    JLabel formatLabel = GUIUtil.makeLabel("Format: ");
    formatLabel.setDisplayedMnemonic('f');
    String formatTip = "Thumbnail output format";
    formatLabel.setToolTipText(formatTip);
    p.add(formatLabel);

    // format combo box
    format = GUIUtil.makeComboBox(new String[] {"PNG", "JPG"});
    formatLabel.setLabelFor(format);
    format.setToolTipText(formatTip);
    p.add(format);
    // set the format value from the preferences
    format.setSelectedIndex(myPrefs.getIntegerPref(ThumbMakerPreferences.THUMB_FORMAT_PREF_NAME));

    right.add(GUIUtil.pad(p));
    right.add(Box.createVerticalStrut(5));

    // panel for prepend string
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    // prepend label
    JLabel prependLabel = GUIUtil.makeLabel("Prepend: ");
    prependLabel.setDisplayedMnemonic('e');
    String prependTip = "Starting string for each thumbnail filename";
    prependLabel.setToolTipText(prependTip);
    p.add(prependLabel);

    // prepend field
    prepend =
        GUIUtil.makeTextField(
            myPrefs.getStringPref(ThumbMakerPreferences.STRING_TO_PREPEND_PREF_NAME), 4);
    prependLabel.setLabelFor(prepend);
    prepend.setToolTipText(prependTip);
    p.add(prepend);

    p.add(Box.createHorizontalStrut(5));

    // append label
    JLabel appendLabel = GUIUtil.makeLabel("Append: ");
    appendLabel.setDisplayedMnemonic('a');
    String appendTip = "Ending string for each thumbnail filename";
    appendLabel.setToolTipText(appendTip);
    p.add(appendLabel);

    // append field
    append =
        GUIUtil.makeTextField(
            myPrefs.getStringPref(ThumbMakerPreferences.STRING_TO_APPEND_PREF_NAME), 4);
    appendLabel.setLabelFor(append);
    append.setToolTipText(appendTip);
    p.add(append);

    right.add(GUIUtil.pad(p));

    // vertical padding
    right.add(Box.createVerticalGlue());

    // bottom panel
    JPanel bottom = new JPanel();
    bottom.setLayout(new BoxLayout(bottom, BoxLayout.X_AXIS));
    pane.add(bottom);

    // output folder label
    JLabel outputLabel = GUIUtil.makeLabel("Output folder: ");
    outputLabel.setDisplayedMnemonic('o');
    String outputTip = "Thumbnail output folder";
    outputLabel.setToolTipText(outputTip);
    bottom.add(outputLabel);

    // output folder field
    String filePath =
        new File(myPrefs.getStringPref(ThumbMakerPreferences.FILE_PATH_STRING_PREF_NAME))
            .getAbsolutePath();
    output = GUIUtil.makeTextField(filePath, 8);
    outputLabel.setLabelFor(output);
    output.setToolTipText(outputTip);
    // start this in default and then lock down so "..." is used
    output.setEditable(false);
    output.setBackground(Color.LIGHT_GRAY);
    bottom.add(output);

    // add a file chooser button "..."
    dotDotDot = new JButton("...");
    dotDotDot.setMnemonic('.');
    dotDotDot.setToolTipText("Select destination directory.");
    dotDotDot.addActionListener(this);
    bottom.add(dotDotDot);

    right.add(GUIUtil.pad(p));

    setFromPreferences();
    addWindowListener(this);
  }
  /**
   * Create the train module GUI (the dynamic and static windows). Both windows are HIDE_ON_CLOSE so
   * that closing them does not cause the train module to close.
   */
  public TrainModelUI() {
    try {
      JPanel emptyJPanel = new JPanel();
      emptyJPanel.add(new JLabel("            "));
      isPaused = true;

      // Setup the dynamicWindow.

      btnShowStaticValues = buildJButton("Show Static Values");
      btnSelectTrain = buildJButton("Select Train");
      btnPauseResume = buildJButton("Pause");
      btnPauseResume.setEnabled(false);
      btnSetManRecPower = buildJButton("Set Manual Received Power");
      btnToggleManRecPower = buildJButton("Toggle Manual Received Power");
      btnSetManDesSpdLmt = buildJButton("Set Manual Desired Speed Limit");
      btnToggleManDesSpdLmt = buildJButton("Toggle Manual Desired Speed Limit");
      btnToggleSignalPickupFailure = buildJButton("Toggle Signal Pickup Failure");
      btnToggleEngineFailure = buildJButton("Toggle Engine Failure");
      btnToggleBrakeFailure = buildJButton("Toggle Brake Failure");
      btnToggleServiceBrake = buildJButton("Toggle Service Brake");
      btnToggleEmergencyBrake = buildJButton("Toggle Emergency Brake");
      btnSetManLights = buildJButton("Set Manual Lights Status");
      btnToggleManLights = buildJButton("Toggle Manual Lights Status");
      btnSetManDoors = buildJButton("Set Manual Doors Status");
      btnToggleManDoors = buildJButton("Toggle Manual Doors Status");
      btnSetManTarTemperature = buildJButton("Set Manual Target Temp.");
      btnToggleManTarTemperature = buildJButton("Toggle Manual Target Temp.");

      jlTime = new JLabel("XX:XX:XX", JLabel.CENTER);
      jlCurVel = new JLabel("", JLabel.CENTER);
      jlCurAccel = new JLabel("", JLabel.CENTER);
      jlRecPowerTNC = new JLabel("", JLabel.CENTER);
      jlManRecPower = new JLabel("", JLabel.CENTER);
      jlToggleManRecPower = new JLabel("", JLabel.CENTER);
      jlPostedSpdLmt = new JLabel("", JLabel.CENTER);
      jlManDesSpdLmt = new JLabel("", JLabel.CENTER);
      jlToggleManDesSpdLmt = new JLabel("", JLabel.CENTER);
      jlGrade = new JLabel("", JLabel.CENTER);
      jlTotalMass = new JLabel("", JLabel.CENTER);
      jlPassengerCount = new JLabel("", JLabel.CENTER);
      jlCrewCount = new JLabel("", JLabel.CENTER);
      jlPosition = new JLabel("", JLabel.CENTER);
      jlToggleSignalPickupFailure = new JLabel("", JLabel.CENTER);
      jlToggleEngineFailure = new JLabel("", JLabel.CENTER);
      jlToggleBrakeFailure = new JLabel("", JLabel.CENTER);
      jlToggleServiceBrake = new JLabel("", JLabel.CENTER);
      jlToggleEmergencyBrake = new JLabel("", JLabel.CENTER);
      jlLights = new JLabel("", JLabel.CENTER);
      jlManLights = new JLabel("", JLabel.CENTER);
      jlToggleManLights = new JLabel("", JLabel.CENTER);
      jlDoors = new JLabel("", JLabel.CENTER);
      jlManDoors = new JLabel("", JLabel.CENTER);
      jlToggleManDoors = new JLabel("", JLabel.CENTER);
      jlCurTemperature = new JLabel("", JLabel.CENTER);
      jlTarTemperature = new JLabel("", JLabel.CENTER);
      jlManTarTemperature = new JLabel("", JLabel.CENTER);
      jlToggleManTarTemperature = new JLabel("", JLabel.CENTER);
      jlAnnouncement = new JLabel("", JLabel.CENTER);

      JPanel dwPanel1 = new JPanel();
      dwPanel1.setLayout(new GridLayout(18, 2));
      dwPanel1.add(buildJPanel(new JLabel("Current Velocity (m/s)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlCurVel));
      dwPanel1.add(buildJPanel(new JLabel("Current Acceleration (m/s^2)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlCurAccel));
      dwPanel1.add(buildJPanel(new JLabel("Received Power from TNC (W)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlRecPowerTNC));
      dwPanel1.add(buildJPanel(btnSetManRecPower));
      dwPanel1.add(buildJPanel(jlManRecPower));
      dwPanel1.add(buildJPanel(btnToggleManRecPower));
      dwPanel1.add(buildJPanel(jlToggleManRecPower));
      dwPanel1.add(buildJPanel(new JLabel("Speed Limit Posted on Signs (m/s)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlPostedSpdLmt));
      dwPanel1.add(buildJPanel(btnSetManDesSpdLmt));
      dwPanel1.add(buildJPanel(jlManDesSpdLmt));
      dwPanel1.add(buildJPanel(btnToggleManDesSpdLmt));
      dwPanel1.add(buildJPanel(jlToggleManDesSpdLmt));
      dwPanel1.add(buildJPanel(new JLabel("Relative Grade from TKM (%)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlGrade));
      dwPanel1.add(
          buildJPanel(new JLabel("Total Mass (inc. passengers/crew) (kg)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlTotalMass));
      dwPanel1.add(buildJPanel(new JLabel("Passenger Count", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlPassengerCount));
      dwPanel1.add(buildJPanel(new JLabel("Crew Count", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlCrewCount));
      dwPanel1.add(
          buildJPanel(new JLabel("Position from Onboard GPS ([block], m)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlPosition));
      dwPanel1.add(buildJPanel(btnToggleSignalPickupFailure));
      dwPanel1.add(buildJPanel(jlToggleSignalPickupFailure));
      dwPanel1.add(buildJPanel(btnToggleEngineFailure));
      dwPanel1.add(buildJPanel(jlToggleEngineFailure));
      dwPanel1.add(buildJPanel(btnToggleBrakeFailure));
      dwPanel1.add(buildJPanel(jlToggleBrakeFailure));
      dwPanel1.add(buildJPanel(btnToggleServiceBrake));
      dwPanel1.add(buildJPanel(jlToggleServiceBrake));
      dwPanel1.add(buildJPanel(btnToggleEmergencyBrake));
      dwPanel1.add(buildJPanel(jlToggleEmergencyBrake));
      JPanel dwPanel2 = new JPanel();
      dwPanel2.setLayout(new GridLayout(18, 2));
      dwPanel2.add(buildJPanel(new JLabel("Lights Status", JLabel.CENTER)));
      dwPanel2.add(buildJPanel(jlLights));
      dwPanel2.add(buildJPanel(btnSetManLights));
      dwPanel2.add(buildJPanel(jlManLights));
      dwPanel2.add(buildJPanel(btnToggleManLights));
      dwPanel2.add(buildJPanel(jlToggleManLights));
      dwPanel2.add(buildJPanel(new JLabel("Doors Status", JLabel.CENTER)));
      dwPanel2.add(buildJPanel(jlDoors));
      dwPanel2.add(buildJPanel(btnSetManDoors));
      dwPanel2.add(buildJPanel(jlManDoors));
      dwPanel2.add(buildJPanel(btnToggleManDoors));
      dwPanel2.add(buildJPanel(jlToggleManDoors));
      dwPanel2.add(buildJPanel(new JLabel("Current Temp. (degrees F)", JLabel.CENTER)));
      dwPanel2.add(buildJPanel(jlCurTemperature));
      dwPanel2.add(buildJPanel(new JLabel("Target Temp. from TNC (degrees F)", JLabel.CENTER)));
      dwPanel2.add(buildJPanel(jlTarTemperature));
      dwPanel2.add(buildJPanel(btnSetManTarTemperature));
      dwPanel2.add(buildJPanel(jlManTarTemperature));
      dwPanel2.add(buildJPanel(btnToggleManTarTemperature));
      dwPanel2.add(buildJPanel(jlToggleManTarTemperature));
      dwPanel2.add(buildJPanel(new JLabel("Announcement", JLabel.CENTER)));
      dwPanel2.add(buildJPanel(jlAnnouncement));

      JPanel primaryButtons = new JPanel();
      primaryButtons.setLayout(new GridLayout(1, 4));
      primaryButtons.add(btnShowStaticValues);
      primaryButtons.add(btnSelectTrain);
      primaryButtons.add(btnPauseResume);
      primaryButtons.add(buildJPanel(jlTime));

      JPanel jp = new JPanel();
      jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
      jp.add(primaryButtons);
      jp.add(emptyJPanel);
      jp.add(new JSeparator(JSeparator.HORIZONTAL));
      jp.add(dwPanel1);
      jp.add(new JSeparator(JSeparator.HORIZONTAL));
      jp.add(dwPanel2);

      jp.setMaximumSize(new Dimension(400, 700));

      JScrollPane dScroll = new JScrollPane(jp);
      dScroll.setViewportView(jp);

      dynamicWindow = new JFrame();
      dynamicWindow.setTitle("Train Model (Chris Paskie)   -   UI   (Train ID:   --)");
      dynamicWindow.setSize(600, 400);
      dynamicWindow.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
      dynamicWindow.add(dScroll);
      isVisible = false;
      dynamicWindow.setVisible(isVisible);

      // Setup the staticWindow.

      jlLength = new JLabel("", JLabel.CENTER);
      jlWidth = new JLabel("", JLabel.CENTER);
      jlHeight = new JLabel("", JLabel.CENTER);
      jlNumCars = new JLabel("", JLabel.CENTER);
      jlMotorPower = new JLabel("", JLabel.CENTER);
      jlMaxSpeed = new JLabel("", JLabel.CENTER);
      jlServiceBrakeDecel = new JLabel("", JLabel.CENTER);
      jlEmergencyBrakeDecel = new JLabel("", JLabel.CENTER);
      jlFrictionCoeff = new JLabel("", JLabel.CENTER);
      jlEmptyTrainMass = new JLabel("", JLabel.CENTER);
      jlPersonMass = new JLabel("", JLabel.CENTER);
      jlMaxSeatedCount = new JLabel("", JLabel.CENTER);
      jlMaxStandingCount = new JLabel("", JLabel.CENTER);
      jlMaxCrewCount = new JLabel("", JLabel.CENTER);

      JPanel swPanel = new JPanel();
      swPanel.setLayout(new GridLayout(14, 2));
      swPanel.add(buildJPanel(new JLabel("Length (m)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlLength));
      swPanel.add(buildJPanel(new JLabel("Width (m)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlWidth));
      swPanel.add(buildJPanel(new JLabel("Height (m)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlHeight));
      swPanel.add(buildJPanel(new JLabel("Number of Cars", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlNumCars));
      swPanel.add(buildJPanel(new JLabel("Motor Power (W)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlMotorPower));
      swPanel.add(buildJPanel(new JLabel("Maximum Speed (m/s)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlMaxSpeed));
      swPanel.add(buildJPanel(new JLabel("Service Brake Deceleration (m/s^2)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlServiceBrakeDecel));
      swPanel.add(buildJPanel(new JLabel("Emergency Brake Deceleration (m/s^2)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlEmergencyBrakeDecel));
      swPanel.add(buildJPanel(new JLabel("Coefficient of Friction", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlFrictionCoeff));
      swPanel.add(
          buildJPanel(new JLabel("Train Mass (not inc. passengers/crew) (kg)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlEmptyTrainMass));
      swPanel.add(buildJPanel(new JLabel("Mass Per Passenger/Crew (kg)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlPersonMass));
      swPanel.add(buildJPanel(new JLabel("Maximum Seated Passenger Count", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlMaxSeatedCount));
      swPanel.add(buildJPanel(new JLabel("Maximum Standing Passenger Count", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlMaxStandingCount));
      swPanel.add(buildJPanel(new JLabel("Maximum Crew Count", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlMaxCrewCount));

      staticWindow = new JFrame();
      staticWindow.setTitle("Train Model (Chris Paskie)   -   Static Values   (Train ID:   --)");
      staticWindow.setSize(700, 600);
      staticWindow.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
      staticWindow.add(swPanel);
      isVisibleStatic = false;
      staticWindow.setVisible(isVisibleStatic);

      // Set up the TNC UI.
      if (!isSolo) {
        tncUI = new TNC_UI();
      }

    } catch (Exception e) {
      e.printStackTrace(System.err);
      JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE);
    }
  }
Exemple #17
0
  /**
   * Constructor
   *
   * @param game
   */
  public SwingView(Game game) {
    this.game = game;

    // get frame size
    this.size = game.getSize();
    this.side = size * 100;

    UIManager.getDefaults().put("Button.disabledText", Color.BLACK);

    // set size (the game field size + the status line size + the buttons panel)
    this.setSize(side, side + 20 + 30);

    this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    this.setTitle("TicTacToe");

    // Create the main panel which will
    // contain all other panels
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    this.add(mainPanel);

    // The game status string
    JPanel status = new JPanel();
    status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS));
    status.setMaximumSize(new Dimension(side, 20));
    statusStr = new JLabel(game.getState().toString());

    status.add(statusStr);
    mainPanel.add(status);

    // The game field panel
    gameField = new JPanel();
    gameField.setSize(side, side);
    gameField.setLayout(new GridLayout(size, size));

    // Fill the game field with buttons
    for (int i = 0; i < size * size; i++) {
      gameField.add(createButton());
    }
    mainPanel.add(gameField);

    // The buttons panel
    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS));
    buttons.setMaximumSize(new Dimension(side, 50));

    JButton restartBtn = new JButton();
    restartBtn.setMaximumSize(new Dimension(side, 50));
    restartBtn.setText("Restart");

    restartBtn.addActionListener(
        e -> {
          this.dispose();
          this.game = new Game();
          new SwingView(this.game);
        });

    buttons.add(restartBtn);
    mainPanel.add(buttons);

    this.setResizable(false);
    // Game window appears on center
    this.setLocationRelativeTo(null);
    this.setVisible(true);
  }
  /** @param owner */
  WordArtCustomDialog(Frame owner) {
    super(owner, "Add Text", true);
    this.setResizable(false);
    this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String[] fontList = ge.getAvailableFontFamilyNames();
    fontCombo = new JComboBox<String>(fontList);

    italic = new JCheckBox("Italic");
    bold = new JCheckBox("Bold");

    sizeCombo = new JComboBox<String>(SZ);
    ((JLabel) sizeCombo.getRenderer()).setHorizontalAlignment(SwingConstants.CENTER);
    sizeCombo.setSelectedIndex(4);
    sizeCombo.setPreferredSize(new Dimension(45, 21)); // tweek size

    example = new JTextField(" Example ");
    example.setHorizontalAlignment(SwingConstants.CENTER);
    example.setFont(new Font("sanserif", Font.PLAIN, 28));
    example.setEditable(false);

    ok = new JButton("Apply");
    cancel = new JButton("Cancel");
    ok.setPreferredSize(cancel.getPreferredSize());

    foreground = new JButton("Color");

    fontCombo.addActionListener(this);
    italic.addItemListener(this);
    bold.addItemListener(this);
    sizeCombo.addActionListener(this);
    ok.addActionListener(this);
    cancel.addActionListener(this);
    foreground.addActionListener(this);
    // custom dialog set up
    JPanel p0 = new JPanel();
    p0.add(fontCombo);
    p0.setBorder(new TitledBorder(new EtchedBorder(), "Font family"));

    JPanel p1a = new JPanel();
    p1a.add(italic);
    p1a.add(bold);
    p1a.setBorder(new TitledBorder(new EtchedBorder(), "Font style"));

    JPanel p1b = new JPanel();
    p1b.add(sizeCombo);
    p1b.add(new JLabel("pt."));
    p1b.setBorder(new TitledBorder(new EtchedBorder(), "Font size"));

    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
    p1.add(p1a);
    p1.add(p1b);
    p1.setAlignmentX(Component.CENTER_ALIGNMENT);

    JPanel p2 = new JPanel(); // use FlowLayout
    p2.add(foreground);
    p2.setBorder(new TitledBorder(new EtchedBorder(), "Message color"));
    p2.setAlignmentX(Component.CENTER_ALIGNMENT);

    JPanel p3 = new JPanel();
    p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
    p3.add(example);
    p3.setPreferredSize(new Dimension(250, 60));
    p3.setMaximumSize(new Dimension(250, 60));
    p3.setAlignmentX(Component.CENTER_ALIGNMENT);

    JPanel p4 = new JPanel();
    p4.add(ok);
    p4.add(cancel);
    p4.setAlignmentX(Component.CENTER_ALIGNMENT);

    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(p0);
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(p1);
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(p2);
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(p3);
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(p4);
    p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // tweek sizes of panels to make the dialog look nice

    Dimension d1 = p3.getPreferredSize();
    Dimension d2 = p1.getPreferredSize();
    p1.setPreferredSize(new Dimension(d1.width, d2.height));
    p1.setMaximumSize(new Dimension(d1.width, d2.height));
    d2 = p2.getPreferredSize();
    p2.setPreferredSize(new Dimension(d1.width, d2.height));
    p2.setMaximumSize(new Dimension(d1.width, d2.height));

    this.setContentPane(p);
    this.pack();
  }
  public GUI() {

    // Frame
    frame = new JFrame("HardwareSwap Notifier");

    // Panels
    panel = new JPanel();
    group1 = new JPanel();
    group2 = new JPanel();
    group3 = new JPanel();
    group4 = new JPanel();
    group5 = new JPanel();
    group6 = new JPanel();
    group7 = new JPanel();
    group8 = new JPanel();

    // Menu Bar
    menus = new JMenuBar();
    fileMenu = new JMenu("File");
    clearCurrent = new JMenuItem("Clear");
    quitItem = new JMenuItem("Quit");
    load = new JMenuItem("Load");
    saveCurrent = new JMenuItem("Save All");
    clearSaved = new JMenuItem("Clear Saved");
    removeItem = new JMenuItem("Remove Item");
    removePhone = new JMenuItem("Remove Phone");
    saveCurrent = new JMenuItem("Save Current");
    helpMenu = new JMenu("Help");
    help = new JMenuItem("How To Use");
    about = new JMenuItem("About");

    // Buttons
    add1 = new JButton("Add");
    add2 = new JButton("Add");
    start = new JButton("Start");
    stop = new JButton("Stop");
    save1 = new JButton("Add/Save");
    save2 = new JButton("Add/Save");
    show = new JButton("Display Data");

    add1.setFocusPainted(false);
    add2.setFocusPainted(false);
    start.setFocusPainted(false);
    stop.setFocusPainted(false);
    save1.setFocusPainted(false);
    save2.setFocusPainted(false);
    show.setFocusPainted(false);

    stop.setEnabled(false);

    // CheckBox
    remove = new JCheckBox("Remove items when found");
    remove.setFocusable(false);

    // Listener
    ButtonListener listener = new ButtonListener();

    add1.addActionListener(listener);
    add2.addActionListener(listener);
    start.addActionListener(listener);
    stop.addActionListener(listener);
    load.addActionListener(listener);
    save1.addActionListener(listener);
    save2.addActionListener(listener);
    saveCurrent.addActionListener(listener);
    show.addActionListener(listener);
    quitItem.addActionListener(listener);
    clearCurrent.addActionListener(listener);
    clearSaved.addActionListener(listener);
    saveCurrent.addActionListener(listener);
    help.addActionListener(listener);
    about.addActionListener(listener);
    removePhone.addActionListener(listener);
    removeItem.addActionListener(listener);
    remove.addActionListener(listener);

    // Carrier Selection
    options = new String[10];
    options[0] = "AT&T";
    options[1] = "Boost Mobile";
    options[2] = "Cellular One";
    options[3] = "Nextel";
    options[4] = "T-Mobile";
    options[5] = "Tracfone";
    options[6] = "US Cellular";
    options[7] = "Sprint";
    options[8] = "Verizon";
    options[9] = "Virgin Mobile";

    carriers = new JComboBox<String>(options);

    // Text Fields
    searchName = new JTextField(15);
    item = new JTextField(15);
    phone = new JTextField(15);
    interval2 = new JTextField(15);
    results = new JTextArea(10, 20);

    JScrollPane scrollPane = new JScrollPane(results);

    results.setEditable(false);

    // Interval
    intOptions = new SpinnerNumberModel(5, 1, 60, 1);
    interval = new JSpinner(intOptions);
    JFormattedTextField tf = ((JSpinner.DefaultEditor) interval.getEditor()).getTextField();
    tf.setHorizontalAlignment(JFormattedTextField.LEFT);

    // Background
    panelBackground = new Color(237, 237, 237);

    panel.setBackground(panelBackground);
    searchName.setBackground(panelBackground);
    item.setBackground(panelBackground);
    phone.setBackground(panelBackground);
    interval.setBackground(panelBackground);

    // Panel Layouts
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    group1.setLayout(new BoxLayout(group1, BoxLayout.PAGE_AXIS));
    group2.setLayout(new BoxLayout(group2, BoxLayout.X_AXIS));
    group3.setLayout(new BoxLayout(group3, BoxLayout.PAGE_AXIS));
    group4.setLayout(new BoxLayout(group4, BoxLayout.X_AXIS));
    group5.setLayout(new BoxLayout(group5, BoxLayout.X_AXIS));
    group6.setLayout(new BoxLayout(group6, BoxLayout.X_AXIS));
    group7.setLayout(new BoxLayout(group7, BoxLayout.X_AXIS));
    group8.setLayout(new BoxLayout(group8, BoxLayout.X_AXIS));

    // Borders
    searchName.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Search Name",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    item.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Item",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    phone.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Cell Phone",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    group5.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Check Interval (mins)",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));

    // Sizes
    panel.setPreferredSize(new Dimension(200, 0));
    searchName.setMaximumSize(new Dimension(190, 50));
    item.setMaximumSize(new Dimension(190, 50));
    phone.setMaximumSize(new Dimension(185, 50));
    carriers.setMaximumSize(new Dimension(175, 20));
    group5.setPreferredSize(new Dimension(190, 47));
    group5.setMaximumSize(new Dimension(190, 47));

    add1.setMaximumSize(new Dimension(90, 20));
    save1.setMaximumSize(new Dimension(90, 20));
    add2.setMaximumSize(new Dimension(90, 20));
    save2.setMaximumSize(new Dimension(90, 20));
    start.setMaximumSize(new Dimension(90, 20));
    stop.setMaximumSize(new Dimension(90, 20));
    show.setMaximumSize(new Dimension(120, 20));

    // Add file menu items
    fileMenu.add(clearCurrent);
    fileMenu.add(clearSaved);
    fileMenu.add(load);
    fileMenu.add(removeItem);
    fileMenu.add(removePhone);
    fileMenu.add(saveCurrent);
    fileMenu.add(quitItem);

    // Add help menu items
    helpMenu.add(help);
    helpMenu.add(about);

    // Add to menu bar
    menus.add(fileMenu);
    menus.add(helpMenu);

    // Add items to panel
    group1.add(searchName);
    group1.add(item);

    group2.add(add1);
    group2.add(Box.createHorizontalStrut(10));
    group2.add(save1);

    group6.add(remove);

    group3.add(phone);
    group3.add(Box.createVerticalStrut(10));
    group3.add(carriers);

    group4.add(add2);
    group4.add(Box.createHorizontalStrut(10));
    group4.add(save2);

    group5.add(interval);

    group7.add(show);

    group8.add(start);
    group8.add(Box.createHorizontalStrut(10));
    group8.add(stop);

    panel.add(Box.createVerticalStrut(10));
    panel.add(group1);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group2);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group3);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group4);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group5);
    panel.add(Box.createVerticalStrut(30));
    panel.add(group6);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group7);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group8);
    panel.add(Box.createVerticalStrut(10));

    // Setup frame
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menus);
    frame.add(scrollPane);
    frame.add(BorderLayout.EAST, panel);
    frame.pack();
    frame.setSize(new Dimension(670, 620));
    frame.setVisible(true);
  }
  /**
   * Present a GUI allowing the user to select shots in which each previously selected asset should
   * be updated.
   *
   * @return
   * @throws PipelineException
   */
  private String confirmShotsToUpdate() throws PipelineException {

    /* DO GUI DRAWING STUFF*/
    JScrollPane scroll = null;
    {
      Box ibox = new Box(BoxLayout.Y_AXIS);
      if (pAssetManager.isEmpty()) {
        Component comps[] = UIFactory.createTitledPanels();
        JPanel tpanel = (JPanel) comps[0];
        JPanel vpanel = (JPanel) comps[1];

        tpanel.add(Box.createRigidArea(new Dimension(sTSize - 7, 0)));
        vpanel.add(Box.createHorizontalGlue());

        ibox.add(comps[2]);
      } else {

        for (String assetName : pAssetManager.keySet()) {
          String name = getShortName(assetName);
          AssetInfo info = pAssetManager.get(assetName);

          Component comps[] = UIFactory.createTitledPanels();
          JPanel tpanel = (JPanel) comps[0];
          JPanel vpanel = (JPanel) comps[1];
          String title = "Replace " + name + " with ";
          title += getShortName(info.getNewAsset());

          JDrawer shotList = new JDrawer(title, (JComponent) comps[2], true);
          ibox.add(shotList);

          for (String shot : info.getLoHiResShots().keySet()) {

            String shortShot = getShortName(shot);
            JBooleanField field =
                UIFactory.createTitledBooleanField(
                    tpanel,
                    shortShot,
                    sVSize,
                    vpanel,
                    sTSize,
                    "Whether to replace this asset source for the node.");
            field.setName(shot);
            field.setValue(true);

            if (!pSubstituteFields.containsKey(assetName))
              pSubstituteFields.put(assetName, new LinkedList<JBooleanField>());

            pSubstituteFields.get(assetName).add(field);
            UIFactory.addVerticalSpacer(tpanel, vpanel, 3);
          }
        }
      }

      {
        JPanel spanel = new JPanel();
        spanel.setName("Spacer");

        spanel.setMinimumSize(new Dimension(sTSize + sVSize, 7));
        spanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
        spanel.setPreferredSize(new Dimension(sTSize + sVSize, 7));

        ibox.add(spanel);
      }

      {
        scroll = new JScrollPane(ibox);
        scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        Dimension size = new Dimension(sTSize + sVSize + 52, 300);
        scroll.setMinimumSize(size);
        scroll.setPreferredSize(size);

        scroll.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
      }
    }

    /* query the user */
    JToolDialog diag = new JToolDialog("Update Assets Per Shot", scroll, "Confirm");
    diag.setVisible(true);

    /* Process User Input */
    if (diag.wasConfirmed()) {

      for (String asset : pSubstituteFields.keySet()) {
        for (JBooleanField field : pSubstituteFields.get(asset)) {
          Boolean bUpdate = field.getValue();
          if ((bUpdate == null) || !bUpdate) {
            pAssetManager.get(asset).getLoHiResShots().remove(field.getName());

            // logLine("\tRemoving: "+ getShortName(field.getName())
            // TODO		+" from list for "+ getShortName(asset));
          }
        }
      }
      return ": Modifying Nodes...";
    }
    return null;
  } // end confirmShotsToUpdate
  /** Construct a new dialog. */
  public JExecDetailsDialog() {
    super("Execution Details");

    /* create dialog body components */
    {
      JPanel body = new JPanel();
      body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS));

      {
        JPanel panel = new JPanel();
        panel.setName("MainDialogPanel");
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

        /* working directory */
        {
          panel.add(UIFactory.createPanelLabel("Working Directory:"));

          panel.add(Box.createRigidArea(new Dimension(0, 4)));

          JTextField field = UIFactory.createTextField(null, 100, JLabel.LEFT);
          pWorkingDirField = field;

          panel.add(field);
        }

        body.add(panel);
      }

      {
        JPanel panel = new JPanel();
        panel.setName("HorizontalBar");

        Dimension size = new Dimension(100, 7);
        panel.setPreferredSize(size);
        panel.setMinimumSize(size);
        panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 7));

        body.add(panel);
      }

      /* command line */
      JPanel above = new JPanel();
      {
        above.setName("MainDialogPanel");
        above.setLayout(new BoxLayout(above, BoxLayout.Y_AXIS));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createRigidArea(new Dimension(4, 0)));

          {
            JLabel label = new JLabel("X");
            pCommandLineLabel = label;

            label.setName("PanelLabel");

            hbox.add(label);
          }

          hbox.add(Box.createHorizontalGlue());

          above.add(hbox);
        }

        above.add(Box.createRigidArea(new Dimension(0, 4)));

        {
          JTextArea area = new JTextArea(null, 5, 70);
          pCommandLineArea = area;

          area.setName("CodeTextArea");
          area.setLineWrap(true);
          area.setWrapStyleWord(true);
          area.setEditable(false);
        }

        {
          JScrollPane scroll =
              UIFactory.createScrollPane(
                  pCommandLineArea,
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(100, 27),
                  null,
                  null);

          above.add(scroll);
        }
      }

      /* environment */
      JPanel below = new JPanel();
      {
        below.setName("MainDialogPanel");
        below.setLayout(new BoxLayout(below, BoxLayout.Y_AXIS));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createRigidArea(new Dimension(4, 0)));

          {
            JLabel label = new JLabel("X");
            pEnvLabel = label;

            label.setName("PanelLabel");

            hbox.add(label);
          }

          hbox.add(Box.createHorizontalGlue());

          below.add(hbox);
        }

        below.add(Box.createRigidArea(new Dimension(0, 4)));

        Component comps[] = UIFactory.createTitledPanels();
        {
          JPanel tpanel = (JPanel) comps[0];
          JPanel vpanel = (JPanel) comps[1];

          tpanel.add(Box.createRigidArea(new Dimension(sTSize, 0)));
          vpanel.add(Box.createHorizontalGlue());
        }

        {
          pEnvScroll =
              UIFactory.createScrollPane(
                  comps[2],
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(100, 50),
                  new Dimension(100, 300),
                  null);

          below.add(pEnvScroll);
        }
      }

      {
        JVertSplitPanel split = new JVertSplitPanel(above, below);
        split.setResizeWeight(0.0);
        split.setAlignmentX(0.5f);

        body.add(split);
      }

      super.initUI("X", body, null, null, null, "Close", null);
    }
  }
  public PlaceMover() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    JPanel moverPanel = new JPanel();
    moverPanel.setLayout(new BoxLayout(moverPanel, BoxLayout.Y_AXIS));
    Border moverBorder = BorderFactory.createTitledBorder("Set Mover");
    moverPanel.setBorder(moverBorder);
    // AddBallListener startListener = new AddBallListener();
    ballButton = new JRadioButton("Launch Ball");
    Window.placeableGroup.add(ballButton);
    moverPanel.add(ballButton);

    rocketButton = new JRadioButton("Launch Rocket");
    Window.placeableGroup.add(rocketButton);
    moverPanel.add(rocketButton);

    JPanel positionLabelPanel = new JPanel();
    positionLabelPanel.setLayout(new BoxLayout(positionLabelPanel, BoxLayout.X_AXIS));
    positionLabelPanel.add(new JLabel("Position:"));

    JButton launchButton = new JButton("<-");
    LaunchListener launchListener = new LaunchListener();
    launchButton.addActionListener(launchListener);
    positionLabelPanel.add(launchButton);
    moverPanel.add(positionLabelPanel);
    JPanel positionPanel = new JPanel();
    positionPanel.setLayout(new BoxLayout(positionPanel, BoxLayout.X_AXIS));

    positionPanel.add(new JLabel("X:"));
    xPosition = new JTextField("0.0", 1);
    positionPanel.add(xPosition);

    positionPanel.add(new JLabel("Y:"));
    yPosition = new JTextField("0.0", 1);
    yPosition.setSize(4, 4);
    positionPanel.add(yPosition);
    moverPanel.add(positionPanel);

    JLabel angleLabel = new JLabel("Angle:");
    // angleLabel.setAlignmentX(LEFT_ALIGNMENT);
    moverPanel.add(angleLabel);
    projectileAngle = new JTextField("1.0", 10);
    moverPanel.add(projectileAngle);
    projectileAngle.setMaximumSize(projectileAngle.getPreferredSize());

    JLabel speedLabel = new JLabel("Speed:");
    // speedLabel.setAlignmentX(LEFT_ALIGNMENT);
    moverPanel.add(speedLabel);
    projectileSpeed = new JTextField("4.0", 10);
    moverPanel.add(projectileSpeed);
    projectileSpeed.setMaximumSize(projectileSpeed.getPreferredSize());

    moverPanel.add(new JLabel("(Rocket) Force:"));
    rocketForce = new JTextField("10.0", 10);
    moverPanel.add(rocketForce);
    rocketForce.setMaximumSize(rocketForce.getPreferredSize());

    moverPanel.add(new JLabel("Mass:"));
    projectileMass = new JTextField("1.0", 10);
    moverPanel.add(projectileMass);
    projectileMass.setMaximumSize(projectileMass.getPreferredSize());

    moverPanel.add(new JLabel("Charge:"));
    projectileCharge = new JTextField("0", 10);
    moverPanel.add(projectileCharge);
    projectileCharge.setMaximumSize(projectileCharge.getPreferredSize());

    moverPanel.setMaximumSize(moverPanel.getPreferredSize());

    add(moverPanel);
  }
Exemple #23
0
  public NewClassDialog(CanvasPanel cp, int x, int y) {
    guiFrame = new JFrame();
    guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    guiFrame.setTitle("Class Options...");
    guiFrame.setSize(270, 550);
    guiFrame.setLocationRelativeTo(null);

    canvasPanel = cp;
    this.x = x;
    this.y = y;

    JPanel optionPanel = new JPanel();
    JPanel optionPanel2 = new JPanel();
    JPanel optionPanel3 = new JPanel();
    JPanel optionPanel4 = new JPanel();
    Border outline = BorderFactory.createLineBorder(Color.black);
    optionPanel.setBorder(outline);
    optionPanel2.setBorder(outline);
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
    optionPanel2.setLayout(new BoxLayout(optionPanel2, BoxLayout.Y_AXIS));
    optionPanel2.setBorder(outline);
    className = new JTextField(8);
    JLabel newClass = new JLabel("NewClass:");
    listObject = new DefaultListModel();
    listObject.addElement("item1");
    listObject.addElement("item2");
    final JList obList = new JList(listObject);
    JScrollPane scrollPane = new JScrollPane(obList);
    objectt = new JTextField();
    JLabel object = new JLabel("Instance Variables");

    methodt = new JTextField();
    JLabel method = new JLabel("Methods");
    listMethod = new DefaultListModel();
    listMethod.addElement("item1");
    listMethod.addElement("item2");
    final JList metList = new JList(listMethod);
    JScrollPane scrollPane2 = new JScrollPane(metList);
    JLabel newVar = new JLabel("New Variable Name:");
    JLabel newMet = new JLabel("New Method Name:");
    JButton OK = new JButton("OK");
    JButton CANCEL = new JButton("CANCEL");
    JLabel ofType = new JLabel("Of Type:");
    JLabel type = new JLabel("Type:");
    JLabel metofType = new JLabel("Of Type:");
    JLabel mettype = new JLabel("Type:");
    aButton = new JRadioButton("Public");
    bButton = new JRadioButton("Private");
    cButton = new JRadioButton("Protected");
    dButton = new JRadioButton("Defualt");
    IntButton = new JRadioButton("Int");
    StrButton = new JRadioButton("String");
    BoolButton = new JRadioButton("Bool");
    DoubButton = new JRadioButton("Double");
    OthButton = new JRadioButton("Other");
    aButton2 = new JRadioButton("Public");
    bButton2 = new JRadioButton("Private");
    cButton2 = new JRadioButton("Protected");
    dButton2 = new JRadioButton("Defualt");
    intButton2 = new JRadioButton("Int");
    strButton2 = new JRadioButton("String");
    boolButton2 = new JRadioButton("Bool");
    doubButton2 = new JRadioButton("Double");
    othButton2 = new JRadioButton("Other");
    // Create a ButtonGroup object, add buttons to the group
    ButtonGroup sign = new ButtonGroup();
    sign.add(aButton);
    sign.add(bButton);
    sign.add(cButton);
    sign.add(dButton);

    ButtonGroup oftype = new ButtonGroup();
    oftype.add(IntButton);
    oftype.add(StrButton);
    oftype.add(BoolButton);
    oftype.add(DoubButton);
    oftype.add(OthButton);

    ButtonGroup metsign = new ButtonGroup();
    metsign.add(aButton2);
    metsign.add(bButton2);
    metsign.add(cButton2);
    metsign.add(dButton2);

    ButtonGroup metoftype = new ButtonGroup();
    metoftype.add(intButton2);
    metoftype.add(strButton2);
    metoftype.add(boolButton2);
    metoftype.add(doubButton2);
    metoftype.add(othButton2);

    textt = new JTextField();
    textt.disable();
    OthButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {

            if (OthButton.isSelected()) {
              textt.enable();
            }
            // disable when not using!!!******************************************************

          }
        });
    mettextt = new JTextField();
    mettextt.disable();
    othButton2.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {

            if (othButton2.isSelected()) {
              mettextt.enable();
            }
            // disable when not using!!!******************************************************

          }
        });
    JButton addObject = new JButton("Add Object        ");
    addObject.setActionCommand("Add Object");
    addObject.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {

            String sign = null;
            String type = null;
            String space = " ";

            if (!aButton.isSelected()
                && !bButton.isSelected()
                && !cButton.isSelected()
                && !dButton.isSelected()) {
              String message =
                  "You did not select a type! Select one before continuing.(Public etc.)";
              JOptionPane.showMessageDialog(
                  new JFrame(), message, "Invalid Input!", JOptionPane.ERROR_MESSAGE);
            } else if (!StrButton.isSelected()
                && !IntButton.isSelected()
                && !BoolButton.isSelected()
                && !DoubButton.isSelected()
                && !OthButton.isSelected()) {
              String message =
                  "You did not select an of type! Select one before continuing.(Int etc.)";
              JOptionPane.showMessageDialog(
                  new JFrame(), message, "Invalid Input!", JOptionPane.ERROR_MESSAGE);
            } else {
              if (aButton.isSelected()) {
                sign = "+";
              }

              if (bButton.isSelected()) {
                sign = "-";
              }
              if (cButton.isSelected()) {
                sign = "#";
              }
              if (dButton.isSelected()) {
                sign = "~";
              }
              if (StrButton.isSelected()) {
                type = ": String";
              }
              if (IntButton.isSelected()) {
                type = ": int";
              }
              if (BoolButton.isSelected()) {
                type = ": Bool";
              }
              if (DoubButton.isSelected()) {
                type = ": double";
              }
              if (OthButton.isSelected()) {
                type = ": " + textt.getText();
              }

              listObject.add(0, sign + space + objectt.getText() + space + type);
            }
          }
        });

    JButton removeObject = new JButton("Remove Object");
    removeObject.setActionCommand("Remove Object");
    removeObject.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {

            listObject.remove(obList.getSelectedIndex());
          }
        });
    JButton changeObject = new JButton("Change Object ");
    changeObject.setActionCommand("Change Object");
    changeObject.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {}
        });
    JButton addMethod = new JButton("Add Method        ");
    addMethod.setActionCommand("Add Method");
    addMethod.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {

            String sign2 = null;
            String type2 = null;
            String space2 = " ";
            String brackets = "()";

            if (!aButton2.isSelected()
                && !bButton2.isSelected()
                && !cButton2.isSelected()
                && !dButton2.isSelected()) {
              String message =
                  "You did not select a type! Select one before continuing.(Public etc.) ";
              JOptionPane.showMessageDialog(
                  new JFrame(), message, "Invalid Input!", JOptionPane.ERROR_MESSAGE);
            } else if (!strButton2.isSelected()
                && !intButton2.isSelected()
                && !boolButton2.isSelected()
                && !doubButton2.isSelected()
                && !othButton2.isSelected()) {
              String message =
                  "You did not select an of type! Select one before continuing.(Int etc.) ";
              JOptionPane.showMessageDialog(
                  new JFrame(), message, "Invalid Input!", JOptionPane.ERROR_MESSAGE);
            } else {
              if (aButton2.isSelected()) {
                sign2 = "+";
              }
              if (bButton2.isSelected()) {
                sign2 = "-";
              }
              if (cButton2.isSelected()) {
                sign2 = "#";
              }
              if (dButton2.isSelected()) {
                sign2 = "~";
              }
              if (strButton2.isSelected()) {
                type2 = ": String";
              }
              if (intButton2.isSelected()) {
                type2 = ": int";
              }
              if (boolButton2.isSelected()) {
                type2 = ": Bool";
              }
              if (doubButton2.isSelected()) {
                type2 = ": double";
              }
              if (othButton2.isSelected()) {
                type2 = ": " + mettextt.getText();
              }
              listMethod.add(0, sign2 + space2 + methodt.getText() + brackets + space2 + type2);
            }
          }
        });
    JButton removeMethod = new JButton("Remove Method");
    removeMethod.setActionCommand("Remove Method");
    removeMethod.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {
            listMethod.remove(metList.getSelectedIndex());
          }
        });
    JButton changeMethod = new JButton("Change Method ");
    changeMethod.setActionCommand("Change Method");
    removeObject.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {}
        });
    // settiong size of panels
    Dimension Size = new Dimension(300, 100);
    objectt.setMaximumSize(Size);
    methodt.setMaximumSize(Size);
    className.setMaximumSize(Size);
    optionPanel.setMaximumSize(Size);
    optionPanel2.setMaximumSize(Size);

    scrollPane2.setMaximumSize(Size);
    scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    method.setMaximumSize(Size);
    scrollPane.setMaximumSize(Size);
    scrollPane2.setAlignmentX(Component.LEFT_ALIGNMENT);
    object.setMaximumSize(Size);

    optionPanel.add(object);
    optionPanel.add(scrollPane);
    optionPanel.add(newVar);
    optionPanel.add(objectt);
    optionPanel.add(type);
    optionPanel.add(aButton);
    optionPanel.add(bButton);
    optionPanel.add(cButton);
    optionPanel.add(dButton);
    optionPanel.add(ofType);
    optionPanel.add(IntButton);
    optionPanel.add(StrButton);
    optionPanel.add(BoolButton);
    optionPanel.add(DoubButton);
    optionPanel.add(OthButton);
    optionPanel.add(textt);
    optionPanel.add(addObject);
    optionPanel.add(changeObject);
    optionPanel.add(removeObject);
    optionPanel2.add(method);
    optionPanel2.add(scrollPane2);
    optionPanel2.add(newMet);
    optionPanel2.add(methodt);
    optionPanel2.add(mettype);
    optionPanel2.add(aButton2);
    optionPanel2.add(bButton2);
    optionPanel2.add(cButton2);
    optionPanel2.add(dButton2);
    optionPanel2.add(metofType);
    optionPanel2.add(intButton2);
    optionPanel2.add(strButton2);
    optionPanel2.add(boolButton2);
    optionPanel2.add(doubButton2);
    optionPanel2.add(othButton2);
    optionPanel2.add(mettextt);
    optionPanel2.add(addMethod);
    optionPanel2.add(changeMethod);
    optionPanel2.add(removeMethod);
    optionPanel3.add(CANCEL);
    optionPanel3.add(OK);
    optionPanel4.add(newClass);
    optionPanel4.add(className);

    guiFrame.add(optionPanel, BorderLayout.WEST);

    guiFrame.add(optionPanel2, BorderLayout.EAST);

    guiFrame.add(optionPanel3, BorderLayout.SOUTH);

    guiFrame.add(optionPanel4, BorderLayout.NORTH);
    buttonPanel = new JPanel();

    guiFrame.setVisible(true);

    CANCEL.setActionCommand("CANCEL");
    CANCEL.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent event) {

            guiFrame.dispose();
          }
        });

    OK.setActionCommand("OK");
    OK.addActionListener(this);
  }
  private void initialize() {
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JLabel label =
        new JLabel(
            "It is up to you whether or not to include the source when you distribute your robot.");

    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    label =
        new JLabel(
            "If you include the source, other people will be able to look at your code and learn from it.");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    getIncludeSource().setAlignmentX(Component.LEFT_ALIGNMENT);
    add(getIncludeSource());

    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getVersionLabel());

    JPanel p = new JPanel();

    p.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setAlignmentX(Component.LEFT_ALIGNMENT);
    getVersionField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getVersionField().setMaximumSize(getVersionField().getPreferredSize());
    p.setMaximumSize(new Dimension(Integer.MAX_VALUE, getVersionField().getPreferredSize().height));
    p.add(getVersionField());
    p.add(getVersionHelpLabel());
    add(p);

    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getDescriptionLabel());

    JScrollPane scrollPane =
        new JScrollPane(
            getDescriptionArea(),
            ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    scrollPane.setMaximumSize(scrollPane.getPreferredSize());
    scrollPane.setMinimumSize(new Dimension(100, scrollPane.getPreferredSize().height));
    scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(scrollPane);

    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getAuthorLabel());

    getAuthorField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getAuthorField().setMaximumSize(getAuthorField().getPreferredSize());
    add(getAuthorField());

    label = new JLabel(" ");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(label);

    add(getWebpageLabel());

    getWebpageField().setAlignmentX(Component.LEFT_ALIGNMENT);
    getWebpageField().setMaximumSize(getWebpageField().getPreferredSize());
    add(getWebpageField());

    getWebpageHelpLabel().setAlignmentX(Component.LEFT_ALIGNMENT);
    add(getWebpageHelpLabel());

    JPanel panel = new JPanel();

    panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(panel);
    addComponentListener(eventHandler);
  }
  private void jbInit() throws Exception {
    panel1.setLayout(borderLayout1);
    jLabelSynapseType.setText("Synapse type:");
    jLabelDelay.setText("Internal delay:");
    jButtonOK.setText("OK");
    jButtonOK.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jButtonOK_actionPerformed(e);
          }
        });
    jButtonCancel.setText("Cancel");
    jButtonCancel.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jButtonCancel_actionPerformed(e);
          }
        });
    jPanelMain.setLayout(gridBagLayout1);
    jButtonDelay.setText("...");
    jButtonDelay.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jButtonDelay_actionPerformed(e);
          }
        });
    jTextFieldDelay.setEditable(false);
    jTextFieldDelay.setText("");
    panel1.setMaximumSize(new Dimension(400, 200));
    panel1.setMinimumSize(new Dimension(400, 200));
    panel1.setPreferredSize(new Dimension(400, 200));
    jLabelWeights.setText("Synaptic weights:");
    jButtonWeights.setText("...");
    jButtonWeights.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jButtonWeights_actionPerformed(e);
          }
        });
    jTextFieldWeights.setEditable(false);
    jTextFieldWeights.setText("");
    jLabelThreshold.setText("Voltage threshold:");
    jTextFieldThreshold.setText("");
    getContentPane().add(panel1);
    panel1.add(jPanelMain, BorderLayout.CENTER);
    jPanelMain.add(
        jLabelSynapseType,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(6, 20, 6, 12),
            0,
            0));

    jPanelMain.add(
        jLabelDelay,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(6, 20, 6, 0),
            0,
            0));
    jPanelMain.add(
        jTextFieldDelay,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(6, 0, 6, 6),
            0,
            0));
    jPanelMain.add(
        jButtonDelay,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(0, 6, 0, 20),
            0,
            0));
    jPanelMain.add(
        jLabelWeights,
        new GridBagConstraints(
            0,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(6, 12, 6, 12),
            0,
            0));
    jPanelMain.add(
        jTextFieldWeights,
        new GridBagConstraints(
            1,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(6, 0, 6, 6),
            0,
            0));
    jPanelMain.add(
        jButtonWeights,
        new GridBagConstraints(
            2,
            2,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(6, 6, 6, 20),
            0,
            0));
    panel1.add(jPanelButtons, BorderLayout.SOUTH);
    jPanelButtons.add(jButtonOK, null);
    jPanelButtons.add(jButtonCancel, null);
    jPanelMain.add(
        jLabelThreshold,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(6, 12, 6, 12),
            0,
            0));
    jPanelMain.add(
        jTextFieldThreshold,
        new GridBagConstraints(
            1,
            3,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(6, 0, 6, 20),
            0,
            0));
    jPanelMain.add(
        jComboBoxSynapseType,
        new GridBagConstraints(
            1,
            0,
            2,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(6, 0, 6, 20),
            0,
            0));
  }
  protected boolean exportApplicationPrompt() throws IOException, SketchException {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(Box.createVerticalStrut(6));

    // Box panel = Box.createVerticalBox();

    // Box labelBox = Box.createHorizontalBox();
    //    String msg = "<html>Click Export to Application to create a standalone, " +
    //      "double-clickable application for the selected plaforms.";

    //    String msg = "Export to Application creates a standalone, \n" +
    //      "double-clickable application for the selected plaforms.";
    String line1 = "Export to Application creates double-clickable,";
    String line2 = "standalone applications for the selected plaforms.";
    JLabel label1 = new JLabel(line1, SwingConstants.CENTER);
    JLabel label2 = new JLabel(line2, SwingConstants.CENTER);
    label1.setAlignmentX(Component.LEFT_ALIGNMENT);
    label2.setAlignmentX(Component.LEFT_ALIGNMENT);
    //    label1.setAlignmentX();
    //    label2.setAlignmentX(0);
    panel.add(label1);
    panel.add(label2);
    int wide = label2.getPreferredSize().width;
    panel.add(Box.createVerticalStrut(12));

    final JCheckBox windowsButton = new JCheckBox("Windows");
    // windowsButton.setMnemonic(KeyEvent.VK_W);
    windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows"));
    windowsButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean(
                "export.application.platform.windows", windowsButton.isSelected());
          }
        });

    final JCheckBox macosxButton = new JCheckBox("Mac OS X");
    // macosxButton.setMnemonic(KeyEvent.VK_M);
    macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx"));
    macosxButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected());
          }
        });

    final JCheckBox linuxButton = new JCheckBox("Linux");
    // linuxButton.setMnemonic(KeyEvent.VK_L);
    linuxButton.setSelected(Preferences.getBoolean("export.application.platform.linux"));
    linuxButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.platform.linux", linuxButton.isSelected());
          }
        });

    JPanel platformPanel = new JPanel();
    // platformPanel.setLayout(new BoxLayout(platformPanel, BoxLayout.X_AXIS));
    platformPanel.add(windowsButton);
    platformPanel.add(Box.createHorizontalStrut(6));
    platformPanel.add(macosxButton);
    platformPanel.add(Box.createHorizontalStrut(6));
    platformPanel.add(linuxButton);
    platformPanel.setBorder(new TitledBorder("Platforms"));
    // Dimension goodIdea = new Dimension(wide, platformPanel.getPreferredSize().height);
    // platformPanel.setMaximumSize(goodIdea);
    wide = Math.max(wide, platformPanel.getPreferredSize().width);
    platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(platformPanel);

    //  Box indentPanel = Box.createHorizontalBox();
    //  indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width));
    final JCheckBox showStopButton = new JCheckBox("Show a Stop button");
    // showStopButton.setMnemonic(KeyEvent.VK_S);
    showStopButton.setSelected(Preferences.getBoolean("export.application.stop"));
    showStopButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.stop", showStopButton.isSelected());
          }
        });
    showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen"));
    showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13));
    //  indentPanel.add(showStopButton);
    //  indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)");
    // fullscreenButton.setMnemonic(KeyEvent.VK_F);
    fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen"));
    fullScreenButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            boolean sal = fullScreenButton.isSelected();
            Preferences.setBoolean("export.application.fullscreen", sal);
            showStopButton.setEnabled(sal);
          }
        });
    fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13));

    JPanel optionPanel = new JPanel();
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
    optionPanel.add(fullScreenButton);
    optionPanel.add(showStopButton);
    //    optionPanel.add(indentPanel);
    optionPanel.setBorder(new TitledBorder("Options"));
    wide = Math.max(wide, platformPanel.getPreferredSize().width);
    // goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height);
    optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    // optionPanel.setMaximumSize(goodIdea);
    panel.add(optionPanel);

    Dimension good;
    // label1, label2, platformPanel, optionPanel
    good = new Dimension(wide, label1.getPreferredSize().height);
    label1.setMaximumSize(good);
    good = new Dimension(wide, label2.getPreferredSize().height);
    label2.setMaximumSize(good);
    good = new Dimension(wide, platformPanel.getPreferredSize().height);
    platformPanel.setMaximumSize(good);
    good = new Dimension(wide, optionPanel.getPreferredSize().height);
    optionPanel.setMaximumSize(good);

    //    JPanel actionPanel = new JPanel();
    //    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS));
    //    optionPanel.add(Box.createHorizontalGlue());

    //    final JDialog frame = new JDialog(editor, "Export to Application");

    //    JButton cancelButton = new JButton("Cancel");
    //    cancelButton.addActionListener(new ActionListener() {
    //      public void actionPerformed(ActionEvent e) {
    //        frame.dispose();
    //        return false;
    //      }
    //    });

    // Add the buttons in platform-specific order
    //    if (PApplet.platform == PConstants.MACOSX) {
    //      optionPanel.add(cancelButton);
    //      optionPanel.add(exportButton);
    //    } else {
    //      optionPanel.add(exportButton);
    //      optionPanel.add(cancelButton);
    //    }
    String[] options = {"Export", "Cancel"};
    final JOptionPane optionPane =
        new JOptionPane(
            panel,
            JOptionPane.PLAIN_MESSAGE,
            // JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION,
            null,
            options,
            options[0]);

    final JDialog dialog = new JDialog(this, "Export Options", true);
    dialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (dialog.isVisible()
                && (e.getSource() == optionPane)
                && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
              // If you were going to check something
              // before closing the window, you'd do
              // it here.
              dialog.setVisible(false);
            }
          }
        });
    dialog.pack();
    dialog.setResizable(false);

    Rectangle bounds = getBounds();
    dialog.setLocation(
        bounds.x + (bounds.width - dialog.getSize().width) / 2,
        bounds.y + (bounds.height - dialog.getSize().height) / 2);
    dialog.setVisible(true);

    Object value = optionPane.getValue();
    if (value.equals(options[0])) {
      return jmode.handleExportApplication(sketch);
    } else if (value.equals(options[1]) || value.equals(new Integer(-1))) {
      // closed window by hitting Cancel or ESC
      statusNotice("Export to Application canceled.");
    }
    return false;
  }
Exemple #27
0
  private void init(Boolean showSearch) {
    dependends = new ArrayList<HoopVisualFeatureVisualizer>();

    Border border = BorderFactory.createLineBorder(Color.black);
    Border bevel = BorderFactory.createLoweredBevelBorder();

    // setBackground(HoopJColorTools.parse("#ffffff"));

    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    coreList = new JList();
    coreList.setCellRenderer(new HoopJCheckListItem());
    JScrollPane posScrollList = new JScrollPane(coreList);

    coreFilter = new JTextField();
    coreFilter.setMaximumSize(new Dimension(2000, 20));

    coreLabel = new JLabel("");
    coreLabel.setBorder(bevel);
    coreLabel.setHorizontalAlignment(JLabel.LEFT);
    coreLabel.setFont(new Font("Dialog", 1, 10));
    coreLabel.setBackground(HoopJColorTools.parse("#ffffff"));
    coreLabel.setMinimumSize(new Dimension(50, 20));
    coreLabel.setMaximumSize(new Dimension(2000, 20));

    colorPicker = new JPanel();
    colorPicker.setBackground(color);
    colorPicker.setBorder(border);
    colorPicker.setMinimumSize(new Dimension(20, 20));
    colorPicker.setPreferredSize(new Dimension(20, 20));
    colorPicker.setMaximumSize(new Dimension(20, 20));
    colorPicker.addMouseListener(this);

    Box labelBox = new Box(BoxLayout.X_AXIS);
    labelBox.add(coreLabel);
    labelBox.add(colorPicker);

    Box buttonBox = new Box(BoxLayout.X_AXIS);
    allButton = new JButton();
    allButton.setFont(new Font("Dialog", 1, 8));
    allButton.setPreferredSize(new Dimension(30, 20));
    allButton.setMaximumSize(new Dimension(2000, 20));
    allButton.setText("All");
    allButton.addActionListener(this);
    buttonBox.add(allButton);
    noneButton = new JButton();
    noneButton.setFont(new Font("Dialog", 1, 8));
    noneButton.setPreferredSize(new Dimension(30, 20));
    noneButton.setMaximumSize(new Dimension(2000, 20));
    noneButton.setText("None");
    noneButton.addActionListener(this);
    buttonBox.add(noneButton);
    inverseButton = new JButton();
    inverseButton.setFont(new Font("Dialog", 1, 8));
    inverseButton.setPreferredSize(new Dimension(30, 20));
    inverseButton.setMaximumSize(new Dimension(2000, 20));
    inverseButton.setText("Inverse");
    inverseButton.addActionListener(this);
    buttonBox.add(inverseButton);
    selectedButton = new JButton();
    selectedButton.setFont(new Font("Dialog", 1, 8));
    selectedButton.setPreferredSize(new Dimension(30, 20));
    selectedButton.setMaximumSize(new Dimension(2000, 20));
    selectedButton.setText("Selected");
    selectedButton.addActionListener(this);
    selectedButton.setEnabled(false);
    buttonBox.add(selectedButton);

    if (showSearch == true) {
      this.add(coreFilter);
    }

    this.add(labelBox);
    this.add(posScrollList);
    this.add(buttonBox);

    // >---------------------------------------------------

    coreFilter.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent keyEvent) {}

          public void keyReleased(KeyEvent keyEvent) {
            // debug ("Filtering on: " + coreFilter.getText());
            filterModel();
          }

          public void keyTyped(KeyEvent keyEvent) {}
        });

    // >---------------------------------------------------

    coreList.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent event) {
            JList list = (JList) event.getSource();

            // Get index of item clicked

            int index = list.locationToIndex(event.getPoint());
            HoopVisualFeature item = (HoopVisualFeature) coreList.getModel().getElementAt(index);

            // Toggle selected state

            item.setSelected(!item.isSelected());

            // Repaint cell

            list.repaint(list.getCellBounds(index, index));
            updateDependends();
          }
        });

    // >---------------------------------------------------
  }
Exemple #28
0
  /**
   * The class constructor.
   *
   * @param owner the GuiKeyboardInstance class instance
   * @param space plugin dimension
   */
  public GUI(final ButtonGridInstance owner, final Dimension space) {
    this.owner = owner;

    final JButton buttons[] = new JButton[owner.NUMBER_OF_KEYS];
    panel = new JPanel();

    setLayout(new BorderLayout());

    int labelHeight;

    if (owner.getCaption().length() > 0) {
      JLabel label = new JLabel(owner.getCaption(), 0);
      add(label, BorderLayout.NORTH);
      labelHeight = (int) getPreferredSize().getHeight();
    } else {
      labelHeight = 0;
    }

    for (int i = 0; i < owner.NUMBER_OF_KEYS; i++) {
      buttons[i] = new JButton();
      String caption = owner.getButtonCaption(i);
      buttons[i].setText(caption);
      if ("".equalsIgnoreCase(caption)) {
        buttons[i].setEnabled(false);
        buttons[i].setVisible(false);
      } else {
        numberOfKeys = numberOfKeys + 1;
        buttons[i].setEnabled(true);
        buttons[i].setVisible(true);

        final JButton b = buttons[i];

        // final Border raisedBevelBorder = BorderFactory.createRaisedBevelBorder();
        // final Insets insets = raisedBevelBorder.getBorderInsets(buttons[i]);
        // final EmptyBorder emptyBorder = new EmptyBorder(insets);
        // b.setBorder(emptyBorder);
        // b.setOpaque(false);
        // b.setContentAreaFilled(false);

        if (owner.propBorderColor != USE_DEFAULT_COLOR)
          b.setBorder(
              BorderFactory.createLineBorder(
                  getColorProperty(owner.propBorderColor), owner.propBorderThickness));

        b.setFocusPainted(false);
        if (!("".equalsIgnoreCase(owner.getToolTip(i)))) b.setToolTipText(owner.getToolTip(i));

        if (owner.propBackgroundColor != USE_DEFAULT_COLOR)
          b.setBackground(getColorProperty(owner.propBackgroundColor));

        if (owner.propTextColor != USE_DEFAULT_COLOR)
          b.setForeground(getColorProperty(owner.propTextColor));

        if (owner.propSelectionFrameColor != USE_DEFAULT_COLOR) {
          b.getModel()
              .addChangeListener(
                  new ChangeListener() {
                    @Override
                    public void stateChanged(ChangeEvent e) {
                      ButtonModel model = (ButtonModel) e.getSource();
                      if (model.isRollover()) {
                        // b.setBorder(raisedBevelBorder);
                        b.setBorder(
                            BorderFactory.createLineBorder(
                                getColorProperty(owner.propSelectionFrameColor),
                                owner.propSelectionFrameThickness));
                      } else {
                        // b.setBorder(emptyBorder);
                        b.setBorder(
                            BorderFactory.createLineBorder(
                                getColorProperty(owner.propBorderColor),
                                owner.propBorderThickness));
                      }
                    }
                  });
        }
      }

      final int y = i;

      buttons[i].addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              if (colSav == null) colSav = buttons[y].getBackground();
              if (owner.propSelectionFrameColor == USE_DEFAULT_COLOR)
                buttons[y].setBackground(Color.RED);
              else buttons[y].setBackground(getColorProperty(owner.propSelectionFrameColor));
              owner.etpKeyArray[y].raiseEvent();

              AstericsThreadPool.instance.execute(
                  new Runnable() {
                    public void run() {
                      try {
                        Thread.sleep(250);
                        buttons[y].setBackground(colSav);
                      } catch (InterruptedException e) {
                      }
                    }
                  });
            }
          });
    }

    if (numberOfKeys > 0) {

      Dimension buttonDimension;
      Dimension panelDimension;

      if (owner.propHorizontalOrientation == true) {
        buttonDimension = new Dimension(space.width / numberOfKeys, ((space.height - labelHeight)));

        panelDimension =
            new Dimension(numberOfKeys * buttonDimension.width, buttonDimension.height);
      } else {
        buttonDimension = new Dimension(space.width, ((space.height - labelHeight) / numberOfKeys));

        panelDimension = new Dimension(space.width, numberOfKeys * buttonDimension.height);
      }

      panel.setMaximumSize(panelDimension);
      panel.setPreferredSize(panelDimension);
      panel.setMinimumSize(panelDimension);
      panel.setVisible(true);

      if (owner.propHorizontalOrientation == true) {
        panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
      } else {
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
      }

      for (int i = 0; i < owner.NUMBER_OF_KEYS; i++) {
        buttons[i].setPreferredSize(buttonDimension);
        buttons[i].setMinimumSize(buttonDimension);
        buttons[i].setMaximumSize(buttonDimension);
        // panel.add(buttons[i]);
      }

      float maxFontSize = fontSizeMax;
      float maxFontSizeTable[] = new float[owner.NUMBER_OF_KEYS];

      Rectangle buttonRectangle = new Rectangle();

      for (int i = 0; i < owner.NUMBER_OF_KEYS; i++) {
        float fontSize = 0;
        boolean finish = false;
        maxFontSizeTable[i] = 0;
        if (owner.getButtonCaption(i).length() > 0) {
          do {

            fontSize = fontSize + fontIncrementStep;

            buttons[i].setMargin(new Insets(2, 2, 2, 2));

            Font font = buttons[i].getFont();
            font = font.deriveFont(fontSize);
            FontMetrics fontMetrics = buttons[i].getFontMetrics(font);
            Rectangle2D tmpFontSize =
                fontMetrics.getStringBounds(owner.getButtonCaption(i), buttons[i].getGraphics());

            Insets insets = buttons[i].getMargin();

            double height = tmpFontSize.getHeight();
            double width = tmpFontSize.getWidth();
            double buttonHeightSpace =
                buttonDimension.getHeight()
                    - (double) insets.bottom
                    - (double) insets.top
                    - verticalOffset;
            double buttonWidthSpace =
                buttonDimension.getWidth()
                    - (double) insets.left
                    - (double) insets.right
                    - horizontalOffset;

            if ((height >= buttonHeightSpace) || (width >= buttonWidthSpace)) {
              finish = true;
              maxFontSizeTable[i] = fontSize - 1;
            } else {

              if (fontSize > fontSizeMax) {
                finish = true;
                maxFontSizeTable[i] = fontSize;
              }
            }

          } while (!finish);
        }
      }

      for (int i = 0; i < owner.NUMBER_OF_KEYS; i++) {
        if ((maxFontSizeTable[i] > 0) && (maxFontSizeTable[i] < maxFontSize)) {
          maxFontSize = maxFontSizeTable[i];
        }
      }

      for (int i = 0; i < owner.NUMBER_OF_KEYS; i++) {
        Font font = buttons[i].getFont();
        font = font.deriveFont(maxFontSize);
        buttons[i].setFont(font);
      }
    }

    for (int i = 0; i < owner.NUMBER_OF_KEYS; i++) {
      panel.add(buttons[i]);
    }

    add(panel, BorderLayout.CENTER);
    setBorder(BorderFactory.createLineBorder(Color.BLACK));
  }
  /**
   * Draws the GUI that allows a user to select assets to be updated.
   *
   * @return true if the user made a valid choice of assets to replace.
   * @throws PipelineException
   */
  private boolean buildUpdateGUI() throws PipelineException {
    Box finalBox = new Box(BoxLayout.Y_AXIS);
    top = new Box(BoxLayout.Y_AXIS);

    JScrollPane scroll;

    {
      scroll = new JScrollPane(finalBox);

      scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
      scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

      Dimension size = new Dimension(sVSize + sVSize + sTSize + 52, 500);
      scroll.setMinimumSize(size);
      scroll.setPreferredSize(size);
      scroll.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
    }

    /* query the user */
    diag = new JToolDialog("Propagate Asset", scroll, "Continue");

    areas = mclient.getWorkingAreas();
    {
      Box hbox = new Box(BoxLayout.X_AXIS);
      Component comps[] = UIFactory.createTitledPanels();
      JPanel tpanel = (JPanel) comps[0];
      JPanel vpanel = (JPanel) comps[1];
      {
        userField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "User:"******"The user whose area the node is being created in.");
        userField.setActionCommand("user");
        userField.setSelected(PackageInfo.sUser);
        userField.addActionListener(this);
      }
      UIFactory.addVerticalSpacer(tpanel, vpanel, 3);
      {
        viewField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "View:",
                sTSize,
                vpanel,
                areas.get(PackageInfo.sUser),
                diag,
                sVSize,
                "The working area to create the nodes in.");
        viewField.setActionCommand("wrap");
        viewField.addActionListener(this);
      }
      UIFactory.addVerticalSpacer(tpanel, vpanel, 3);
      {
        toolsetField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "Toolset:",
                sTSize,
                vpanel,
                mclient.getActiveToolsetNames(),
                diag,
                sVSize,
                "The toolset to set on all the nodes.");
        toolsetField.setSelected(mclient.getDefaultToolsetName());
        toolsetField.setActionCommand("wrap");
        toolsetField.addActionListener(this);
      }
      UIFactory.addVerticalSpacer(tpanel, vpanel, 3);

      w =
          new Wrapper(
              userField.getSelected(),
              viewField.getSelected(),
              toolsetField.getSelected(),
              mclient);

      charList = SonyConstants.getAssetList(w, project, AssetType.CHARACTER);
      setsList = SonyConstants.getAssetList(w, project, AssetType.SET);
      propsList = SonyConstants.getAssetList(w, project, AssetType.PROP);

      {
        projectField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "Project:",
                sTSize,
                vpanel,
                Globals.getChildrenDirs(w, "/projects"),
                diag,
                sVSize,
                "All the projects in pipeline.");
        projectField.setActionCommand("proj");
        projectField.addActionListener(this);
      }
      hbox.add(comps[2]);
      top.add(hbox);
    }

    {
      Box vbox = new Box(BoxLayout.Y_AXIS);
      Box hbox = new Box(BoxLayout.X_AXIS);
      JButton button = new JButton("Propagate Additional Asset");
      button.setName("ValuePanelButton");
      button.setRolloverEnabled(false);
      button.setFocusable(false);
      Dimension d = new Dimension(sVSize, 25);
      button.setPreferredSize(d);
      button.setMinimumSize(d);
      button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));

      vbox.add(Box.createRigidArea(new Dimension(0, 5)));
      hbox.add(button);
      hbox.add(Box.createRigidArea(new Dimension(4, 0)));
      vbox.add(hbox);
      vbox.add(Box.createRigidArea(new Dimension(0, 5)));

      button.setActionCommand("add");
      button.addActionListener(this);

      top.add(vbox);
    }

    list = new Box(BoxLayout.Y_AXIS);
    test = new JDrawer("Propagate Additional Asset", list, false);

    top.add(test);
    list.add(assetChoiceBox());

    finalBox.add(top);

    {
      JPanel spanel = new JPanel();
      spanel.setName("Spacer");
      spanel.setMinimumSize(new Dimension(sTSize + sVSize, 7));
      spanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
      spanel.setPreferredSize(new Dimension(sTSize + sVSize, 7));
      finalBox.add(spanel);
    }

    diag.setVisible(true);
    if (diag.wasConfirmed()) {
      // get list of things to change.
      for (Component comp : list.getComponents()) {
        if (comp instanceof Box) {
          Box can = (Box) comp;
          JCollectionField oldOne = (JCollectionField) can.getComponent(2);
          JCollectionField newOne = (JCollectionField) can.getComponent(4);

          TreeMap<String, String> assetList = new TreeMap<String, String>();
          assetList.putAll(charList);
          assetList.putAll(propsList);
          assetList.putAll(setsList);

          String key = assetList.get(oldOne.getSelected()) + lr;
          String value = assetList.get(newOne.getSelected()) + lr;
          if (!key.equals(value)) {
            potentialUpdates.add(key);
            pAssetManager.put(key, new AssetInfo(key, value));
          }
          // System.err.println("bUG: "+pAssetManager.get(key).getHiLoResShots());
        }
      }

      if (!pAssetManager.isEmpty()) return true;
    }
    return false;
  } // end buildReplacementGUI
  public FavouritesView(Favourite favouritesModel) {
    super();

    // Set the favourites model, and register ourselves as an observer, so we can be notified
    // of any changes to the model.
    _favouritesModel = favouritesModel;
    _favouritesModel.addObserver(this);

    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    this.setBorder(BorderFactory.createTitledBorder("Favourites"));

    JPanel listPanel = new JPanel();
    listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.Y_AXIS));
    listPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));

    _favouritesList = new JList();
    _favouritesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _favouritesList.setLayoutOrientation(JList.VERTICAL);

    // Fetch initial favourited stations.
    updateList();

    _favouritesScroller = new JScrollPane(_favouritesList);
    _favouritesScroller.setHorizontalScrollBarPolicy(
        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    _favouritesScroller.setVerticalScrollBarPolicy(
        ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

    listPanel.add(_favouritesScroller);

    _remove = new JButton("Remove");
    _remove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // Remove the selected station from the user's favourites.
            Station station = (Station) _favouritesList.getSelectedValue();
            if (station != null) {
              _favouritesModel.removeStation(station);
            }
          }
        });

    _select = new JButton("Select");
    _select.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // Display the selected favourite.
            if (_favouritesList.getSelectedValue() != null)
              _favouritesModel.setCurrentStation((Station) _favouritesList.getSelectedValue());
          }
        });

    JPanel buttonPanel = new JPanel();
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    buttonPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 25));

    buttonPanel.add(_select);
    buttonPanel.add(_remove);

    this.add(listPanel);
    this.add(buttonPanel);
  }