Example #1
0
 public Container createSizeBox() {
   final JComboBox sizeBox = new JComboBox(size);
   sizeBox.setPreferredSize(sizeBox.getPreferredSize());
   sizeBox.setEditor(new FixedBasicComboBoxEditor());
   sizeBox.setEditable(true);
   return sizeBox;
 }
  private JPanel createCallComboPanel() {
    JPanel callComboPanel = new JPanel();

    callCombo = new JComboBox<Call>();
    Dimension dim = callCombo.getPreferredSize(); // adjusting comboBox size.
    callCombo.setPreferredSize(new Dimension(275, dim.height));

    populateCallCombo();
    callComboPanel.add(callCombo);

    addCallButton = new JButton("Add Call..");
    addCallButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {

            try {
              int callDuration =
                  Integer.parseInt(JOptionPane.showInputDialog("Input Call Duration :"));

              PhoneInfoController.getInstance()
                  .addCallForContact(
                      selectedContactName, callDuration, Calendar.getInstance().getTime());

            } catch (NumberFormatException ex) {
              JFrame outerFrame = new JFrame();
              JOptionPane.showConfirmDialog(outerFrame, "Please enter a Number");
            }
            dispose();
          }
        });

    callComboPanel.add(addCallButton);
    return callComboPanel;
  };
  private void createComponents(JPanel p) {
    String tt = "Any of these:  45.5 -120.2   or   45 30 0 n 120 12 0 w   or   Seattle";

    JComboBox field = new JComboBox();
    field.setOpaque(false);
    field.setEditable(true);
    field.setLightWeightPopupEnabled(false);
    field.setPreferredSize(new Dimension(200, field.getPreferredSize().height));
    field.setToolTipText(tt);

    JLabel label = new JLabel(ImageLibrary.getIcon("gov/nasa/worldwindow/images/safari-24x24.png"));
    //            new
    // ImageIcon(getClass().getResource("gov/nasa/worldwindow/images/safari-24x24.png")));
    label.setOpaque(false);
    label.setToolTipText(tt);

    p.add(label, BorderLayout.WEST);
    p.add(field, BorderLayout.CENTER);

    field.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            performGazeteerAction(actionEvent);
          }
        });
  }
Example #4
0
 public HeaderPanel(String heading) {
   super();
   this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
   this.setBackground(background);
   JLabel panelLabel = new JLabel(" " + heading, SwingConstants.LEFT);
   Font labelFont = new Font("Dialog", Font.BOLD, 18);
   panelLabel.setFont(labelFont);
   this.add(panelLabel);
   this.add(Box.createHorizontalGlue());
   refresh = new JButton("Refresh");
   refresh.addActionListener(this);
   this.add(refresh);
   this.add(Box.createHorizontalStrut(5));
   root = new JComboBox();
   Dimension d = root.getPreferredSize();
   d.width = 90;
   root.setPreferredSize(d);
   root.setMaximumSize(d);
   File[] roots = directoryPane.getRoots();
   for (int i = 0; i < roots.length; i++) root.addItem(roots[i].getAbsolutePath());
   this.add(root);
   root.setSelectedIndex(directoryPane.getCurrentRootIndex());
   root.addActionListener(this);
   this.add(Box.createHorizontalStrut(17));
 }
Example #5
0
 @Override
 public int getBaseline() {
   FontMetrics fm = b.getFontMetrics(b.getFont());
   int border = (b.getPreferredSize().height - fm.getHeight()) / 2;
   int bestGuess = border + fm.getAscent();
   if (PlatformUtils.isMac()) bestGuess -= 1;
   return bestGuess;
 }
Example #6
0
  protected void addCommonToolbarActions(final SwingEngine swingEngine, JToolBar tb) {
    // copy, paste and undo buttons
    tb.addSeparator();
    addToToolbar(actions.copyAction);
    addToToolbar(actions.pasteAction);
    tb.addSeparator();
    addToToolbar(actions.undoAction);
    tb.addSeparator();

    // zoom drop-down
    addToToolbar(new JLabel("Zoom:", JLabel.LEFT));
    zoomCombo = new JComboBox(actions.zoomActions);
    zoomCombo.setMaximumSize(zoomCombo.getPreferredSize());
    zoomCombo.setEditable(true);
    zoomCombo.setSelectedIndex(5); // 100%
    zoomCombo.addActionListener(new ZoomComboListener());
    addToToolbar(zoomCombo, TB_GROUP_SHOW_IF_VPATHWAY);
    tb.addSeparator();

    // define the drop-down menu for data nodes
    GraphicsChoiceButton datanodeButton = new GraphicsChoiceButton();
    datanodeButton.setToolTipText("Select a data node to draw");
    datanodeButton.addButtons("Data Nodes", actions.newDatanodeActions);
    //		datanodeButton.addButtons("Annotations", actions.newAnnotationActions);
    addToToolbar(datanodeButton, TB_GROUP_SHOW_IF_EDITMODE);
    tb.addSeparator(new Dimension(2, 0));

    // define the drop-down menu for shapes
    GraphicsChoiceButton shapeButton = new GraphicsChoiceButton();
    shapeButton.setToolTipText("Select a shape to draw");
    itemsDropDown = shapeButton;
    shapeButton.addButtons("Basic shapes", actions.newShapeActions);
    shapeButton.addButtons("Cellular components", actions.newCellularComponentActions);
    addToToolbar(shapeButton, TB_GROUP_SHOW_IF_EDITMODE);
    tb.addSeparator(new Dimension(2, 0));

    // define the drop-down menu for interactions
    GraphicsChoiceButton lineButton = new GraphicsChoiceButton();
    lineButton.setToolTipText("Select an interaction to draw");
    lineButton.addButtons("Basic interactions", actions.newInteractionActions);
    lineButton.addButtons("MIM interactions", actions.newMIMInteractionActions);
    addToToolbar(lineButton, TB_GROUP_SHOW_IF_EDITMODE);
    tb.addSeparator(new Dimension(2, 0));

    // define the drop-down menu for templates
    GraphicsChoiceButton templateButton = new GraphicsChoiceButton();
    templateButton.setToolTipText("Select a template to draw");
    templateButton.addButtons("Templates", actions.newTemplateActions);
    addToToolbar(templateButton, TB_GROUP_SHOW_IF_EDITMODE);
    tb.addSeparator();

    // layout actions
    addToToolbar(actions.layoutActions);
  }
Example #7
0
 /**
  * Constructor for the LiveSearchBox. First create a pointer to the controller. Then create a
  * JComboBox, set the preferred size, set the setEditable to true, and set the background. The
  * component is retrieved from adress and sets a size. Finally a listener is added to component.
  */
 public LiveSearchBox() {
   controller = Controller.getInstance();
   adress = new JComboBox();
   Dimension d = adress.getPreferredSize();
   adress.setPreferredSize(new Dimension(170, (int) d.getHeight()));
   adress.setEditable(true);
   adress.setBackground(Color.lightGray);
   component = (JTextField) adress.getEditor().getEditorComponent();
   component.setSize(50, 10);
   doc = component.getDocument();
   listener = createListener();
   doc.addDocumentListener(listener);
 }
 {
   String encoding = RapidMiner.SYSTEM_ENCODING_NAME;
   String encodingProperty =
       ParameterService.getParameterValue(RapidMiner.PROPERTY_RAPIDMINER_GENERAL_DEFAULT_ENCODING);
   if (encodingProperty != null) {
     encoding = encodingProperty;
   }
   encodingComboBox.setSelectedItem(encoding);
   encodingComboBox.setPreferredSize(new Dimension(encodingComboBox.getPreferredSize().width, 25));
   encodingComboBox.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           settingsChanged();
         }
       });
 }
Example #9
0
  /**
   * adds comboBox to fxz composer toolbar
   *
   * @param toolbar Toolbar to add comboBox at
   * @param comboBox comboBox to add
   * @param index the position in the container's list at which to insert the component; <code>-1
   *     </code> means insert at the end component
   * @param isEditable is comboBox editable
   */
  public static void addCombo(JToolBar toolbar, JComboBox comboBox, int index, boolean isEditable) {
    GridBagConstraints constrains = new GridBagConstraints();
    constrains.anchor = GridBagConstraints.WEST;
    constrains.insets = new Insets(0, 3, 0, 2);

    // @inherited fix of issue #69642. Focus shouldn't stay in toolbar
    comboBox.setFocusable(false);

    Dimension size = comboBox.getPreferredSize();
    comboBox.setPreferredSize(size);
    comboBox.setSize(size);
    comboBox.setMinimumSize(size);
    comboBox.setMaximumSize(size);

    comboBox.setEditable(isEditable);

    toolbar.add(comboBox, constrains, index);
  }
  /**
   * Overridden to create a new title year component.
   *
   * @return
   */
  protected JComponent createTitleYear() {
    yearTitleComboBox = new JComboBox();
    yearTitleComboBox.setEditable(true);
    yearTitleComboBox.setPreferredSize(
        new Dimension(50, yearTitleComboBox.getPreferredSize().height));
    yearTitleComboBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Integer value = (Integer) yearTitleComboBox.getSelectedItem();
            month.setYear(value.intValue());
          }
        });

    yearTitleComboBox.setModel(new YearComboBoxModel(10));
    yearTitleComboBox.setMaximumRowCount(10);
    yearTitleComboBox.setSelectedItem(new Integer(month.getYear()));
    ((JTextField) yearTitleComboBox.getEditor().getEditorComponent()).setColumns(5);

    return yearTitleComboBox;
  }
  private JPanel createLeftPanel() {
    JPanel left = new JPanel();
    left.setLayout(new BoxLayout(left, BoxLayout.X_AXIS));

    imagesCombo = new JComboBox();
    imagesCombo.addItem("Thresholded");
    imagesCombo.addItem("Filtered");
    imagesCombo.addActionListener(this);
    imagesCombo.setSelectedIndex(1);
    imagesCombo.setMaximumSize(imagesCombo.getPreferredSize());

    selectThresh = new SelectHistogramThresholdPanel(20, true);
    selectThresh.setListener(this);

    left.add(imagesCombo);
    left.add(selectThresh);
    left.add(Box.createHorizontalGlue());

    return left;
  }
  public AnnotationSidePanel(final Browser br, final Fab4 f) {
    super(new BorderLayout(5, 3));
    bro = br;
    fab = f;
    final PersonalAnnos bu = (PersonalAnnos) Fab4utils.getBe("Personal", br.getRoot().getLayers());
    // JPanel icos = new JPanel(new FlowLayout(FlowLayout.CENTER,3,2));
    setBorder(new LineBorder(AnnotationSidePanel.publicColor, 2));
    JPanel topp = new JPanel(new BorderLayout(4, 1));
    annotationPaneLabel = new JComboBox(new String[] {"Public notes", "Private notes"});
    annotationPaneLabel.setToolTipText("Choose if public or private");
    annotationPaneLabel.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) loadRemoteCombo();
          }
        });
    annotationPaneLabel.setFont(annotationPaneLabel.getFont().deriveFont(Font.BOLD));

    topp.add(BorderLayout.NORTH, annotationPaneLabel);
    JPanel south = new JPanel(new FlowLayout(FlowLayout.CENTER, 1, 1));
    final JTextField tt = new JTextField("type search");
    tt.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(java.awt.event.MouseEvent e) {
            if (e.getButton() == java.awt.event.MouseEvent.BUTTON1) tt.selectAll();
          }
        });
    tt.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent arg0) {
            if (arg0.getKeyChar() == '\n') {
              String txt = ((JTextField) arg0.getSource()).getText();
              search(txt);
            }
          }
        });
    JButton lb = new JButton(FabIcons.getIcons().ICOLIGHT);
    lb.setToolTipText("Search in the annotations");
    lb.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            search(tt.getText());
          }
        });
    south.add(tt);
    south.add(lb);

    // TODO: do a better search, separate window
    JComboBox cb = new JComboBox(new String[] {"Date", "Author", "Trust", "Position"});
    cb.setToolTipText("Sort notes by:");
    cb.setEditable(false);
    JPanel t = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 1));
    t.add(new JLabel("sort"));
    t.add(cb);
    topp.add(BorderLayout.SOUTH, t);

    // int wi = bHideAnno.getPreferredSize().width*3+20;
    // wi = Math.max(wi,annotationPaneLabel.getPreferredSize().width);
    int hei =
        annotationPaneLabel.getPreferredSize().height + /*
		 * bHideAnno.getPreferredSize
		 * ().height
		 */ +10 + tt.getPreferredSize().height;
    Dimension dim = new Dimension(annotationPaneLabel.getPreferredSize().width, hei);
    topp.setPreferredSize(dim);
    topp.setMinimumSize(dim);
    topp.setMaximumSize(dim);

    annoUserList = new JList();
    annoUserList.setAutoscrolls(true);
    annoUserList.setBackground(new Color(255, 255, 230));
    annoUserList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    bdeleAnno = new JButton("Delete", FabIcons.getIcons().ICODEL);
    bdeleAnno.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            for (int i : annoUserList.getSelectedIndices())
              br.eventq(PersonalAnnos.MSG_DELETE, bu.user.get(i));
          }
        });
    bdeleAnno.setToolTipText("Delete selected notes");
    if (bu != null) {
      annoUserList.setModel(bu.user);
      Component[] t1 = new Component[1];
      t1[0] = bdeleAnno;
      bu.addUIElementsToFab4List(annoUserList, t1, cb);
    }
    bdeleAnno.setEnabled(false);
    add(topp, BorderLayout.NORTH);
    JScrollPane scrollPane = new JScrollPane(annoUserList);
    add(scrollPane, BorderLayout.CENTER);
    annoUserList.addListSelectionListener(
        new ListSelectionListener() {

          public void valueChanged(ListSelectionEvent e) {
            Object[] index = annoUserList.getSelectedValues();
            if (index.length > 0) bCopy.setEnabled(true);
            else bCopy.setEnabled(false);
            nsel.setText("" + index.length);
          }
        });

    JPanel ppp = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 1));
    bCopy = new JButton("Copy  ", FabIcons.getIcons().ICOPUB);
    Font nf = bCopy.getFont();
    nf.deriveFont((float) (nf.getSize2D() * 0.8));
    bCopy.setFont(nf);
    bCopy.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            br.eventq(PersonalAnnos.MSG_COPY, "");
          }
        });
    bCopy.setToolTipText("Copies the selected notes to the server or local database");
    ppp.add(bCopy);
    bCopy.setEnabled(false);

    bdeleAnno.setFont(nf);

    ppp.add(bdeleAnno);
    ppp.setPreferredSize(
        new Dimension(ppp.getPreferredSize().width, bdeleAnno.getPreferredSize().height * 2 + 3));

    nsel = new JLabel(" ");
    nsel.setFont(nf);
    ppp.add(nsel);
    add(ppp, BorderLayout.SOUTH);
  }
Example #13
0
  public LingDisplay(final Ling.StoredGraphs storedGraphs) {
    this.storedGraphs = storedGraphs;

    if (storedGraphs.getNumGraphs() == 0) {
      workbench = new GraphWorkbench();
    } else {
      workbench = new GraphWorkbench(storedGraphs.getGraph(0));
    }

    subsetIndices = getStableIndices(storedGraphs);

    final SpinnerNumberModel model =
        new SpinnerNumberModel(subsetIndices.size() == 0 ? 0 : 1, 0, subsetIndices.size(), 1);
    model.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            int index = model.getNumber().intValue();
            workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1)));
          }
        });

    spinner = new JSpinner();
    subsetCombo = new JComboBox(new String[] {"Show Stable", "Show Unstable", "Show All"});
    subsetCombo.setSelectedItem("Show Stable");
    spinner.setModel(model);
    totalLabel = new JLabel(" of " + subsetIndices.size());

    subsetCombo.setMaximumSize(subsetCombo.getPreferredSize());
    subsetCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            resetDisplay();
          }
        });

    spinner.setPreferredSize(new Dimension(50, 20));
    spinner.setMaximumSize(spinner.getPreferredSize());
    Box b = Box.createVerticalBox();
    Box b1 = Box.createHorizontalBox();
    //        b1.add(Box.createHorizontalGlue());
    //        b1.add(Box.createHorizontalStrut(10));
    b1.add(subsetCombo);
    b1.add(Box.createHorizontalGlue());
    b1.add(new JLabel("DAG "));
    b1.add(spinner);
    b1.add(totalLabel);

    b.add(b1);

    Box b2 = Box.createHorizontalBox();
    JPanel graphPanel = new JPanel();
    graphPanel.setLayout(new BorderLayout());
    JScrollPane jScrollPane = new JScrollPane(workbench);
    //        jScrollPane.setPreferredSize(new Dimension(400, 400));
    graphPanel.add(jScrollPane);
    //        graphPanel.setBorder(new TitledBorder("DAG"));
    b2.add(graphPanel);
    b.add(b2);

    setLayout(new BorderLayout());
    //        add(menuBar(), BorderLayout.NORTH);
    add(b, BorderLayout.CENTER);
  }
Example #14
0
  /**
   * Make the UI for this widget.
   *
   * @param floatToolBar true if the toolbar should be floatable
   * @return UI as a Component
   */
  private JComponent doMakeContents(boolean floatToolBar) {

    String imgp = "/auxdata/ui/icons/";
    KeyListener listener =
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if ((e.getSource() instanceof JComboBox)) {
              return;
            }
            int code = e.getKeyCode();
            char c = e.getKeyChar();
            if ((code == KeyEvent.VK_RIGHT) || (code == KeyEvent.VK_KP_RIGHT)) {
              if (e.isShiftDown()) {
                gotoIndex(anime.getNumSteps() - 1);
              } else {
                actionPerformed(CMD_FORWARD);
              }
            } else if ((code == KeyEvent.VK_LEFT) || (code == KeyEvent.VK_KP_LEFT)) {
              if (e.isShiftDown()) {
                gotoIndex(0);
              } else {
                actionPerformed(CMD_BACKWARD);
              }
            } else if (code == KeyEvent.VK_ENTER) {
              actionPerformed(CMD_STARTSTOP);
            } else if ((code == KeyEvent.VK_P) && e.isControlDown()) {
              actionPerformed(CMD_PROPS);
            } else if (Character.isDigit(c)) {
              int step = new Integer("" + c).intValue() - 1;
              if (step < 0) {
                step = 0;
              }
              if (step >= anime.getNumSteps()) {
                step = anime.getNumSteps() - 1;
              }
              gotoIndex(step);
            }
          }
        };

    List buttonList = new ArrayList();
    buttonList.add(timesCbx);
    // Update the list of times
    setTimesInTimesBox();

    Dimension preferredSize = timesCbx.getPreferredSize();
    if (preferredSize != null) {
      int height = preferredSize.height;
      if (height < 50) {
        JComponent filler = GuiUtils.filler(3, height);
        buttonList.add(filler);
      }
    }

    String[][] buttonInfo = {
      {"Go to first frame", CMD_BEGINNING, getIcon("Rewind")},
      {"One frame back", CMD_BACKWARD, getIcon("StepBack")},
      {"Run/Stop", CMD_STARTSTOP, getIcon("Play")},
      {"One frame forward", CMD_FORWARD, getIcon("StepForward")},
      {"Go to last frame", CMD_END, getIcon("FastForward")},
      {"Properties", CMD_PROPS, getIcon("Information")}
    };

    for (int i = 0; i < buttonInfo.length; i++) {
      JButton btn = GuiUtils.getScaledImageButton(buttonInfo[i][2], getClass(), 2, 2);
      btn.setToolTipText(buttonInfo[i][0]);
      btn.setActionCommand(buttonInfo[i][1]);
      btn.addActionListener(this);
      btn.addKeyListener(listener);
      //            JComponent wrapper = GuiUtils.center(btn);
      //            wrapper.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
      btn.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
      buttonList.add(btn);
      //            buttonList.add(wrapper);
      if (i == 2) {
        startStopBtn = btn;
      }
    }

    JComponent contents = GuiUtils.hflow(buttonList, 1, 0);
    if (boxPanel == null) {
      boxPanel = new AnimationBoxPanel(this);
      if (timesArray != null) {
        updateBoxPanel(timesArray);
      }
    }
    boxPanel.addKeyListener(listener);
    if (!getBoxPanelVisible()) {
      boxPanel.setVisible(false);
    }
    contents =
        GuiUtils.doLayout(new Component[] {boxPanel, contents}, 1, GuiUtils.WT_Y, GuiUtils.WT_N);
    //      GuiUtils.addKeyListenerRecurse(listener,contents);
    if (floatToolBar) {
      JToolBar toolbar = new JToolBar(JToolBar.HORIZONTAL);
      toolbar.setFloatable(true);
      contents = GuiUtils.left(contents);
      toolbar.add(contents);
      contents = toolbar;
    }

    updateRunButton();
    madeContents = true;
    return contents;
  }
  public DetectPolygonControlPanel(DetectBlackPolygonApp owner) {
    this.owner = owner;

    imageView = new JComboBox();
    imageView.addItem("Input");
    imageView.addItem("Binary");
    imageView.addItem("Black");
    imageView.addActionListener(this);
    imageView.setMaximumSize(imageView.getPreferredSize());

    selectZoom = new JSpinner(new SpinnerNumberModel(1, 0.1, 50, 1));
    selectZoom.addChangeListener(this);
    selectZoom.setMaximumSize(selectZoom.getPreferredSize());

    showCorners = new JCheckBox("Corners");
    showCorners.addActionListener(this);
    showCorners.setSelected(bShowCorners);
    showLines = new JCheckBox("Lines");
    showLines.setSelected(bShowLines);
    showLines.addActionListener(this);
    showContour = new JCheckBox("Contour");
    showContour.addActionListener(this);
    showContour.setSelected(bShowContour);

    threshold = new ThresholdControlPanel(owner);

    refineChoice = new JComboBox();
    for (PolygonRefineType n : PolygonRefineType.values()) {
      refineChoice.addItem(n.name());
    }
    refineChoice.setSelectedIndex(refineType.ordinal());
    refineChoice.addActionListener(this);
    refineChoice.setMaximumSize(refineChoice.getPreferredSize());

    spinnerMinContourSize =
        new JSpinner(new SpinnerNumberModel(config.minContourImageWidthFraction, 0.0, 0.2, 0.01));
    configureSpinnerFloat(spinnerMinContourSize);
    spinnerMinSides = new JSpinner(new SpinnerNumberModel(minSides, 3, 20, 1));
    spinnerMinSides.setMaximumSize(spinnerMinSides.getPreferredSize());
    spinnerMinSides.addChangeListener(this);
    spinnerMaxSides = new JSpinner(new SpinnerNumberModel(maxSides, 3, 20, 1));
    spinnerMaxSides.setMaximumSize(spinnerMaxSides.getPreferredSize());
    spinnerMaxSides.addChangeListener(this);

    spinnerMinEdge =
        new JSpinner(new SpinnerNumberModel(config.minimumEdgeIntensity, 0.0, 255.0, 1.0));
    spinnerMinEdge.setMaximumSize(spinnerMinEdge.getPreferredSize());
    spinnerMinEdge.addChangeListener(this);
    spinnerContourSplit =
        new JSpinner(new SpinnerNumberModel(config.contour2Poly_splitFraction, 0.0, 1.0, 0.01));
    configureSpinnerFloat(spinnerContourSplit);
    spinnerContourMinSplit =
        new JSpinner(
            new SpinnerNumberModel(config.contour2Poly_minimumSideFraction, 0.0, 1.0, 0.001));
    configureSpinnerFloat(spinnerContourMinSplit);
    spinnerContourSplit.addChangeListener(this);
    spinnerContourIterations =
        new JSpinner(new SpinnerNumberModel(config.contour2Poly_iterations, 1, 200, 1));
    spinnerContourIterations.setMaximumSize(spinnerContourIterations.getPreferredSize());
    spinnerContourIterations.addChangeListener(this);
    spinnerSplitPenalty =
        new JSpinner(new SpinnerNumberModel(config.splitPenalty, 0.0, 100.0, 1.0));
    configureSpinnerFloat(spinnerSplitPenalty);

    setConvex = new JCheckBox("Convex");
    setConvex.addActionListener(this);
    setConvex.setSelected(config.convex);
    setBorder = new JCheckBox("Image Border");
    setBorder.addActionListener(this);
    setBorder.setSelected(config.canTouchBorder);

    spinnerLineSamples = new JSpinner(new SpinnerNumberModel(configLine.lineSamples, 5, 100, 1));
    spinnerLineSamples.setMaximumSize(spinnerLineSamples.getPreferredSize());
    spinnerLineSamples.addChangeListener(this);
    spinnerCornerOffset = new JSpinner(new SpinnerNumberModel(configLine.cornerOffset, 0, 10, 1));
    spinnerCornerOffset.setMaximumSize(spinnerCornerOffset.getPreferredSize());
    spinnerCornerOffset.addChangeListener(this);
    spinnerSampleRadius = new JSpinner(new SpinnerNumberModel(configLine.sampleRadius, 0, 10, 1));
    spinnerSampleRadius.setMaximumSize(spinnerCornerOffset.getPreferredSize());
    spinnerSampleRadius.addChangeListener(this);
    spinnerRefineMaxIterations =
        new JSpinner(new SpinnerNumberModel(configLine.maxIterations, 0, 200, 1));
    spinnerRefineMaxIterations.setMaximumSize(spinnerRefineMaxIterations.getPreferredSize());
    spinnerRefineMaxIterations.addChangeListener(this);
    spinnerConvergeTol =
        new JSpinner(new SpinnerNumberModel(configLine.convergeTolPixels, 0.0, 2.0, 0.005));
    configureSpinnerFloat(spinnerConvergeTol);
    spinnerMaxCornerChange =
        new JSpinner(new SpinnerNumberModel(configLine.maxCornerChangePixel, 0.0, 50.0, 1.0));
    configureSpinnerFloat(spinnerMaxCornerChange);

    addLabeled(imageView, "View: ", this);
    addLabeled(selectZoom, "Zoom", this);
    addAlignLeft(showCorners, this);
    addAlignLeft(showLines, this);
    addAlignLeft(showContour, this);
    add(threshold);
    addLabeled(spinnerMinContourSize, "Min Contour Size: ", this);
    addLabeled(spinnerMinSides, "Minimum Sides: ", this);
    addLabeled(spinnerMaxSides, "Maximum Sides: ", this);
    addLabeled(spinnerMinEdge, "Edge Intensity: ", this);
    addAlignLeft(setConvex, this);
    addAlignLeft(setBorder, this);
    addCenterLabel("Contour", this);
    addLabeled(spinnerContourSplit, "Split Fraction: ", this);
    addLabeled(spinnerContourMinSplit, "Min Split: ", this);
    addLabeled(spinnerContourIterations, "Max Iterations: ", this);
    addLabeled(spinnerSplitPenalty, "Split Penalty: ", this);
    addCenterLabel("Refinement", this);
    addLabeled(refineChoice, "Refine: ", this);
    addLabeled(spinnerLineSamples, "Line Samples: ", this);
    addLabeled(spinnerCornerOffset, "Corner Offset: ", this);
    addLabeled(spinnerSampleRadius, "Sample Radius: ", this);
    addLabeled(spinnerRefineMaxIterations, "Iterations: ", this);
    addLabeled(spinnerConvergeTol, "Converge Tol Pixels: ", this);
    addLabeled(spinnerMaxCornerChange, "Max Corner Change: ", this);
    addVerticalGlue(this);
  }
Example #16
0
    /** Creates the ui of this panel, laying out all the ui elements. */
    private void createUI() {
      I18n i18n = getI18n();

      final int labelPad = 4; // To align labels with checkboxes

      // Time controls
      JLabel timeLabel = i18n.createLabel("timeLabel");
      timeLabel.setLabelFor(timeField);

      JLabel incLabel = i18n.createLabel("incrementLabel");
      incLabel.setLabelFor(incField);

      JLabel secondsLabel = i18n.createLabel("secondsLabel");
      JLabel minutesLabel = i18n.createLabel("minutesLabel");

      timeField.setMaximumSize(timeField.getPreferredSize());
      incField.setMaximumSize(incField.getPreferredSize());

      JComponent timeContainer = new JPanel(new TableLayout(5, labelPad, 2));
      timeContainer.add(Box.createHorizontalStrut(0));
      timeContainer.add(timeLabel);
      timeContainer.add(Box.createHorizontalStrut(10));
      timeContainer.add(timeField);
      timeContainer.add(minutesLabel);
      timeContainer.add(Box.createHorizontalStrut(0));
      timeContainer.add(incLabel);
      timeContainer.add(Box.createHorizontalStrut(10));
      timeContainer.add(incField);
      timeContainer.add(secondsLabel);

      // Variant
      JLabel variantLabel = i18n.createLabel("variantLabel");
      variantLabel.setLabelFor(variantChoice);
      variantChoice.setMaximumSize(variantChoice.getPreferredSize());

      JComponent variantContainer = SwingUtils.createHorizontalBox();
      variantContainer.add(Box.createHorizontalStrut(labelPad));
      variantContainer.add(variantLabel);
      variantContainer.add(Box.createHorizontalStrut(10));
      variantContainer.add(variantChoice);
      variantContainer.add(Box.createHorizontalGlue());

      // Color
      JLabel colorLabel = i18n.createLabel("colorLabel");

      JComponent colorContainer = SwingUtils.createHorizontalBox();
      colorContainer.add(Box.createHorizontalStrut(labelPad));
      colorContainer.add(colorLabel);
      colorContainer.add(Box.createHorizontalStrut(15));
      colorContainer.add(autoColor);
      colorContainer.add(Box.createHorizontalStrut(10));
      colorContainer.add(whiteColor);
      colorContainer.add(Box.createHorizontalStrut(10));
      colorContainer.add(blackColor);
      colorContainer.add(Box.createHorizontalGlue());

      // Limit opponent rating
      JLabel minLabel = i18n.createLabel("minRatingLabel");
      minLabel.setLabelFor(minRatingField);
      JLabel maxLabel = i18n.createLabel("maxRatingLabel");
      maxLabel.setLabelFor(maxRatingField);
      minRatingField.setMaximumSize(minRatingField.getPreferredSize());
      maxRatingField.setMaximumSize(minRatingField.getPreferredSize());

      JComponent limitRatingBoxContainer = SwingUtils.createHorizontalBox();
      limitRatingBoxContainer.add(limitRatingBox);
      limitRatingBoxContainer.add(Box.createHorizontalGlue());

      final JComponent minMaxContainer = SwingUtils.createHorizontalBox();
      minMaxContainer.add(Box.createHorizontalStrut(40));
      minMaxContainer.add(minLabel);
      minMaxContainer.add(Box.createHorizontalStrut(10));
      minMaxContainer.add(minRatingField);
      minMaxContainer.add(Box.createHorizontalStrut(20));
      minMaxContainer.add(maxLabel);
      minMaxContainer.add(Box.createHorizontalStrut(10));
      minMaxContainer.add(maxRatingField);
      minMaxContainer.add(Box.createHorizontalGlue());

      JComponent limitRatingContainer = SwingUtils.createVerticalBox();
      limitRatingContainer.add(limitRatingBoxContainer);
      limitRatingContainer.add(Box.createVerticalStrut(3));
      limitRatingContainer.add(minMaxContainer);

      // Buttons panel
      JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
      JButton issueSeekButton = i18n.createButton("issueSeekButton");
      JButton cancelButton = i18n.createButton("cancelButton");

      setDefaultButton(issueSeekButton);
      cancelButton.setDefaultCapable(false);

      buttonsPanel.add(issueSeekButton);
      buttonsPanel.add(cancelButton);

      JButton moreLessButton = i18n.createButton("moreOptionsButton");
      moreLessButton.setDefaultCapable(false);
      moreLessButton.setActionCommand("more");
      JPanel moreLessPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
      moreLessPanel.add(moreLessButton);

      final JComponent advancedPanelHolder = new JPanel(new BorderLayout());

      // Layout the subcontainers in the main container
      setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
      timeContainer.setAlignmentX(LEFT_ALIGNMENT);
      add(timeContainer);
      add(Box.createVerticalStrut(2));
      isRatedBox.setAlignmentX(LEFT_ALIGNMENT);
      add(isRatedBox);
      advancedPanelHolder.setAlignmentX(LEFT_ALIGNMENT);
      add(advancedPanelHolder);
      add(Box.createVerticalStrut(5));
      moreLessPanel.setAlignmentX(LEFT_ALIGNMENT);
      add(moreLessPanel);

      add(Box.createVerticalStrut(10));
      buttonsPanel.setAlignmentX(LEFT_ALIGNMENT);
      add(buttonsPanel);

      // Advanced options panel
      final JComponent advancedPanel = SwingUtils.createVerticalBox();
      advancedPanel.add(Box.createVerticalStrut(4));
      variantContainer.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(variantContainer);
      advancedPanel.add(Box.createVerticalStrut(4));
      colorContainer.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(colorContainer);
      advancedPanel.add(Box.createVerticalStrut(2));
      limitRatingContainer.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(limitRatingContainer);
      advancedPanel.add(Box.createVerticalStrut(2));
      manualAcceptBox.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(manualAcceptBox);
      advancedPanel.add(Box.createVerticalStrut(2));
      useFormulaBox.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(useFormulaBox);

      AWTUtilities.setContainerEnabled(minMaxContainer, limitRatingBox.isSelected());
      limitRatingBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent evt) {
              AWTUtilities.setContainerEnabled(minMaxContainer, limitRatingBox.isSelected());
            }
          });

      moreLessButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              if (evt.getActionCommand().equals("more")) {
                JButton moreLessButton = (JButton) evt.getSource();
                moreLessButton.setText(getI18n().getString("lessOptionsButton.text"));
                moreLessButton.setActionCommand("less");
                advancedPanelHolder.add(advancedPanel, BorderLayout.CENTER);
                SeekPanel.this.resizeContainerToFit();
              } else {
                JButton moreLessButton = (JButton) evt.getSource();
                moreLessButton.setText(getI18n().getString("moreOptionsButton.text"));
                moreLessButton.setActionCommand("more");
                advancedPanelHolder.remove(advancedPanel);
                SeekPanel.this.resizeContainerToFit();
              }
            }
          });

      cancelButton.addActionListener(new ClosingListener(null));
      issueSeekButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              int time, inc;

              try {
                time = Integer.parseInt(timeField.getText());
              } catch (NumberFormatException e) {
                getI18n().error("timeError");
                return;
              }

              try {
                inc = Integer.parseInt(incField.getText());
              } catch (NumberFormatException e) {
                getI18n().error("incError");
                return;
              }

              boolean isRated = isRatedBox.isSelected();

              WildVariant variant = (WildVariant) variantChoice.getSelectedItem();

              Player color =
                  autoColor.isSelected()
                      ? null
                      : whiteColor.isSelected() ? Player.WHITE_PLAYER : Player.BLACK_PLAYER;

              int minRating, maxRating;
              if (limitRatingBox.isSelected()) {
                try {
                  minRating = Integer.parseInt(minRatingField.getText());
                } catch (NumberFormatException e) {
                  getI18n().error("minRatingError");
                  return;
                }
                try {
                  maxRating = Integer.parseInt(maxRatingField.getText());
                } catch (NumberFormatException e) {
                  getI18n().error("maxRatingError");
                  return;
                }
              } else {
                minRating = Integer.MIN_VALUE;
                maxRating = Integer.MAX_VALUE;
              }

              boolean manualAccept = manualAcceptBox.isSelected();
              boolean useFormula = useFormulaBox.isSelected();

              close(
                  new UserSeek(
                      time,
                      inc,
                      isRated,
                      variant,
                      color,
                      minRating,
                      maxRating,
                      manualAccept,
                      useFormula));
            }
          });
    }
 @Override
 public Dimension getPreferredSize() {
   return myThemedCombo.getPreferredSize();
 }
Example #18
0
  private void createGUI() {
    setTitle(textField ? app.getPlain("TextField") : app.getPlain("Button"));
    setResizable(false);

    // create caption panel
    JLabel captionLabel = new JLabel(app.getMenu("Button.Caption") + ":");
    String initString = button == null ? "" : button.getCaption();
    InputPanel ip = new InputPanel(initString, app, 1, 15, true);
    tfCaption = ip.getTextComponent();
    if (tfCaption instanceof AutoCompleteTextField) {
      AutoCompleteTextField atf = (AutoCompleteTextField) tfCaption;
      atf.setAutoComplete(false);
    }

    captionLabel.setLabelFor(tfCaption);
    JPanel captionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    captionPanel.add(captionLabel);
    captionPanel.add(ip);

    // combo box to link GeoElement to TextField
    comboModel = new DefaultComboBoxModel();
    TreeSet sortedSet = app.getKernel().getConstruction().getGeoSetNameDescriptionOrder();

    final JComboBox cbAdd = new JComboBox(comboModel);

    if (textField) {
      // lists for combo boxes to select input and output objects
      // fill combobox models
      Iterator it = sortedSet.iterator();
      comboModel.addElement(null);
      FontMetrics fm = getFontMetrics(getFont());
      int width = (int) cbAdd.getPreferredSize().getWidth();
      while (it.hasNext()) {
        GeoElement geo = (GeoElement) it.next();
        if (!geo.isGeoImage() && !(geo.isGeoButton()) && !(geo.isGeoBoolean())) {
          comboModel.addElement(geo);
          String str = geo.toString();
          if (width < fm.stringWidth(str)) width = fm.stringWidth(str);
        }
      }

      // make sure it's not too wide (eg long GeoList)
      Dimension size =
          new Dimension(
              Math.min(app.getScreenSize().width / 2, width), cbAdd.getPreferredSize().height);
      cbAdd.setMaximumSize(size);
      cbAdd.setPreferredSize(size);

      if (comboModel.getSize() > 1) {

        // listener for the combobox
        MyComboBoxListener ac =
            new MyComboBoxListener() {
              public void doActionPerformed(Object source) {
                GeoElement geo = (GeoElement) cbAdd.getSelectedItem();
                // if (geo == null)
                // {
                //
                //	return;
                // }

                linkedGeo = geo;
                // ((GeoTextField)button).setLinkedGeo(geo);

                cbAdd.removeActionListener(this);

                // cbAdd.setSelectedItem(null);
                cbAdd.addActionListener(this);
              }
            };
        cbAdd.addActionListener(ac);
        cbAdd.addMouseListener(ac);

        captionPanel.add(cbAdd);
      }
    }

    // create script panel
    JLabel scriptLabel = new JLabel(app.getPlain("Script") + ":");
    initString = (button == null) ? "" : button.getClickScript();
    InputPanel ip2 = new InputPanel(initString, app, 10, 40, false);
    tfScript = ip2.getTextComponent();
    if (tfScript instanceof AutoCompleteTextField) {
      AutoCompleteTextField atf = (AutoCompleteTextField) tfScript;
      atf.setAutoComplete(false);
    }

    scriptLabel.setLabelFor(tfScript);
    JPanel scriptPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    scriptPanel.add(scriptLabel);
    scriptPanel.add(ip2);

    JPanel linkedPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JLabel linkedLabel = new JLabel(app.getPlain("LinkedObject") + ":");
    linkedPanel.add(linkedLabel);
    linkedPanel.add(cbAdd);

    // buttons
    btApply = new JButton(app.getPlain("Apply"));
    btApply.setActionCommand("Apply");
    btApply.addActionListener(this);
    btCancel = new JButton(app.getPlain("Cancel"));
    btCancel.setActionCommand("Cancel");
    btCancel.addActionListener(this);
    btPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    btPanel.add(btApply);
    btPanel.add(btCancel);

    // Create the JOptionPane.
    optionPane = new JPanel(new BorderLayout(5, 5));

    // create object list
    optionPane.add(captionPanel, BorderLayout.NORTH);
    if (textField) optionPane.add(linkedPanel, BorderLayout.CENTER);
    else optionPane.add(scriptPanel, BorderLayout.CENTER);
    optionPane.add(btPanel, BorderLayout.SOUTH);
    optionPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    // Make this dialog display it.
    setContentPane(optionPane);

    /*

    inputPanel = new InputPanel("ggbApplet.evalCommand('A=(3,4)');", app, 10, 50, false, true, false );
    inputPanel2 = new InputPanel("function func() {\n}", app, 10, 50, false, true, false );

    JPanel centerPanel = new JPanel(new BorderLayout());

    centerPanel.add(inputPanel, BorderLayout.CENTER);
    centerPanel.add(inputPanel2, BorderLayout.SOUTH);
    getContentPane().add(centerPanel, BorderLayout.CENTER);
    //centerOnScreen();

    setContentPane(centerPanel);
    pack();
    setLocationRelativeTo(app.getFrame());	*/
  }
Example #19
0
  /**
   * Creates the panel and adds it to the main window (splitpane) on te left
   *
   * @param splitPane = main windows split into two sides, left and right.
   */
  protected static void addLeftPanel(JSplitPane splitPane) {

    JPanel windowLeft = new JPanel();
    // windowLeft.setBorder(BorderFactory.createLineBorder(Color.black));
    GroupLayout windowLeftLayout = new GroupLayout(windowLeft);
    windowLeft.setLayout(windowLeftLayout); // one column, start with no rows.
    windowLeftLayout.setAutoCreateContainerGaps(true);
    windowLeftLayout.setAutoCreateGaps(true);

    JLabel patientLabel =
        new ByFontSize_JLabel(
            "<html><br><b>Create or Load a New Patient File<br></b></html>",
            ByFontSize_JLabel.Size.L);
    patientLabelPointer =
        patientLabel; // global pointer to use for dynamic updating of label upon every relevant
                      // action
    patientLabel.setVerticalAlignment(JLabel.TOP);

    JLabel chooseResultText =
        new ByFontSize_JLabel("Choose Desired Reult to View:", ByFontSize_JLabel.Size.L);

    JPanel patientDataPanel = new JPanel();
    GroupLayout dataPanelLayout =
        new GroupLayout(
            patientDataPanel); // foolishly using grouplayot when starting out. way more complicated
                               // than it needs to be
    patientDataPanel.setLayout(dataPanelLayout);
    dataPanelLayout.setHonorsVisibility(true);
    dataPanelLayoutPointer =
        dataPanelLayout; // global pointer to use for dynamic updating of label upon every relevant
                         // action

    Component strut50 = Box.createVerticalStrut(50);

    resultChoiceList = new JComboBox<String>(ResultTypes.resultNames());
    resultChoiceList.setSelectedIndex(-1);
    resultChoiceList.setPreferredSize(new Dimension(4000, 25));
    resultChoiceList.setMaximumSize(resultChoiceList.getPreferredSize());
    resultChoiceList.setVisible(false); // invisible till we know there is valid data to work with

    noDataText =
        new ByFontSize_JLabel(
            "<html>No information to show. Please run test to collect data.<html>",
            ByFontSize_JLabel.Size.L);
    noDataText.setVisible(false);

    collectDataButton = new JButton("Begin Test");
    collectDataButton.setVisible(false);
    collectDataButton.setHorizontalAlignment(JButton.CENTER);
    collectDataButton.setToolTipText("Click here to begin sound lateralization test");
    collectDataButton.setFont(new Font("Serif", Font.PLAIN, 18));

    editPatientInfoButton = new JButton("View Patient Information");
    editPatientInfoButton.setVisible(false);
    editPatientInfoButton.setHorizontalAlignment(JButton.CENTER);
    editPatientInfoButton.setToolTipText("Click to edit patient info and add notes");
    editPatientInfoButton.setFont(new Font("Serif", Font.PLAIN, 18));

    ///////////

    windowLeftLayout.setHorizontalGroup(
        windowLeftLayout
            .createParallelGroup(GroupLayout.Alignment.TRAILING)
            .addComponent(patientLabel)
            .addComponent(strut50)
            .addComponent(patientDataPanel));

    windowLeftLayout.setVerticalGroup(
        windowLeftLayout
            .createSequentialGroup()
            .addComponent(patientLabel)
            .addComponent(strut50)
            .addComponent(patientDataPanel));

    //////////////

    currentHorizontalDataGroup =
        dataPanelLayoutPointer
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(chooseResultText)
            .addComponent(strut50)
            .addComponent(resultChoiceList)
            .addComponent(noDataText)
            .addComponent(strut50)
            .addComponent(collectDataButton, GroupLayout.Alignment.CENTER)
            .addComponent(strut50)
            .addComponent(editPatientInfoButton, GroupLayout.Alignment.CENTER);

    currentVerticalDataGroup =
        dataPanelLayoutPointer
            .createSequentialGroup()
            .addComponent(chooseResultText)
            .addComponent(strut50)
            .addComponent(resultChoiceList)
            .addComponent(noDataText)
            .addComponent(strut50)
            .addComponent(collectDataButton)
            .addComponent(strut50)
            .addComponent(editPatientInfoButton);

    dataPanelLayoutPointer.setHorizontalGroup(currentHorizontalDataGroup);
    dataPanelLayoutPointer.setVerticalGroup(currentVerticalDataGroup);

    //////////////

    splitPane.setLeftComponent(windowLeft);
  }
  /** Builds the panel. */
  public void setup() {
    DataModelList dataModelList = null;

    for (Object parentModel : parentModels) {
      if (parentModel instanceof DataWrapper) {
        DataWrapper dataWrapper = (DataWrapper) parentModel;
        dataModelList = dataWrapper.getDataModelList();
      }
    }

    if (dataModelList == null) {
      throw new NullPointerException("Null data model list.");
    }

    for (DataModel model : dataModelList) {
      if (!(model instanceof DataSet)) {
        JOptionPane.showMessageDialog(
            JOptionUtils.centeringComp(),
            "For the shift search, all of the data in the data box must be in the form of data sets.");
        return;
      }
    }

    final List<DataSet> dataSets = new ArrayList<DataSet>();

    for (Object aDataModelList : dataModelList) {
      dataSets.add((DataSet) aDataModelList);
    }

    SpinnerModel maxVarsModel =
        new SpinnerNumberModel(
            Preferences.userRoot().getInt("shiftSearchMaxNumShifts", 3), 1, 50, 1);
    JSpinner maxVarsSpinner = new JSpinner(maxVarsModel);
    maxVarsSpinner.setMaximumSize(maxVarsSpinner.getPreferredSize());

    maxVarsSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            JSpinner spinner = (JSpinner) e.getSource();
            SpinnerNumberModel model = (SpinnerNumberModel) spinner.getModel();
            int value = (Integer) model.getValue();
            Preferences.userRoot().putInt("shiftSearchMaxNumShifts", value);
          }
        });

    SpinnerModel maxShiftModel =
        new SpinnerNumberModel(Preferences.userRoot().getInt("shiftSearchMaxShift", 2), 1, 50, 1);
    JSpinner maxShiftSpinner = new JSpinner(maxShiftModel);
    maxShiftSpinner.setMaximumSize(maxShiftSpinner.getPreferredSize());

    maxShiftSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            JSpinner spinner = (JSpinner) e.getSource();
            SpinnerNumberModel model = (SpinnerNumberModel) spinner.getModel();
            int value = (Integer) model.getValue();
            Preferences.userRoot().putInt("shiftSearchMaxShift", value);
          }
        });

    JButton searchButton = new JButton("Search");
    final JButton stopButton = new JButton("Stop");

    final JTextArea textArea = new JTextArea();
    JScrollPane textScroll = new JScrollPane(textArea);
    textScroll.setPreferredSize(new Dimension(500, 200));

    searchButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            final Thread thread =
                new Thread() {
                  public void run() {
                    textArea.setText("");
                    doShiftSearch(dataSets, textArea);
                  }
                };

            thread.start();
          }
        });

    stopButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            if (search != null) {
              search.stop();
            }
          }
        });

    JComboBox directionBox = new JComboBox(new String[] {"forward", "backward"});
    directionBox.setSelectedItem(params.isForwardSearch() ? "forward" : "backward");
    directionBox.setMaximumSize(directionBox.getPreferredSize());

    directionBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            JComboBox source = (JComboBox) actionEvent.getSource();
            String selected = (String) source.getSelectedItem();
            params.setForwardSearch("forward".equals(selected));
          }
        });

    Box b1 = Box.createVerticalBox();

    Box b2 = Box.createHorizontalBox();
    b2.add(new JLabel("Maximum number of variables in shift set is: "));
    b2.add(maxVarsSpinner);
    b2.add(Box.createHorizontalGlue());
    b1.add(b2);

    Box b3 = Box.createHorizontalBox();
    b3.add(new JLabel("Maximum "));
    b3.add(directionBox);
    b3.add(new JLabel(" shift: "));
    b3.add(maxShiftSpinner);
    b3.add(Box.createHorizontalGlue());
    b1.add(b3);

    Box b4 = Box.createHorizontalBox();
    b4.add(new JLabel("Output:"));
    b4.add(Box.createHorizontalGlue());
    b1.add(b4);

    Box b5 = Box.createHorizontalBox();
    b5.add(textScroll);
    b1.add(b5);

    Box b6 = Box.createHorizontalBox();
    b6.add(searchButton);
    b6.add(stopButton);
    b1.add(b6);

    final Box a1 = Box.createVerticalBox();

    Box a2 = Box.createHorizontalBox();
    a2.add(new JLabel("Specify the shift (positive or negative) for each variable:"));
    a2.add(Box.createHorizontalGlue());
    a1.add(a2);

    a1.add(Box.createVerticalStrut(20));

    setUpA1(dataSets, a1);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Shift", new JScrollPane(a1));
    tabbedPane.addTab("Search", new JScrollPane(b1));

    add(tabbedPane, BorderLayout.CENTER);

    tabbedPane.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent changeEvent) {
            System.out.println("a1 shown");
            a1.removeAll();
            setUpA1(dataSets, a1);
          }
        });
  }
  private JComponent getButtonPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    choiceType = new JComboBox<PersonTypeItem>();
    choiceType.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceType.getPreferredSize().getHeight()));
    DefaultComboBoxModel<PersonTypeItem> personTypeModel = new DefaultComboBoxModel<>();
    personTypeModel.addElement(
        new PersonTypeItem(resourceMap.getString("primaryRole.choice.text"), null)); // $NON-NLS-1$
    for (int i = 1; i < Person.T_NUM; ++i) {
      personTypeModel.addElement(
          new PersonTypeItem(Person.getRoleDesc(i, campaign.getFaction().isClan()), i));
    }
    personTypeModel.addElement(
        new PersonTypeItem(Person.getRoleDesc(0, campaign.getFaction().isClan()), 0));
    // Add "none" for generic AsTechs
    choiceType.setModel(personTypeModel);
    choiceType.setSelectedIndex(0);
    choiceType.addActionListener(
        e -> {
          personnelFilter.setPrimaryRole(((PersonTypeItem) choiceType.getSelectedItem()).id);
          updatePersonnelTable();
        });
    panel.add(choiceType);

    choiceExp = new JComboBox<PersonTypeItem>();
    choiceExp.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceType.getPreferredSize().getHeight()));
    DefaultComboBoxModel<PersonTypeItem> personExpModel = new DefaultComboBoxModel<>();
    personExpModel.addElement(
        new PersonTypeItem(resourceMap.getString("experience.choice.text"), null)); // $NON-NLS-1$
    for (int i = 0; i < 5; ++i) {
      personExpModel.addElement(new PersonTypeItem(SkillType.getExperienceLevelName(i), i));
    }
    choiceExp.setModel(personExpModel);
    choiceExp.setSelectedIndex(0);
    choiceExp.addActionListener(
        e -> {
          personnelFilter.setExpLevel(((PersonTypeItem) choiceExp.getSelectedItem()).id);
          updatePersonnelTable();
        });
    panel.add(choiceExp);

    choiceSkill = new JComboBox<String>();
    choiceSkill.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceSkill.getPreferredSize().getHeight()));
    DefaultComboBoxModel<String> personSkillModel = new DefaultComboBoxModel<>();
    personSkillModel.addElement(choiceNoSkill);
    for (String skill : SkillType.getSkillList()) {
      personSkillModel.addElement(skill);
    }
    choiceSkill.setModel(personSkillModel);
    choiceSkill.setSelectedIndex(0);
    choiceSkill.addActionListener(
        e -> {
          if (choiceNoSkill.equals(choiceSkill.getSelectedItem())) {
            personnelFilter.setSkill(null);
            ((SpinnerNumberModel) skillLevel.getModel()).setMaximum(10);
            buttonSpendXP.setEnabled(false);
          } else {
            String skillName = (String) choiceSkill.getSelectedItem();
            personnelFilter.setSkill(skillName);
            int maxSkillLevel = SkillType.getType(skillName).getMaxLevel();
            int currentLevel = (Integer) skillLevel.getModel().getValue();
            ((SpinnerNumberModel) skillLevel.getModel()).setMaximum(maxSkillLevel);
            if (currentLevel > maxSkillLevel) {
              skillLevel.getModel().setValue(Integer.valueOf(maxSkillLevel));
            }
            buttonSpendXP.setEnabled(true);
          }
          updatePersonnelTable();
        });
    panel.add(choiceSkill);

    panel.add(Box.createRigidArea(new Dimension(10, 10)));
    panel.add(new JLabel(resourceMap.getString("targetSkillLevel.text"))); // $NON-NLS-1$

    skillLevel = new JSpinner(new SpinnerNumberModel(10, 0, 10, 1));
    skillLevel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) skillLevel.getPreferredSize().getHeight()));
    skillLevel.addChangeListener(
        e -> {
          personnelFilter.setMaxSkillLevel((Integer) skillLevel.getModel().getValue());
          updatePersonnelTable();
        });
    panel.add(skillLevel);

    allowPrisoners = new JCheckBox(resourceMap.getString("allowPrisoners.text")); // $NON-NLS-1$
    allowPrisoners.setHorizontalAlignment(SwingConstants.LEFT);
    allowPrisoners.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) allowPrisoners.getPreferredSize().getHeight()));
    allowPrisoners.addChangeListener(
        e -> {
          personnelFilter.setAllowPrisoners(allowPrisoners.isSelected());
          updatePersonnelTable();
        });
    JPanel allowPrisonersPanel = new JPanel(new GridLayout(1, 1));
    allowPrisonersPanel.setAlignmentY(JComponent.LEFT_ALIGNMENT);
    allowPrisonersPanel.add(allowPrisoners);
    allowPrisonersPanel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) allowPrisonersPanel.getPreferredSize().getHeight()));
    panel.add(allowPrisonersPanel);

    panel.add(Box.createVerticalGlue());

    matchedPersonnelLabel = new JLabel(""); // $NON-NLS-1$
    matchedPersonnelLabel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) matchedPersonnelLabel.getPreferredSize().getHeight()));
    panel.add(matchedPersonnelLabel);

    JPanel buttons = new JPanel(new FlowLayout());
    buttons.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) buttons.getPreferredSize().getHeight()));

    buttonSpendXP = new JButton(resourceMap.getString("spendXP.text")); // $NON-NLS-1$
    buttonSpendXP.setEnabled(false);
    buttonSpendXP.addActionListener(e -> spendXP());
    buttons.add(buttonSpendXP);

    JButton button = new JButton(resourceMap.getString("close.text")); // $NON-NLS-1$
    button.addActionListener(e -> setVisible(false));
    buttons.add(button);

    panel.add(buttons);

    panel.setMaximumSize(new Dimension((int) panel.getPreferredSize().getWidth(), Short.MAX_VALUE));
    panel.setMinimumSize(new Dimension((int) panel.getPreferredSize().getWidth(), 300));

    return panel;
  }
  public static void getCategories(
      Map<String, Component> componentsMap,
      Map<String, Component> tabs,
      JComboBox<?> skinComboBox,
      ResourceBundle resourceBundle) {
    Map<String, Map<String, Field>> categorized = new HashMap<>();

    Map<String, Field> fields = Configuration.getConfigurationFields();
    String[] keys = new String[fields.size()];
    keys = fields.keySet().toArray(keys);
    Arrays.sort(keys);

    for (String name : keys) {
      Field field = fields.get(name);
      ConfigurationCategory cat = field.getAnnotation(ConfigurationCategory.class);
      String scat = cat == null ? "other" : cat.value();
      if (!categorized.containsKey(scat)) {
        categorized.put(scat, new HashMap<>());
      }

      categorized.get(scat).put(name, field);
    }

    for (String cat : categorized.keySet()) {
      JPanel configPanel = new JPanel(new SpringLayout());
      int itemCount = 0;
      for (String name : categorized.get(cat).keySet()) {
        Field field = categorized.get(cat).get(name);

        String locName = resourceBundle.getString("config.name." + name);

        try {
          ConfigurationItem item = (ConfigurationItem) field.get(null);

          ParameterizedType listType = (ParameterizedType) field.getGenericType();
          java.lang.reflect.Type itemType2 = listType.getActualTypeArguments()[0];
          if (!(itemType2 instanceof Class<?>)) {
            continue;
          }

          Class itemType = (Class<?>) itemType2;

          String description = resourceBundle.getString("config.description." + name);

          Object defaultValue = Configuration.getDefaultValue(field);
          if (name.equals("gui.skin")) {
            Class c;
            try {
              c = Class.forName((String) defaultValue);
              defaultValue = c.getField("NAME").get(c);
            } catch (ClassNotFoundException | NoSuchFieldException | SecurityException ex) {
              Logger.getLogger(AdvancedSettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
            }
          }

          if (defaultValue != null) {
            description += " (" + resourceBundle.getString("default") + ": " + defaultValue + ")";
          }

          JLabel l = new JLabel(locName, JLabel.TRAILING);
          l.setToolTipText(description);
          configPanel.add(l);
          Component c = null;
          if (name.equals("gui.skin")) {
            skinComboBox.setToolTipText(description);
            skinComboBox.setMaximumSize(
                new Dimension(Integer.MAX_VALUE, skinComboBox.getPreferredSize().height));
            c = skinComboBox;
          } else if ((itemType == String.class)
              || (itemType == Integer.class)
              || (itemType == Long.class)
              || (itemType == Double.class)
              || (itemType == Float.class)
              || (itemType == Calendar.class)) {
            JTextField tf = new JTextField();
            Object val = item.get();
            if (val == null) {
              val = "";
            }
            if (itemType == Calendar.class) {
              tf.setText(new SimpleDateFormat().format(((Calendar) item.get()).getTime()));
            } else {
              tf.setText(val.toString());
            }
            tf.setToolTipText(description);
            tf.setMaximumSize(new Dimension(Integer.MAX_VALUE, tf.getPreferredSize().height));
            c = tf;
          } else if (itemType == Boolean.class) {
            JCheckBox cb = new JCheckBox();
            cb.setSelected((Boolean) item.get());
            cb.setToolTipText(description);
            c = cb;
          } else if (itemType.isEnum()) {
            JComboBox<String> cb = new JComboBox<>();
            @SuppressWarnings("unchecked")
            EnumSet enumValues = EnumSet.allOf(itemType);
            String stringValue = null;
            for (Object enumValue : enumValues) {
              String enumValueStr = enumValue.toString();
              if (stringValue == null) {
                stringValue = enumValueStr;
              }
              cb.addItem(enumValueStr);
            }
            if (item.get() != null) {
              stringValue = item.get().toString();
            }
            cb.setToolTipText(description);
            cb.setSelectedItem(stringValue);
            cb.setMaximumSize(new Dimension(Integer.MAX_VALUE, cb.getPreferredSize().height));
            c = cb;
          } else {
            throw new UnsupportedOperationException(
                "Configuration ttem type '" + itemType.getName() + "' is not supported");
          }

          componentsMap.put(name, c);
          l.setLabelFor(c);
          configPanel.add(c);
        } catch (IllegalArgumentException | IllegalAccessException ex) {
          // Reflection exceptions. This should never happen
          throw new Error(ex.getMessage());
        }

        itemCount++;
      }

      SpringUtilities.makeCompactGrid(
          configPanel,
          itemCount,
          2, // rows, cols
          6,
          6, // initX, initY
          6,
          6); // xPad, yPad
      tabs.put(cat, new JScrollPane(configPanel));
    }
  }
  public BankGUI(BankDriver server) {
    this.driver = server;
    this.bank = server.getBank();

    if (server instanceof BankDriver2) {
      try {
        ((BankDriver2) server)
            .registerUpdateHandler(
                new BankDriver2.UpdateHandler() {
                  @Override
                  public void accountChanged(String number) {
                    SwingUtilities.invokeLater(
                        new Runnable() {
                          @Override
                          public void run() {
                            refreshDialog();
                          }
                        });
                  }
                });
      } catch (IOException e1) {
        throw new RuntimeException(e1);
      }
    }

    setTitle("ClientBank Application");
    setBackground(Color.lightGray);

    BankTest test;
    test = loadTest("bank.gui.tests.EfficiencyTest");
    if (test != null) {
      tests.add(test);
    }
    test = loadTest("bank.gui.tests.ThreadingTest");
    if (test != null) {
      tests.add(test);
    }
    test = loadTest("bank.gui.tests.FunctionalityTest");
    if (test != null) {
      tests.add(test);
    }
    test = loadTest("bank.gui.tests.TransferTest");
    if (test != null) {
      tests.add(test);
    }
    test = loadTest("bank.gui.tests.ConcurrentReads");
    if (test != null) {
      tests.add(test);
    }

    // define menus
    JMenuBar menubar = new JMenuBar();
    setJMenuBar(menubar);

    JMenu menu_file = new JMenu("File");
    menubar.add(menu_file);
    menu_file.add(item_new);
    menu_file.add(item_close);
    menu_file.addSeparator();
    menu_file.add(item_exit);

    JMenu menu_test = new JMenu("Test");
    menubar.add(menu_test);

    for (BankTest t : tests) {
      final BankTest tt = t;
      JMenuItem m = new JMenuItem(t.getName());
      testMenuItems.put(t, m);
      menu_test.add(m);
      m.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                tt.runTests(BankGUI.this, bank, currentAccountNumber());
                refreshDialog();
              } catch (Exception ex) {
                error(ex);
              }
            }
          });
    }

    JMenu menu_help = new JMenu("Help");
    menubar.add(menu_help);
    menu_help.add(item_about);

    item_new.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addAccount();
          }
        });
    item_close.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            closeAccount();
          }
        });
    item_exit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            exit();
          }
        });
    item_about.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            about();
          }
        });

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            exit();
          }

          @Override
          public void windowDeiconified(WindowEvent e) {
            refreshDialog();
          }
        });

    accountcombo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (ignoreItemChanges) return;
            if (e.getStateChange() == ItemEvent.SELECTED) updateCustomerInfo();
          }
        });

    // create layout

    setResizable(false);

    JPanel center = new JPanel(new GridLayout(3, 2, 5, 5));
    center.add(new JLabel("Account Nr: ", SwingConstants.RIGHT));
    center.add(accountcombo);
    center.add(new JLabel("Owner: ", SwingConstants.RIGHT));
    center.add(fld_owner);
    center.add(new JLabel("Balance: ", SwingConstants.RIGHT));
    center.add(fld_balance);

    // set text fields read only
    fld_owner.setEditable(false);
    fld_balance.setEditable(false);

    JPanel east = new JPanel(new GridLayout(3, 1, 5, 5));
    east.add(btn_deposit);
    east.add(btn_withdraw);
    east.add(btn_transfer);

    JPanel p = new JPanel(new BorderLayout(10, 10));
    p.add(new JLabel(""), BorderLayout.NORTH);
    p.add(center, BorderLayout.CENTER);
    p.add(east, BorderLayout.EAST);
    if (!(driver instanceof BankDriver2)) {
      p.add(btn_refresh, BorderLayout.SOUTH);
    } else {
      p.add(new JLabel(""), BorderLayout.SOUTH);
    }
    add(p);

    // Add ActionListeners
    btn_refresh.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            refreshDialog();
          }
        });
    btn_deposit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            deposit();
          }
        });
    btn_withdraw.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            withdraw();
          }
        });
    btn_transfer.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            transfer();
          }
        });

    Dimension d = accountcombo.getPreferredSize();
    d.setSize(Math.max(d.getWidth(), 130), d.getHeight());
    accountcombo.setPreferredSize(d);

    refreshDialog();
  }
Example #24
0
  public JPanel makePanel() {
    GridLayout gridL = new GridLayout(1, 2);
    JPanel mainPanel = new JPanel(gridL); // has BorderLayout
    mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    // create function list area
    JPanel funcPanel = new JPanel(new BorderLayout());
    funcPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    functionList = new JList();
    functionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    functionList.addListSelectionListener(this);
    functionList.setVisibleRowCount(12);
    JScrollPane scrollPane = new JScrollPane(functionList);
    funcPanel.add(scrollPane);

    JPanel categoryPanel = new JPanel();
    JLabel label = new JLabel(categoriesLabel);
    categoryPanel.add(label);
    categoryMenu = new JComboBox();
    categoryPanel.add(categoryMenu);
    funcPanel.add(categoryPanel, BorderLayout.NORTH);

    // create control area on right (key bindings and buttons)
    JPanel controlPanel = new JPanel(new BorderLayout());
    controlPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    // create area for key bindings
    JPanel keyPanel = new JPanel(new BorderLayout());
    JLabel kLabel = new JLabel(keyLabel);
    kLabel.setPreferredSize(categoryMenu.getPreferredSize());
    keyPanel.add(kLabel, BorderLayout.NORTH);
    keyList = new JList();
    keyList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    keyList.setPrototypeCellValue("shift-ctrl-delete");
    keyList.setVisibleRowCount(4);
    scrollPane = new JScrollPane(keyList);
    keyPanel.add(scrollPane, BorderLayout.CENTER);

    JPanel keyButtonPanel = new JPanel();
    addKeyButton = new JButton(addKeyLabel);
    addKeyButton.setMargin(new Insets(2, 2, 2, 2));
    keyButtonPanel.add(addKeyButton);

    delKeyButton = new JButton(delKeyLabel);
    delKeyButton.setMargin(new Insets(2, 2, 2, 2));
    keyButtonPanel.add(delKeyButton);

    defaultsButton = new JButton(defaultsLabel);
    keyButtonPanel.add(defaultsButton);
    keyPanel.add(keyButtonPanel, BorderLayout.SOUTH);
    controlPanel.add(keyPanel);

    // create help text area at bottom
    JPanel helpPanel = new JPanel(new GridLayout());
    helpPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createEmptyBorder(10, 0, 0, 0),
            BorderFactory.createLineBorder(Color.black)));
    helpLabel = new JTextArea();
    helpLabel.setRows(6);
    helpLabel.setLineWrap(true);
    helpLabel.setWrapStyleWord(true);
    helpLabel.setBackground(MoeEditor.infoColor);
    helpPanel.add(helpLabel);
    controlPanel.add(helpPanel, BorderLayout.SOUTH);

    mainPanel.add(funcPanel);
    mainPanel.add(controlPanel);
    updateDispay();

    return mainPanel;
  }
Example #25
0
 private void relayout() {
   int preferredHeight = b.getPreferredSize().height;
   b.setBounds(0, topOffset, getWidth(), preferredHeight);
 }
  public SettingsPanel() {
    setLayout(new BorderLayout());
    topPanel = new JPanel();
    topPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    helpIcon = Utils.getIconImage("/resources/Help.png");

    // Language
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = LABEL_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    languageLabel = new JLabel(App.settings.getLocalizedString("settings.language") + ":");
    languageLabel.setIcon(helpIcon);
    languageLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && e.getY() < 16) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    App.settings.getLocalizedString("settings.languagehelp"),
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(languageLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    language = new JComboBox<Language>();
    for (Language languagee : App.settings.getLanguages()) {
      language.addItem(languagee);
    }
    language.setSelectedItem(App.settings.getLanguage());
    topPanel.add(language, gbc);

    // Forge Logging Level
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = LABEL_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    forgeLoggingLevelLabel =
        new JLabel(App.settings.getLocalizedString("settings.forgelogginglevel") + ":");
    forgeLoggingLevelLabel.setIcon(helpIcon);
    forgeLoggingLevelLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && e.getY() < 16) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    "<html><center>"
                        + App.settings.getLocalizedString(
                            "settings.forgelogginglevelhelp", "<br/><br/>")
                        + "</center></html>",
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(forgeLoggingLevelLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    forgeLoggingLevel = new JComboBox<String>();
    forgeLoggingLevel.addItem("SEVERE");
    forgeLoggingLevel.addItem("WARNING");
    forgeLoggingLevel.addItem("INFO");
    forgeLoggingLevel.addItem("CONFIG");
    forgeLoggingLevel.addItem("FINE");
    forgeLoggingLevel.addItem("FINER");
    forgeLoggingLevel.addItem("FINEST");
    forgeLoggingLevel.setSelectedItem(App.settings.getForgeLoggingLevel());
    topPanel.add(forgeLoggingLevel, gbc);

    // Download Server
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = LABEL_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    downloadServerLabel =
        new JLabel(App.settings.getLocalizedString("settings.downloadserver") + ":");
    downloadServerLabel.setIcon(helpIcon);
    downloadServerLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && e.getY() < 16) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    App.settings.getLocalizedString("settings.downloadserverhelp"),
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(downloadServerLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    server = new JComboBox<Server>();
    for (Server serverr : App.settings.getServers()) {
      server.addItem(serverr);
    }
    server.setSelectedItem(App.settings.getOriginalServer());
    topPanel.add(server, gbc);

    // Memory Settings
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = LABEL_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    memoryLabel = new JLabel(App.settings.getLocalizedString("settings.memory") + ":");
    memoryLabel.setIcon(helpIcon);
    memoryLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && e.getY() < 16) {
                if (!Utils.is64Bit()) {
                  JOptionPane.showMessageDialog(
                      App.settings.getParent(),
                      "<html><center>"
                          + App.settings.getLocalizedString("settings.memoryhelp32bit", "<br/>")
                          + "</center></html>",
                      App.settings.getLocalizedString("settings.help"),
                      JOptionPane.PLAIN_MESSAGE);
                } else {
                  JOptionPane.showMessageDialog(
                      App.settings.getParent(),
                      App.settings.getLocalizedString("settings.memoryhelp"),
                      App.settings.getLocalizedString("settings.help"),
                      JOptionPane.PLAIN_MESSAGE);
                }
              }
            }
          }
        });
    topPanel.add(memoryLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    memory = new JComboBox<String>();
    String[] memoryOptions = Utils.getMemoryOptions();
    for (int i = 0; i < memoryOptions.length; i++) {
      memory.addItem(memoryOptions[i]);
    }
    memory.setSelectedItem(App.settings.getMemory() + " MB");
    topPanel.add(memory, gbc);

    // Perm Gen Settings
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = LABEL_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    permGenLabel = new JLabel(App.settings.getLocalizedString("settings.permgen") + ":");
    permGenLabel.setIcon(helpIcon);
    permGenLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && e.getY() < 16) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    App.settings.getLocalizedString("settings.permgenhelp"),
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(permGenLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    permGen = new JTextField(4);
    permGen.setText(App.settings.getPermGen() + "");
    topPanel.add(permGen, gbc);

    // Window Size
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.gridwidth = 1;
    gbc.insets = LABEL_INSETS_SMALL;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    windowSizeLabel = new JLabel(App.settings.getLocalizedString("settings.windowsize") + ":");
    windowSizeLabel.setIcon(helpIcon);
    windowSizeLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && (e.getY() > 10 && e.getY() < 26)) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    App.settings.getLocalizedString("settings.windowsizehelp"),
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(windowSizeLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS_SMALL;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    windowSizePanel = new JPanel();
    windowSizePanel.setLayout(new FlowLayout());
    widthField = new JTextField(4);
    widthField.setText(App.settings.getWindowWidth() + "");
    heightField = new JTextField(4);
    heightField.setText(App.settings.getWindowHeight() + "");
    commonScreenSizes = new JComboBox<String>();
    commonScreenSizes.addItem("Select An Option");
    commonScreenSizes.addItem("854x480");
    if (Utils.getMaximumWindowWidth() >= 1280 && Utils.getMaximumWindowHeight() >= 720) {
      commonScreenSizes.addItem("1280x720");
    }
    if (Utils.getMaximumWindowWidth() >= 1600 && Utils.getMaximumWindowHeight() >= 900) {
      commonScreenSizes.addItem("1600x900");
    }
    if (Utils.getMaximumWindowWidth() >= 1920 && Utils.getMaximumWindowHeight() >= 1080) {
      commonScreenSizes.addItem("1920x1080");
    }
    commonScreenSizes.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String selected = (String) commonScreenSizes.getSelectedItem();
            if (selected.contains("x")) {
              String[] parts = selected.split("x");
              widthField.setText(parts[0]);
              heightField.setText(parts[1]);
            }
          }
        });
    commonScreenSizes.setPreferredSize(
        new Dimension(
            commonScreenSizes.getPreferredSize().width + 10,
            commonScreenSizes.getPreferredSize().height));
    windowSizePanel.add(widthField);
    windowSizePanel.add(new JLabel("x"));
    windowSizePanel.add(heightField);
    windowSizePanel.add(commonScreenSizes);
    topPanel.add(windowSizePanel, gbc);
    windowSizeLabel.setPreferredSize(
        new Dimension(
            windowSizeLabel.getPreferredSize().width, windowSizePanel.getPreferredSize().height));

    // Java Path

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.gridwidth = 1;
    gbc.insets = LABEL_INSETS_SMALL;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    javaPathLabel = new JLabel(App.settings.getLocalizedString("settings.javapath") + ":");
    javaPathLabel.setIcon(helpIcon);
    javaPathLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && (e.getY() > 10 && e.getY() < 26)) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    "<html><center>"
                        + App.settings.getLocalizedString("settings.javapathhelp", "<br/>")
                        + "</center></html>",
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(javaPathLabel, gbc);

    gbc.gridx++;
    gbc.insets = LABEL_INSETS_SMALL;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    javaPathPanel = new JPanel();
    javaPathPanel.setLayout(new FlowLayout());
    javaPath = new JTextField(20);
    javaPath.setText(App.settings.getJavaPath());
    javaPathResetButton = new JButton(App.settings.getLocalizedString("settings.javapathreset"));
    javaPathResetButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            javaPath.setText(Utils.getJavaHome());
          }
        });
    javaPathPanel.add(javaPath);
    javaPathPanel.add(javaPathResetButton);
    topPanel.add(javaPathPanel, gbc);
    javaPathLabel.setPreferredSize(
        new Dimension(
            javaPathLabel.getPreferredSize().width, javaPathPanel.getPreferredSize().height));

    // Java Paramaters

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = LABEL_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    javaParametersLabel =
        new JLabel(App.settings.getLocalizedString("settings.javaparameters") + ":");
    javaParametersLabel.setIcon(helpIcon);
    javaParametersLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && e.getY() < 16) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    App.settings.getLocalizedString("settings.javaparametershelp"),
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(javaParametersLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    javaParameters = new JTextField(20);
    javaParameters.setText(App.settings.getJavaParameters());
    topPanel.add(javaParameters, gbc);

    // Start Minecraft Maximised

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = LABEL_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    startMinecraftMaximisedLabel =
        new JLabel(App.settings.getLocalizedString("settings.startminecraftmaximised") + "?");
    startMinecraftMaximisedLabel.setIcon(helpIcon);
    startMinecraftMaximisedLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && e.getY() < 16) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    App.settings.getLocalizedString("settings.startminecraftmaximisedhelp"),
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(startMinecraftMaximisedLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    startMinecraftMaximised = new JCheckBox();
    if (App.settings.startMinecraftMaximised()) {
      startMinecraftMaximised.setSelected(true);
    }
    topPanel.add(startMinecraftMaximised, gbc);

    // Sort Packs Alphabetically

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = LABEL_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    sortPacksAlphabeticallyLabel =
        new JLabel(App.settings.getLocalizedString("settings.sortpacksalphabetically") + "?");
    sortPacksAlphabeticallyLabel.setIcon(helpIcon);
    sortPacksAlphabeticallyLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && e.getY() < 16) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    App.settings.getLocalizedString("settings.sortpacksalphabeticallyhelp"),
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(sortPacksAlphabeticallyLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    sortPacksAlphabetically = new JCheckBox();
    if (App.settings.sortPacksAlphabetically()) {
      sortPacksAlphabetically.setSelected(true);
    }
    topPanel.add(sortPacksAlphabetically, gbc);

    // Enable Console

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = LABEL_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    enableConsoleLabel = new JLabel(App.settings.getLocalizedString("settings.console") + "?");
    enableConsoleLabel.setIcon(helpIcon);
    enableConsoleLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && e.getY() < 16) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    App.settings.getLocalizedString("settings.consolehelp"),
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(enableConsoleLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    enableConsole = new JCheckBox();
    if (App.settings.enableConsole()) {
      enableConsole.setSelected(true);
    }
    topPanel.add(enableConsole, gbc);

    // Enable Debug Console

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = LABEL_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    enableDebugConsoleLabel =
        new JLabel(App.settings.getLocalizedString("settings.debugconsole") + "?");
    enableDebugConsoleLabel.setIcon(helpIcon);
    enableDebugConsoleLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && e.getY() < 16) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    App.settings.getLocalizedString("settings.debugconsolehelp"),
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(enableDebugConsoleLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    enableDebugConsole = new JCheckBox();
    if (App.settings.enableDebugConsole()) {
      enableDebugConsole.setSelected(true);
    }
    topPanel.add(enableDebugConsole, gbc);

    // Enable Leaderboards

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = LABEL_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    enableLeaderboardsLabel =
        new JLabel(App.settings.getLocalizedString("settings.leaderboards") + "?");
    enableLeaderboardsLabel.setIcon(helpIcon);
    enableLeaderboardsLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && e.getY() < 16) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    App.settings.getLocalizedString("settings.leaderboardshelp"),
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(enableLeaderboardsLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    enableLeaderboards = new JCheckBox();
    if (App.settings.enableLeaderboards()) {
      enableLeaderboards.setSelected(true);
    }
    topPanel.add(enableLeaderboards, gbc);

    // Enable Logging

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.insets = LABEL_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_TRAILING;
    enableLoggingLabel = new JLabel(App.settings.getLocalizedString("settings.logging") + "?");
    enableLoggingLabel.setIcon(helpIcon);
    enableLoggingLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
              if (e.getX() < 16 && e.getY() < 16) {
                JOptionPane.showMessageDialog(
                    App.settings.getParent(),
                    "<html><center>"
                        + App.settings.getLocalizedString("settings.logginghelp", "<br/>")
                        + "</center></html>",
                    App.settings.getLocalizedString("settings.help"),
                    JOptionPane.PLAIN_MESSAGE);
              }
            }
          }
        });
    topPanel.add(enableLoggingLabel, gbc);

    gbc.gridx++;
    gbc.insets = FIELD_INSETS;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    enableLogs = new JCheckBox();
    if (App.settings.enableLogs()) {
      enableLogs.setSelected(true);
    }
    topPanel.add(enableLogs, gbc);

    // End Components

    bottomPanel = new JPanel();
    saveButton = new JButton(App.settings.getLocalizedString("common.save"));
    saveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            File jPath = new File(javaPath.getText(), "bin");
            if (!jPath.exists()) {
              JOptionPane.showMessageDialog(
                  App.settings.getParent(),
                  "<html><center>"
                      + App.settings.getLocalizedString("settings.javapathincorrect", "<br/><br/>")
                      + "</center></html>",
                  App.settings.getLocalizedString("settings.help"),
                  JOptionPane.PLAIN_MESSAGE);
              return;
            }
            if (javaParameters.getText().contains("-Xms")
                || javaParameters.getText().contains("-Xmx")
                || javaParameters.getText().contains("-XX:PermSize")) {
              JOptionPane.showMessageDialog(
                  App.settings.getParent(),
                  "<html><center>"
                      + App.settings.getLocalizedString(
                          "settings.javaparametersincorrect", "<br/><br/>")
                      + "</center></html>",
                  App.settings.getLocalizedString("settings.help"),
                  JOptionPane.PLAIN_MESSAGE);
              return;
            }
            boolean reboot = false;
            boolean reloadPacksPanel = false;
            if (language.getSelectedItem() != App.settings.getLanguage()) {
              reboot = true;
            }
            if (sortPacksAlphabetically.isSelected() != App.settings.sortPacksAlphabetically()) {
              reloadPacksPanel = true;
            }
            App.settings.setLanguage((Language) language.getSelectedItem());
            App.settings.setServer((Server) server.getSelectedItem());
            App.settings.setForgeLoggingLevel((String) forgeLoggingLevel.getSelectedItem());
            App.settings.setMemory(
                Integer.parseInt(((String) memory.getSelectedItem()).replace(" MB", "")));
            App.settings.setPermGen(Integer.parseInt(permGen.getText().replaceAll("[^0-9]", "")));
            App.settings.setWindowWidth(
                Integer.parseInt(widthField.getText().replaceAll("[^0-9]", "")));
            App.settings.setWindowHeight(
                Integer.parseInt(heightField.getText().replaceAll("[^0-9]", "")));
            App.settings.setJavaPath(javaPath.getText());
            App.settings.setJavaParameters(javaParameters.getText());
            App.settings.setStartMinecraftMaximised(startMinecraftMaximised.isSelected());
            App.settings.setSortPacksAlphabetically(sortPacksAlphabetically.isSelected());
            App.settings.setEnableConsole(enableConsole.isSelected());
            App.settings.setEnableDebugConsole(enableDebugConsole.isSelected());
            App.settings.setEnableLeaderboards(enableLeaderboards.isSelected());
            App.settings.setEnableLogs(enableLogs.isSelected());
            App.settings.saveProperties();
            App.settings.log("Settings Saved!");
            if (reboot) {
              App.settings.restartLauncher();
            }
            if (reloadPacksPanel) {
              App.settings.reloadPacksPanel();
            }
            String[] options = {App.settings.getLocalizedString("common.ok")};
            JOptionPane.showOptionDialog(
                App.settings.getParent(),
                App.settings.getLocalizedString("settings.saved"),
                App.settings.getLocalizedString("settings.saved"),
                JOptionPane.DEFAULT_OPTION,
                JOptionPane.INFORMATION_MESSAGE,
                null,
                options,
                options[0]);
          }
        });
    bottomPanel.add(saveButton);

    add(topPanel, BorderLayout.CENTER);
    add(bottomPanel, BorderLayout.SOUTH);
  }
  public EducAssignmentPanel() {
    super("‘ормирование учебных поручений");
    List<Image> icons = new Vector<Image>();
    icons.add(new ImageIcon("images/уп.png").getImage());
    setIconImages(icons);
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    this.setPreferredSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT));
    this.setResizable(false);
    Dimension dim_screen = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation(
        (int) dim_screen.getWidth() / 2 - DEFAULT_WIDTH / 2,
        (int) dim_screen.getHeight() / 2 - DEFAULT_HEIGHT / 2);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JPanel content_top = BoxLayoutUtils.createHorizontalPanel();

    // ----------------------------------------------------------
    JPanel semester = BoxLayoutUtils.createHorizontalPanel();
    semester.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel lab_semester = new JLabel("¬ид семестра:");
    semester_combo = new JComboBox<String>();
    semester_combo.setBackground(Color.white);
    semester_combo.addItem("летний");
    semester_combo.addItem("зимний");
    lab_semester.setPreferredSize(new Dimension(100, 27));
    lab_semester.setMaximumSize(lab_semester.getPreferredSize());
    lab_semester.setMinimumSize(lab_semester.getPreferredSize());
    semester_combo.setPreferredSize(new Dimension(100, 27));
    semester_combo.setMaximumSize(semester_combo.getPreferredSize());
    semester_combo.setMinimumSize(semester_combo.getPreferredSize());
    semester.add(lab_semester);
    semester.add(semester_combo);

    JPanel bevel_semester = BoxLayoutUtils.createHorizontalPanel();
    bevel_semester.setBorder(BorderFactory.createLoweredBevelBorder());

    JPanel out_semester = BoxLayoutUtils.createHorizontalPanel();
    out_semester.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    bevel_semester.add(semester);
    out_semester.add(bevel_semester);
    // ----------------------------------------------------------

    JPanel cath = BoxLayoutUtils.createVerticalPanel();
    cath.setBackground(Color.white);
    semester.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    CurriculumTransaction tr = new CurriculumTransaction();
    ArrayList<String> cath_names = tr.getCathedras();
    checks = new ArrayList<JCheckBox>();
    this.checks.add(new JCheckBox("выбрать все..."));
    for (String name : cath_names) checks.add(new JCheckBox(name));
    for (JCheckBox cur_check : checks) {
      cath.add(Box.createHorizontalStrut(5));
      cath.add(cur_check);
      cur_check.setBackground(Color.white);
    }
    checks
        .get(0)
        .addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                JCheckBox check = (JCheckBox) e.getSource();
                if (check.isSelected()) {
                  for (JCheckBox cur : checks) cur.setSelected(true);
                } else for (JCheckBox cur : checks) cur.setSelected(false);
              }
            });
    cath.add(Box.createGlue());

    JPanel bevel_cath = BoxLayoutUtils.createHorizontalPanel();
    bevel_cath.setBorder(BorderFactory.createLoweredBevelBorder());

    JPanel out_cath = BoxLayoutUtils.createHorizontalPanel();
    out_cath.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));

    bevel_cath.add(new JScrollPane(cath));
    out_cath.add(bevel_cath);
    // ----------------------------------------------------------
    JPanel right = BoxLayoutUtils.createVerticalPanel();
    right.add(out_semester);
    right.add(out_cath);

    content_top.add(right);
    chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    content_top.add(chooser);
    // ----------------------------------------------------------
    JPanel content_create = BoxLayoutUtils.createHorizontalPanel();
    content_create.add(Box.createHorizontalGlue());
    create = new JButton("—формировать поручени¤");
    create.setPreferredSize(new Dimension(200, 27));
    create.setMinimumSize(create.getPreferredSize());
    create.setMaximumSize(create.getPreferredSize());
    cancel = new JButton("ќтмена");
    cancel.setPreferredSize(new Dimension(100, 27));
    cancel.setMinimumSize(cancel.getPreferredSize());
    cancel.setMaximumSize(cancel.getPreferredSize());
    content_create.add(create);
    content_create.add(Box.createHorizontalStrut(5));
    content_create.add(cancel);
    content_create.add(Box.createHorizontalStrut(4));

    JPanel create_empty = BoxLayoutUtils.createHorizontalPanel();
    create_empty.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JPanel content_bottom = BoxLayoutUtils.createHorizontalPanel();
    content_bottom.setBorder(BorderFactory.createEtchedBorder());
    create_empty.add(content_create);
    content_bottom.add(create_empty);

    JPanel content = BoxLayoutUtils.createVerticalPanel();
    content.add(content_top);
    content.add(content_bottom);

    create.addActionListener(this);
    cancel.addActionListener(this);
    setContentPane(content);
    setVisible(true);
  }
Example #28
0
  /** Creates a new WelcomeFrame and makes it visible. */
  public WelcomeFrame() {
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(final WindowEvent event) {
            cancel();
          };
        });

    setIconImage(Icons.SC2GEARS.getImage());

    final Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(5));
    box.add(GuiUtils.wrapInPanel(SharedUtils.createAnimatedLogoLabel()));
    box.add(Box.createVerticalStrut(10));
    GuiUtils.changeFontToBold(welcomeLabel);
    box.add(Box.createVerticalStrut(15));
    box.add(GuiUtils.wrapInPanel(welcomeLabel));
    box.add(Box.createVerticalStrut(15));
    box.add(GuiUtils.wrapInPanel(firstRunLabel));
    box.add(GuiUtils.wrapInPanel(chooseLabel));
    box.add(Box.createVerticalStrut(15));
    box.add(GuiUtils.wrapInPanel(thankYouLabel));
    box.add(Box.createVerticalStrut(15));

    final JPanel languagePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 1));
    languagePanel.add(languageLabel);
    final JComboBox<String> languagesComboBox = new JComboBox<>(Language.getAvailableLanguages());
    languagesComboBox.setMaximumRowCount(
        languagesComboBox.getModel().getSize()); // Display all languages
    languagesComboBox.setRenderer(
        new BaseLabelListCellRenderer<String>() {
          @Override
          public Icon getIcon(final String value) {
            return Icons.getLanguageIcon(value);
          }
        });
    languagesComboBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent event) {
            final String language = (String) languagesComboBox.getSelectedItem();
            Language.loadAndActivateLanguage(language);

            reassignTexts();
          }
        });
    languagePanel.add(languagesComboBox);
    box.add(languagePanel);

    final JPanel voicePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 1));
    voicePanel.add(voiceLabel);
    final JComboBox<VoiceDescription> voiceComboBox = new JComboBox<>(Sounds.VOICE_DESCRIPTIONS);
    voiceComboBox.setMaximumRowCount(15); // Not too many languages, display them all
    voiceComboBox.setRenderer(
        new BaseLabelListCellRenderer<VoiceDescription>() {
          @Override
          public Icon getIcon(final VoiceDescription value) {
            return Icons.getLanguageIcon(value.language);
          }
        });
    voiceComboBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent event) {
            final VoiceDescription voiceDescription =
                (VoiceDescription) voiceComboBox.getSelectedItem();
            Settings.set(Settings.KEY_SETTINGS_VOICE, voiceDescription.name);
            Sounds.playSoundSample(Sounds.SAMPLE_WELCOME, false);
          }
        });
    voicePanel.add(voiceComboBox);
    box.add(voicePanel);

    int maxWidth =
        Math.max(
            languagesComboBox.getPreferredSize().width, voiceComboBox.getPreferredSize().width);
    maxWidth += 5;
    languagesComboBox.setPreferredSize(
        new Dimension(maxWidth, languagesComboBox.getPreferredSize().height));
    voiceComboBox.setPreferredSize(
        new Dimension(maxWidth, voiceComboBox.getPreferredSize().height));

    box.add(Box.createVerticalStrut(15));

    final JPanel buttonsPanel = new JPanel();
    okButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent event) {
            dispose();
            Settings.set(
                Settings.KEY_SETTINGS_LANGUAGE, (String) languagesComboBox.getSelectedItem());
            Settings.saveProperties();
            synchronized (WelcomeFrame.this) {
              Sounds.playSoundSample(Sounds.SAMPLE_THANK_YOU, false);
              WelcomeFrame.this
                  .notify(); // Notify the main thread to continue starting the application
            }
          }
        });
    buttonsPanel.add(okButton);
    cancelButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent event) {
            cancel();
          }
        });
    buttonsPanel.add(cancelButton);
    box.add(buttonsPanel);

    box.add(Box.createVerticalStrut(15));

    final JPanel panel = new JPanel();
    panel.add(Box.createHorizontalStrut(15));
    panel.add(box);
    panel.add(Box.createHorizontalStrut(15));
    getContentPane().add(panel);

    setResizable(false);

    reassignTexts();
    setVisible(true);

    okButton.requestFocusInWindow();
    Sounds.playSoundSample(Sounds.SAMPLE_WELCOME, false);
  }
  private JPanel createAttributePanel() {
    JPanel attributePanel = new JPanel();
    attributePanel.setLayout(new BoxLayout(attributePanel, BoxLayout.Y_AXIS));

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

    attributeCombo = new JComboBox<String>();
    for (String attribute : getAttributes(true)) {
      attributeCombo.addItem(attribute);
    }
    attributeCombo.setAlignmentX(Component.LEFT_ALIGNMENT);
    attributeCombo.setPreferredSize(new Dimension(220, attributeCombo.getPreferredSize().height));
    attributeCombo.setMaximumSize(new Dimension(220, attributeCombo.getPreferredSize().height));
    attributePanel.add(attributeCombo);

    attributePanel.add(Box.createRigidArea(new Dimension(0, 10)));

    label = new JLabel("Edge Weight Attribute");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    attributePanel.add(label);

    weightCombo = new JComboBox<String>();
    weightCombo.addItem(NONE);
    for (String attribute : getAttributes(false)) {
      weightCombo.addItem(attribute);
    }
    weightCombo.setAlignmentX(Component.LEFT_ALIGNMENT);
    weightCombo.setPreferredSize(new Dimension(220, weightCombo.getPreferredSize().height));
    weightCombo.setMaximumSize(new Dimension(220, weightCombo.getPreferredSize().height));
    attributePanel.add(weightCombo);

    attributePanel.add(Box.createRigidArea(new Dimension(0, 10)));

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

    countRadio = new JRadioButton("Count");
    statisticsRadio = new JRadioButton("Statistics");
    groupButtons(countRadio, statisticsRadio);

    ActionListener radioListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateEnablement();
          }
        };

    countRadio.addActionListener(radioListener);
    statisticsRadio.addActionListener(radioListener);

    attributePanel.add(countRadio);
    attributePanel.add(statisticsRadio);

    attributePanel.add(Box.createRigidArea(new Dimension(0, 10)));

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

    removeSelfEdges = new JCheckBox("Remove self edges");
    singleNodesCheck = new JCheckBox("Include single nodes");

    attributePanel.add(removeSelfEdges);
    attributePanel.add(singleNodesCheck);

    return attributePanel;
  }
  private JToolBar makeToolBar() {
    JToolBar tool = new JToolBar();
    tool.setFloatable(false);

    // Setup the buttons
    save.setRequestFocusEnabled(false);
    tool.add(save);

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String[] fontNames = ge.getAvailableFontFamilyNames();
    tool.addSeparator();
    cbFonts = new JComboBox(fontNames);
    cbFonts.setRequestFocusEnabled(false);
    cbFonts.setMaximumSize(cbFonts.getPreferredSize());
    cbFonts.setEditable(true);
    ActionListener lst =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (fFamilyChange) {
              fFamilyChange = false;
              return;
            }
            editor.grabFocus();
            setSelectionAttribute(StyleConstants.Family, cbFonts.getSelectedItem().toString());
          }
        };

    cbFonts.addActionListener(lst);
    tool.add(cbFonts);
    tool.addSeparator();
    sSizes = new JSpinner(new SpinnerNumberModel(12, 1, 100, 1));
    sSizes.setRequestFocusEnabled(false);
    sSizes.setMaximumSize(sSizes.getPreferredSize());
    sSizes.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent arg0) {
            if (fSizeChange) {
              fSizeChange = false;
              return;
            }
            setSelectionAttribute(StyleConstants.Size, sSizes.getValue());
            editor.grabFocus();
          }
        });
    tool.add(sSizes);
    tool.addSeparator();

    tbBold = new JToggleButton(LGM.getIconForKey("GameInformationFrame.BOLD")); // $NON-NLS-1$
    tbBold.setRequestFocusEnabled(false);
    lst =
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            setSelectionAttribute(StyleConstants.Bold, tbBold.isSelected());
          }
        };
    tbBold.addActionListener(lst);
    tool.add(tbBold);
    tbItalic = new JToggleButton(LGM.getIconForKey("GameInformationFrame.ITALIC")); // $NON-NLS-1$
    tbItalic.setRequestFocusEnabled(false);
    lst =
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            setSelectionAttribute(StyleConstants.Italic, tbItalic.isSelected());
          }
        };
    tbItalic.addActionListener(lst);
    tool.add(tbItalic);
    tbUnderline =
        new JToggleButton(LGM.getIconForKey("GameInformationFrame.UNDERLINED")); // $NON-NLS-1$
    tbUnderline.setRequestFocusEnabled(false);
    lst =
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            setSelectionAttribute(StyleConstants.Underline, tbUnderline.isSelected());
          }
        };
    tbUnderline.addActionListener(lst);
    tool.add(tbUnderline);

    tool.addSeparator();
    JButton butFontColor =
        new JButton(LGM.getIconForKey("GameInformationFrame.FONTCOLOR")); // $NON-NLS-1$
    butFontColor.setRequestFocusEnabled(false);
    butFontColor.setActionCommand("GameInformationFrame.FONTCOLOR"); // $NON-NLS-1$
    butFontColor.addActionListener(this);
    tool.add(butFontColor);
    JButton but = new JButton(LGM.getIconForKey("GameInformationFrame.COLOR")); // $NON-NLS-1$
    but.setRequestFocusEnabled(false);
    but.setActionCommand("GameInformationFrame.COLOR"); // $NON-NLS-1$
    but.addActionListener(this);
    tool.add(but);
    return tool;
  }