예제 #1
0
  // This method is called when a cell value is edited by the user.
  public Component getTableCellEditorComponent(
      JTable table, Object value, boolean isSelected, int row, int column) {
    // Configure the component with the specified value
    if (!mitMaus) {
      ((JFormattedTextField) component).setText(String.valueOf(value));
      ((JFormattedTextField) component).selectAll();
      ((JFormattedTextField) component).setHorizontalAlignment(SwingConstants.RIGHT);
      ((JFormattedTextField) component).setBackground(Color.YELLOW);

    } else {
      final String xvalue = String.valueOf(value);
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              ((JFormattedTextField) component).setText(String.valueOf(xvalue).replace(".", ","));
              ((JFormattedTextField) component).selectAll();
              ((JFormattedTextField) component).setBackground(Color.YELLOW);
              ((JFormattedTextField) component).setHorizontalAlignment(SwingConstants.RIGHT);
              ((JFormattedTextField) component).setCaretPosition(0);
            }
          });
    }

    // Return the configured component
    //// System.out.println("I've been Called!!");
    return component;
  }
예제 #2
0
    /** Constructs cell editor. */
    public CellEditor() {
      super(new JFormattedTextField());
      final JFormattedTextField ftf = (JFormattedTextField) getComponent();

      // Set GUI behaviour of text field
      ftf.setValue(null);
      ftf.setHorizontalAlignment(JTextField.LEADING);
      ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);

      // Set that one click on cell is enough for editing
      setClickCountToStart(1);

      // Special handling code for ENTER
      ftf.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
      ftf.getActionMap()
          .put(
              "check",
              new AbstractAction() {
                public void actionPerformed(ActionEvent e) {
                  if (!ftf.isEditValid()) {
                    if (askEditOrRevert(ftf, null)) {
                      ftf.setValue(ftf.getValue());
                      ftf.postActionEvent();
                    }
                  } else
                    try {
                      ftf.commitEdit();
                      ftf.postActionEvent();
                    } catch (java.text.ParseException exc) {
                      // nothing to do
                    }
                }
              });
    }
  public TelaCadastrarConsulta(TelaPrincipal t) {
    initComponents();
    this.tp = t;

    // Spinner de Hora
    JSpinner.DateEditor editorHora = new JSpinner.DateEditor(spinHorario, "HH:mm");
    JFormattedTextField ftfHora = editorHora.getTextField();
    ftfHora.setEditable(false);
    ftfHora.setHorizontalAlignment(JTextField.CENTER);
    spinHorario.setEditor(editorHora);
  }
    public DateTimePropertyInputField(
        final Object value, final UpdateStatus status, final Color bgColor) {
      setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
      setBackground(bgColor);

      GregorianCalendar cal = (value == null ? new GregorianCalendar() : (GregorianCalendar) value);
      timezone = cal.getTimeZone();

      day = new SpinnerNumberModel(cal.get(Calendar.DATE), 1, 31, 1);
      addSpinner(new JSpinner(day), status);

      month = new SpinnerListModel(MONTH_STRINGS);
      month.setValue(MONTH_STRINGS[cal.get(Calendar.MONTH)]);
      JSpinner monthSpinner = new JSpinner(month);
      JComponent editor = monthSpinner.getEditor();
      if (editor instanceof JSpinner.DefaultEditor) {
        JFormattedTextField tf = ((JSpinner.DefaultEditor) editor).getTextField();
        tf.setColumns(6);
        tf.setHorizontalAlignment(JTextField.RIGHT);
      }
      addSpinner(monthSpinner, status);

      year = new SpinnerNumberModel(cal.get(Calendar.YEAR), 0, 9999, 1);
      JSpinner yearSpinner = new JSpinner(year);
      yearSpinner.setEditor(new JSpinner.NumberEditor(yearSpinner, "#"));
      yearSpinner.getEditor().setBackground(bgColor);
      addSpinner(yearSpinner, status);

      add(new JLabel("  "));

      hour = new SpinnerNumberModel(cal.get(Calendar.HOUR_OF_DAY), 0, 23, 1);
      JSpinner hourSpinner = new JSpinner(hour);
      addSpinner(hourSpinner, status);

      add(new JLabel(":"));

      min = new SpinnerNumberModel(cal.get(Calendar.MINUTE), 0, 59, 1);
      JSpinner minSpinner = new JSpinner(min);
      addSpinner(minSpinner, status);

      add(new JLabel(":"));

      sec = new SpinnerNumberModel(cal.get(Calendar.SECOND), 0, 59, 1);
      JSpinner secSpinner = new JSpinner(sec);
      addSpinner(secSpinner, status);

      add(new JLabel(" " + timezone.getDisplayName(true, TimeZone.SHORT)));
    }
예제 #5
0
파일: Case.java 프로젝트: Chaghall/Kakuro
  /**
   * Affiche les cases de la grille grâce à des JTextField pour les cases à remplir et des JLabel
   * pour les indices de somme dans le JPanel pan
   *
   * @param pan
   * @throws NumberFormatException
   */
  public void affichCase(JPanel pan) throws NumberFormatException {
    if (this.n != 0) {
      bloc.setValue(null);
      try {
        MaskFormatter format = new MaskFormatter("#");
        bloc = new JFormattedTextField(format);
      } catch (ParseException e2) {

      }
      pan.add(bloc);
      bloc.setHorizontalAlignment(SwingConstants.CENTER);
      bloc.addKeyListener(
          new KeyAdapter() {
            public void keyReleased(KeyEvent e) {
              try {
                if (Integer.valueOf(bloc.getText()) == n) {
                  Utilitaire.score -= juste;
                  juste = 1;
                  Utilitaire.score += juste;
                } else {
                  Utilitaire.score -= juste;
                  juste = 0;
                  Utilitaire.score += juste;
                }
              } catch (NumberFormatException e1) {

              }
            }
          });
    } else {
      Utilitaire.score -= juste;
      juste = 1;
      Utilitaire.score += juste;
      if (sX != 0)
        if (sY != 0) block.setText(String.format("%2d\\%2d", sX, sY));
        else block.setText(String.format("%2d\\  ", sX));
      else if (sY != 0) block.setText(String.format("  \\%2d", sY));

      block.setHorizontalAlignment(SwingConstants.CENTER);
      block.setBorder(null);
      block.setOpaque(true);
      block.setBackground(Color.BLACK);
      block.setForeground(Color.WHITE);
      pan.add(block);
    }
  }
예제 #6
0
  /**
   * Constructor con dos parámetros para definir los límites que queremos definirle al número a
   * ingresar.
   *
   * @param min (Float) Permite un NULL como valor lo que no definirá un valor para el límite
   *     inferior.
   * @param max (Float) Permite un NULL como valor lo que no definirá un valor para el límite
   *     superior.
   */
  public FloatEditor(Float min, Float max) {
    super(new JFormattedTextField(new DecimalFormat("####.##")));
    ftf = (JFormattedTextField) getComponent();
    this.minimum = min;
    this.maximum = max;

    // Set up the editor for the float cells.
    floatFormat = new DecimalFormat("####.##");
    NumberFormatter floatFormatter = new NumberFormatter(floatFormat);
    floatFormatter.setFormat(floatFormat);
    floatFormatter.setMinimum(minimum);
    floatFormatter.setMaximum(maximum);

    ftf.setFormatterFactory(new DefaultFormatterFactory(floatFormatter));
    ftf.setValue(minimum);
    ftf.setHorizontalAlignment(JTextField.TRAILING);
    ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);

    // React when the user presses Enter while the editor is
    // active.  (Tab is handled as specified by
    // JFormattedTextField's focusLostBehavior property.)
    ftf.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    ftf.getActionMap()
        .put(
            "check",
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent e) {
                if (!ftf.isEditValid()) { // The text is invalid.
                  if (userSaysRevert()) { // reverted
                    ftf.postActionEvent(); // inform the editor
                  }
                } else
                  try { // The text is valid,
                    ftf.commitEdit(); // so use it.
                    ftf.postActionEvent(); // stop editing
                  } catch (java.text.ParseException exc) {
                  }
              }
            });
  }
예제 #7
0
  private void createZoomTextField() {
    mZoomTextField = new JFormattedTextField(new DecimalFormat("##0.00%"));
    mZoomTextField.setFocusLostBehavior(JFormattedTextField.REVERT);
    mZoomTextField.setHorizontalAlignment(SwingConstants.CENTER);
    mZoomTextField.setColumns(6);
    mZoomTextField.setMinimumSize(mZoomTextField.getPreferredSize());

    mZoomTextField.addActionListener(
        (x) -> mImagePresentationModel.setZoom(((Number) mZoomTextField.getValue()).doubleValue()));

    mImagePresentationModel.addListener(
        new ImagePresentationModel.Listener() {
          @Override
          public void onVisibleImageContentUpdate() {
            mZoomTextField.setValue(mImagePresentationModel.getZoom());
          }

          @Override
          public void onImageChange() {
            onVisibleImageContentUpdate();
          }
        });
  }
예제 #8
0
  private void editSliderSample(MouseEvent evt, final int sliderIndex) {
    final PropertyContainer vc = new PropertyContainer();
    vc.addProperty(Property.create("sample", getSliderSample(sliderIndex)));
    vc.getDescriptor("sample").setDisplayName("sample");
    vc.getDescriptor("sample").setUnit(getModel().getParameterUnit());
    final ValueRange valueRange;
    if (sliderIndex == 0) {
      valueRange = new ValueRange(Double.NEGATIVE_INFINITY, round(getMaxSliderSample(sliderIndex)));
    } else if (sliderIndex == getSliderCount() - 1) {
      valueRange = new ValueRange(round(getMinSliderSample(sliderIndex)), Double.POSITIVE_INFINITY);
    } else {
      valueRange =
          new ValueRange(
              round(getMinSliderSample(sliderIndex)), round(getMaxSliderSample(sliderIndex)));
    }
    vc.getDescriptor("sample").setValueRange(valueRange);

    final BindingContext ctx = new BindingContext(vc);
    final NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0.0#"));
    formatter.setValueClass(Double.class); // to ensure that double values are returned
    final JFormattedTextField field = new JFormattedTextField(formatter);
    field.setColumns(11);
    field.setHorizontalAlignment(JFormattedTextField.RIGHT);
    ctx.bind("sample", field);

    showPopup(evt, field);

    ctx.addPropertyChangeListener(
        "sample",
        pce -> {
          hidePopup();
          setSliderSample(sliderIndex, (Double) ctx.getBinding("sample").getPropertyValue());
          computeZoomInToSliderLimits();
          applyChanges();
        });
  }
  /**
   * @param tf
   * @param format
   */
  public TableCellEditorForDezimal(final JFormattedTextField tf, final NumberFormat format) {
    super(tf);
    super.setClickCountToStart(1);
    tf.setFocusLostBehavior(JFormattedTextField.COMMIT);
    tf.setHorizontalAlignment(SwingConstants.LEFT);
    tf.setBorder(null);
    delegate =
        new EditorDelegate() {

          boolean isMousePressed = false;

          @Override
          public void setValue(Object param) {
            if (isMousePressed
                && param != null
                && (param.getClass() == Double.class || param.getClass() == BigDecimal.class)) {
              SwingUtilities.invokeLater(
                  new Runnable() {

                    public void run() {
                      tf.selectAll();
                    }
                  });
              try {
                tf.setText(
                    format == null
                        ? FormatNumber.formatDezimal((Number) param)
                        : format.format((Number) param));
              } catch (Exception e) {
                try {
                  param = new BigDecimal(String.valueOf(param));
                  tf.setText(
                      format == null
                          ? FormatNumber.formatDezimal((Number) param)
                          : format.format((Number) param));
                } catch (Exception ex) {
                  tf.setText(String.valueOf(param));
                }
              }
            } else {
              tf.setText("");
            }
          }

          @Override
          public Object getCellEditorValue() {
            try {
              String _field = tf.getText();
              Number _number =
                  (format == null ? FormatNumber.parseDezimal(_field) : format.parse(_field));
              if (_number != null) {
                double _parsed = _number.doubleValue();
                BigDecimal d = BigDecimal.valueOf(_parsed);
                //                        tf.setBackground(Color.white);
                return d;
              } else {
                //                        tf.setBackground(Color.white);
                return BigDecimal.ZERO;
              }
            } catch (ParseException e) {
              Log.Debug(this, e);
              //                    tf.setBackground(Color.red);
              return BigDecimal.ZERO;
            }
          }

          @Override
          public boolean isCellEditable(EventObject anEvent) {
            if (anEvent instanceof MouseEvent) {
              isMousePressed = true;
              return ((MouseEvent) anEvent).getClickCount() >= clickCountToStart;
            }
            isMousePressed = false;
            return true;
          }
        };
  }
예제 #10
0
파일: EditorPane.java 프로젝트: hencjo/jOOQ
 EditorPane(QueryExecutorCreator queryExecutorCreator) {
   super(new BorderLayout());
   this.queryExecutorCreator = queryExecutorCreator;
   setOpaque(false);
   JPanel northPanel = new JPanel(new BorderLayout());
   northPanel.setOpaque(false);
   JToolBar northWestPanel = new JToolBar();
   northWestPanel.setOpaque(false);
   northWestPanel.setFloatable(false);
   startButton =
       new JButton(
           new ImageIcon(getClass().getResource("/org/jooq/debug/console/resources/Play16.png")));
   startButton.setOpaque(false);
   startButton.setFocusable(false);
   //        startButton.setMargin(new Insets(2, 2, 2, 2));
   startButton.setToolTipText("Run the (selected) text (F5)");
   startButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           evaluateInternal();
         }
       });
   northWestPanel.add(startButton);
   stopButton =
       new JButton(
           new ImageIcon(getClass().getResource("/org/jooq/debug/console/resources/Stop16.png")));
   stopButton.setVisible(false);
   stopButton.setOpaque(false);
   stopButton.setFocusable(false);
   //        stopButton.setMargin(new Insets(2, 2, 2, 2));
   stopButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           closeLastExecution();
         }
       });
   northWestPanel.add(stopButton);
   northPanel.add(northWestPanel, BorderLayout.WEST);
   JPanel northEastPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 2));
   northEastPanel.setOpaque(false);
   JCheckBox limitCheckBox = new JCheckBox("Parse 10000 rows max", isUsingMaxRowCount);
   limitCheckBox.addItemListener(
       new ItemListener() {
         @Override
         public void itemStateChanged(ItemEvent e) {
           isUsingMaxRowCount = e.getStateChange() == ItemEvent.SELECTED;
         }
       });
   limitCheckBox.setOpaque(false);
   northEastPanel.add(limitCheckBox);
   northEastPanel.add(Box.createHorizontalStrut(5));
   northEastPanel.add(new JLabel("No display when rows >"));
   NumberFormat numberFormat = NumberFormat.getIntegerInstance();
   displayedRowCountField = new JFormattedTextField(numberFormat);
   displayedRowCountField.setHorizontalAlignment(JFormattedTextField.RIGHT);
   displayedRowCountField.setValue(100000);
   displayedRowCountField.setColumns(7);
   northEastPanel.add(displayedRowCountField);
   northPanel.add(northEastPanel, BorderLayout.CENTER);
   add(northPanel, BorderLayout.NORTH);
   editorTextArea = new SqlTextArea();
   editorTextArea.addKeyListener(
       new KeyAdapter() {
         @Override
         public void keyPressed(KeyEvent e) {
           boolean isControlDown = e.isControlDown();
           switch (e.getKeyCode()) {
             case KeyEvent.VK_SPACE:
               if (isControlDown) {
                 showCompletion();
               }
               break;
             case KeyEvent.VK_F5:
               if (startButton.isVisible()) {
                 evaluateInternal();
               }
               break;
             case KeyEvent.VK_ESCAPE:
               new Thread("SQLConsole - Interruption") {
                 @Override
                 public void run() {
                   closeLastExecution();
                 }
               }.start();
               break;
           }
         }
       });
   RTextScrollPane editorTextAreaScrollPane = new RTextScrollPane(editorTextArea);
   southPanel = new JPanel(new BorderLayout());
   southPanel.setOpaque(false);
   JSplitPane verticalSplitPane =
       new InvisibleSplitPane(
           JSplitPane.VERTICAL_SPLIT, true, editorTextAreaScrollPane, southPanel);
   verticalSplitPane.setOpaque(false);
   add(verticalSplitPane, BorderLayout.CENTER);
   verticalSplitPane.setDividerLocation(150);
 }
예제 #11
0
  /**
   * Creates the UI component. The enable state of the UI is controlled via the parameter <code>
   * disableUIProperty</code>. If it matches the value of the property provided in the constructor,
   * the UI will be disabled.
   *
   * @param disableUIProperty Controls the enable state of the UI.
   * @return The UI component.
   */
  public JPanel createBoundsInputPanel(boolean disableUIProperty) {
    final TableLayout layout = new TableLayout(9);
    layout.setTableAnchor(TableLayout.Anchor.WEST);
    layout.setTableFill(TableLayout.Fill.BOTH);
    layout.setTableWeightX(1.0);
    layout.setTableWeightY(1.0);
    layout.setTablePadding(3, 3);
    layout.setColumnWeightX(0, 0.0);
    layout.setColumnWeightX(1, 1.0);
    layout.setColumnWeightX(2, 0.0);
    layout.setColumnWeightX(3, 0.0);
    layout.setColumnWeightX(4, 1.0);
    layout.setColumnWeightX(5, 0.0);
    layout.setColumnWeightX(6, 0.0);
    layout.setColumnWeightX(7, 1.0);
    layout.setColumnWeightX(8, 0.0);
    layout.setColumnPadding(2, new Insets(3, 0, 3, 12));
    layout.setColumnPadding(5, new Insets(3, 0, 3, 12));
    final JPanel panel = new JPanel(layout);
    final DoubleFormatter doubleFormatter = new DoubleFormatter("###0.0##");
    pixelXUnit = new JLabel(NonSI.DEGREE_ANGLE.toString());
    pixelYUnit = new JLabel(NonSI.DEGREE_ANGLE.toString());

    panel.add(new JLabel("West:"));
    final JFormattedTextField westLonField = new JFormattedTextField(doubleFormatter);
    westLonField.setHorizontalAlignment(JTextField.RIGHT);
    bindingContext.bind(PROPERTY_WEST_BOUND, westLonField);
    bindingContext.bindEnabledState(
        PROPERTY_WEST_BOUND, false, enablePropertyKey, disableUIProperty);
    panel.add(westLonField);
    panel.add(new JLabel(NonSI.DEGREE_ANGLE.toString()));
    panel.add(new JLabel("East:"));
    final JFormattedTextField eastLonField = new JFormattedTextField(doubleFormatter);
    eastLonField.setHorizontalAlignment(JTextField.RIGHT);
    bindingContext.bind(PROPERTY_EAST_BOUND, eastLonField);
    bindingContext.bindEnabledState(
        PROPERTY_EAST_BOUND, false, enablePropertyKey, disableUIProperty);
    panel.add(eastLonField);
    panel.add(new JLabel(NonSI.DEGREE_ANGLE.toString()));
    panel.add(new JLabel("Pixel size X:"));
    pixelSizeXField = new JFormattedTextField(doubleFormatter);
    pixelSizeXField.setHorizontalAlignment(JTextField.RIGHT);
    bindingContext.bind(PROPERTY_PIXEL_SIZE_X, pixelSizeXField);
    bindingContext.bindEnabledState(
        PROPERTY_PIXEL_SIZE_X, false, enablePropertyKey, disableUIProperty);
    panel.add(pixelSizeXField);
    panel.add(pixelXUnit);

    panel.add(new JLabel("North:"));
    final JFormattedTextField northLatField = new JFormattedTextField(doubleFormatter);
    northLatField.setHorizontalAlignment(JTextField.RIGHT);
    bindingContext.bind(PROPERTY_NORTH_BOUND, northLatField);
    bindingContext.bindEnabledState(
        PROPERTY_NORTH_BOUND, false, enablePropertyKey, disableUIProperty);
    panel.add(northLatField);
    panel.add(new JLabel(NonSI.DEGREE_ANGLE.toString()));
    panel.add(new JLabel("South:"));
    final JFormattedTextField southLatField = new JFormattedTextField(doubleFormatter);
    southLatField.setHorizontalAlignment(JTextField.RIGHT);
    bindingContext.bind(PROPERTY_SOUTH_BOUND, southLatField);
    bindingContext.bindEnabledState(
        PROPERTY_SOUTH_BOUND, false, enablePropertyKey, disableUIProperty);
    panel.add(southLatField);
    panel.add(new JLabel(NonSI.DEGREE_ANGLE.toString()));
    panel.add(new JLabel("Pixel size Y:"));
    pixelSizeYField = new JFormattedTextField(doubleFormatter);
    pixelSizeYField.setHorizontalAlignment(JTextField.RIGHT);
    bindingContext.bind(PROPERTY_PIXEL_SIZE_Y, pixelSizeYField);
    bindingContext.bindEnabledState(
        PROPERTY_PIXEL_SIZE_Y, false, enablePropertyKey, disableUIProperty);
    panel.add(pixelSizeYField);
    panel.add(pixelYUnit);
    bindingContext.addProblemListener(
        new BindingProblemListener() {

          @Override
          public void problemReported(BindingProblem problem, BindingProblem ignored) {
            final String propertyName = problem.getBinding().getPropertyName();
            final boolean invalidBoundSet =
                propertyName.equals(PROPERTY_NORTH_BOUND)
                    || propertyName.equals(PROPERTY_EAST_BOUND)
                    || propertyName.equals(PROPERTY_SOUTH_BOUND)
                    || propertyName.equals(PROPERTY_WEST_BOUND);
            if (invalidBoundSet) {
              resetTextField(problem);
            }
          }

          private void resetTextField(BindingProblem problem) {
            problem.getBinding().getComponentAdapter().adjustComponents();
          }

          @Override
          public void problemCleared(BindingProblem ignored) {
            // do nothing
          }
        });
    return panel;
  }
예제 #12
0
  /** Initialize */
  @Override
  public void init() {
    //	Content
    MigLayout layout = new MigLayout("ins 0 0", "[fill|fill|fill|fill]", "[nogrid]unrel[||]");
    setLayout(layout);

    Font bigFont = AdempierePLAF.getFont_Field().deriveFont(16f);

    String buttonSize = "w 50!, h 50!,";
    // NEW
    f_bNew = createButtonAction("New", KeyStroke.getKeyStroke(KeyEvent.VK_F2, Event.F2));
    add(f_bNew, buttonSize);

    // EDIT
    f_bEdit = createButtonAction("Edit", null);
    add(f_bEdit, buttonSize);
    f_bEdit.setEnabled(false);

    // HISTORY
    f_history = createButtonAction("History", null);
    add(f_history, buttonSize);

    // CANCEL
    f_process = createButtonAction("Cancel", null);
    add(f_process, buttonSize);
    f_process.setEnabled(false);

    // PAYMENT
    f_cashPayment = createButtonAction("Payment", null);
    f_cashPayment.setActionCommand("Cash");
    add(f_cashPayment, buttonSize);
    f_cashPayment.setEnabled(false);

    // PRINT
    f_print = createButtonAction("Print", null);
    add(f_print, buttonSize);
    f_print.setEnabled(false);

    // Settings
    f_bSettings = createButtonAction("Preference", null);
    add(f_bSettings, buttonSize);

    //
    f_logout = createButtonAction("Logout", null);
    add(f_logout, buttonSize + ", gapx 25, wrap");

    // DOC NO
    add(new CLabel(Msg.getMsg(Env.getCtx(), "DocumentNo")), "");

    f_DocumentNo = new CTextField("");
    f_DocumentNo.setName("DocumentNo");
    f_DocumentNo.setEditable(false);
    add(f_DocumentNo, "growx, pushx");

    CLabel lNet = new CLabel(Msg.translate(Env.getCtx(), "SubTotal"));
    add(lNet, "");
    f_net = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
    f_net.setHorizontalAlignment(JTextField.TRAILING);
    f_net.setEditable(false);
    f_net.setFocusable(false);
    lNet.setLabelFor(f_net);
    add(f_net, "wrap, growx, pushx");
    f_net.setValue(Env.ZERO);
    //

    /*
    	// BPARTNER
    	f_bSearch = createButtonAction ("BPartner", KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.SHIFT_MASK+Event.CTRL_MASK));
    	add (f_bSearch,buttonSize + ", spany 2");
    */

    /*
     * f_name.setName("Name");
    f_name.addActionListener(this);
    f_name.addFocusListener(this);
    add (f_name, "wrap");
    */

    // SALES REP
    add(new CLabel(Msg.translate(Env.getCtx(), "SalesRep_ID")), "");
    f_RepName = new CTextField("");
    f_RepName.setName("SalesRep");
    f_RepName.setEditable(false);
    add(f_RepName, "growx, pushx");

    CLabel lTax = new CLabel(Msg.translate(Env.getCtx(), "TaxAmt"));
    add(lTax);
    f_tax = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
    f_tax.setHorizontalAlignment(JTextField.TRAILING);
    f_tax.setEditable(false);
    f_tax.setFocusable(false);
    lTax.setLabelFor(f_tax);
    add(f_tax, "wrap, growx, pushx");
    f_tax.setValue(Env.ZERO);
    //

    /*
    	f_location = new CComboBox();
    	add (f_location, " wrap");
    */

    // BP
    add(new CLabel(Msg.translate(Env.getCtx(), "C_BPartner_ID")), "");
    f_name = new CTextField();
    f_name.setEditable(false);
    f_name.setName("Name");
    add(f_name, "growx, pushx");

    //
    CLabel lTotal = new CLabel(Msg.translate(Env.getCtx(), "GrandTotal"));
    lTotal.setFont(bigFont);
    add(lTotal, "");
    f_total = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
    f_total.setHorizontalAlignment(JTextField.TRAILING);
    f_total.setFont(bigFont);
    f_total.setEditable(false);
    f_total.setFocusable(false);
    lTotal.setLabelFor(f_total);
    add(f_total, "growx, pushx");
    f_total.setValue(Env.ZERO);
    /*
    //
    f_user = new CComboBox();
    add (f_user, "skip 1");
    */
  } //	init
예제 #13
0
  public GUI() {

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

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

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

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

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

    stop.setEnabled(false);

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

    // Listener
    ButtonListener listener = new ButtonListener();

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

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

    carriers = new JComboBox<String>(options);

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

    JScrollPane scrollPane = new JScrollPane(results);

    results.setEditable(false);

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

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

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

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

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

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

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

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

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

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

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

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

    group6.add(remove);

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

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

    group5.add(interval);

    group7.add(show);

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

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

    // Setup frame
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menus);
    frame.add(scrollPane);
    frame.add(BorderLayout.EAST, panel);
    frame.pack();
    frame.setSize(new Dimension(670, 620));
    frame.setVisible(true);
  }
예제 #14
0
  /** make the view for this face */
  protected Component makeView() {
    final Box mainBox = new Box(BoxLayout.Y_AXIS);

    final JTable bpmTable = new JTable(BPM_TABLE_MODEL);

    final JSplitPane mainSplitPane =
        new JSplitPane(
            JSplitPane.VERTICAL_SPLIT, new JScrollPane(bpmTable), TARGET_PLOT.getPlotPanel());
    final Box mainSplitBox = new Box(BoxLayout.X_AXIS);
    mainSplitBox.add(mainSplitPane);
    mainBox.add(mainSplitBox);
    mainSplitPane.setOneTouchExpandable(true);
    mainSplitPane.addAncestorListener(
        new AncestorListener() {
          public void ancestorAdded(final AncestorEvent event) {
            // only set the divider location the first time it becomes visible
            if (mainSplitPane.getClientProperty("initialized") == null) {
              mainSplitPane.setDividerLocation(0.4);
              mainSplitPane.putClientProperty("initialized", true);
            }
          }

          public void ancestorRemoved(final AncestorEvent event) {}

          public void ancestorMoved(final AncestorEvent event) {}
        });

    final Box targetBox = new Box(BoxLayout.X_AXIS);
    mainBox.add(targetBox);
    targetBox.setBorder(BorderFactory.createTitledBorder("Target Beam Position"));

    final java.text.NumberFormat TARGET_NUMBER_FORMAT = new DecimalFormat("#,##0.0");
    final int NUMBER_WIDTH = 6;

    targetBox.add(new JLabel("X (mm):"));
    final JFormattedTextField xTargetField = new JFormattedTextField(TARGET_NUMBER_FORMAT);
    xTargetField.setToolTipText("Matching Target horizontal beam position");
    xTargetField.setEditable(false);
    xTargetField.setHorizontalAlignment(JTextField.RIGHT);
    xTargetField.setColumns(NUMBER_WIDTH);
    xTargetField.setMaximumSize(xTargetField.getPreferredSize());
    targetBox.add(xTargetField);

    targetBox.add(new JLabel("+/-"));
    final JFormattedTextField xTargetErrorField = new JFormattedTextField(TARGET_NUMBER_FORMAT);
    xTargetErrorField.setToolTipText("Estimated horizontal target beam position error.");
    xTargetErrorField.setEditable(false);
    xTargetErrorField.setHorizontalAlignment(JTextField.RIGHT);
    xTargetErrorField.setColumns(NUMBER_WIDTH);
    xTargetErrorField.setMaximumSize(xTargetErrorField.getPreferredSize());
    targetBox.add(xTargetErrorField);
    targetBox.add(Box.createHorizontalGlue());

    targetBox.add(new JLabel("Y (mm):"));
    final JFormattedTextField yTargetField = new JFormattedTextField(TARGET_NUMBER_FORMAT);
    yTargetField.setToolTipText("Matching Target vertical beam position");
    yTargetField.setEditable(false);
    yTargetField.setHorizontalAlignment(JTextField.RIGHT);
    yTargetField.setColumns(NUMBER_WIDTH);
    yTargetField.setMaximumSize(yTargetField.getPreferredSize());
    targetBox.add(yTargetField);

    targetBox.add(new JLabel("+/-"));
    final JFormattedTextField yTargetErrorField = new JFormattedTextField(TARGET_NUMBER_FORMAT);
    yTargetErrorField.setToolTipText("Estimated vertical target beam position error.");
    yTargetErrorField.setEditable(false);
    yTargetErrorField.setHorizontalAlignment(JTextField.RIGHT);
    yTargetErrorField.setColumns(NUMBER_WIDTH);
    yTargetErrorField.setMaximumSize(yTargetErrorField.getPreferredSize());
    targetBox.add(yTargetErrorField);
    targetBox.add(Box.createHorizontalGlue());

    final JButton clearButton = new JButton("Clear");
    clearButton.setToolTipText("Clear results and running average BPM statistics.");
    targetBox.add(clearButton);
    clearButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            TARGET_PLOT.clear();
            clearBeamPositionRunningAverage();
            xTargetField.setValue(null);
            xTargetErrorField.setValue(null);
            yTargetField.setValue(null);
            yTargetErrorField.setValue(null);
          }
        });

    final JButton startButton = new JButton("Start");
    startButton.setToolTipText("Start Beam Position Running Average after clearing it.");
    targetBox.add(startButton);
    startButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            for (final BpmAgent bpmAgent : BPM_AGENTS) {
              bpmAgent.startAveraging(); // automatically clears the running average each time
            }
          }
        });

    final JButton stopButton = new JButton("Stop");
    stopButton.setToolTipText("Stop Beam Position Running Average.");
    targetBox.add(stopButton);
    stopButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            stopRunningAverage();
          }
        });

    final JButton targetMatchButton = new JButton("Match");
    targetMatchButton.setToolTipText(
        "<html><body>Stop averaging the BPM beam position.<br>Match the target position to the BPM beam position data.</body></html>");
    targetBox.add(targetMatchButton);
    targetMatchButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            try {
              stopButton.doClick();

              final List<BpmAgent> enabledBpmAgents = BPM_TABLE_MODEL.getEnabledBpmAgents();
              final List<BpmAgent> xBpmAgents = new ArrayList<BpmAgent>(enabledBpmAgents.size());
              final List<BpmAgent> yBpmAgents = new ArrayList<BpmAgent>(enabledBpmAgents.size());
              final StringBuffer warningsBuffer = new StringBuffer("");

              if (enabledBpmAgents.size() < 2) {
                warningsBuffer.append(
                    "Only " + enabledBpmAgents.size() + " are enabled for matching.\n");
              }

              // only include BPM agents with running average samples for at least one valid channel
              for (final BpmAgent bpmAgent : enabledBpmAgents) {
                if (bpmAgent.hasRunningAverageSamplesInValidPlanes()) {
                  if (bpmAgent.isXAvgChannelValid()) {
                    xBpmAgents.add(bpmAgent);
                  } else {
                    warningsBuffer.append(
                        "Warning: Enabled BPM, "
                            + bpmAgent.name()
                            + " has an invalid X Avg channel, "
                            + bpmAgent.getXAvgChannel().channelName()
                            + " which will be exluded from analysis.\n");
                  }

                  if (bpmAgent.isYAvgChannelValid()) {
                    yBpmAgents.add(bpmAgent);
                  } else {
                    warningsBuffer.append(
                        "Warning: Enabled BPM, "
                            + bpmAgent.name()
                            + " has an invalid Y Avg channel, "
                            + bpmAgent.getYAvgChannel().channelName()
                            + " which will be exluded from analysis.\n");
                  }
                } else if (!bpmAgent.hasValidPlane()) {
                  warningsBuffer.append(
                      "Warning: Ignoring BPM, "
                          + bpmAgent.name()
                          + " because it has no valid X or Y channel.\n");
                } else {
                  warningsBuffer.append(
                      "Warning: Ignoring BPM, "
                          + bpmAgent.name()
                          + " because it has no samples in a valid channel.\n");
                }
              }

              // always post warnings to the console
              final String warningsMessage = warningsBuffer.toString();
              if (warningsMessage != null && warningsMessage.length() > 0) {
                System.out.print(warningsBuffer.toString());
              }

              // to match both X and Y, at least two BPMs must be valid for each of X and Y channels
              if (xBpmAgents.size() < 2 || yBpmAgents.size() < 2) {
                DOCUMENT.displayError(
                    "Matching Error",
                    "You must choose at least 2 BPMs that have valid channels for each plane.\n"
                        + warningsBuffer.toString());
                return;
              }

              if (_beamPositionMatcher == null) {
                _beamPositionMatcher = new TargetBeamPositionMatcher(RTBT_SEQUENCE);
              }
              final BeamPosition targetBeamPosition =
                  _beamPositionMatcher.getMatchingTargetBeamPosition(xBpmAgents, yBpmAgents);
              xTargetField.setValue(targetBeamPosition.X);
              xTargetErrorField.setValue(targetBeamPosition.X_RMS_ERROR);
              yTargetField.setValue(targetBeamPosition.Y);
              yTargetErrorField.setValue(targetBeamPosition.Y_RMS_ERROR);

              // update the main document so the values can be shared elsewhere
              DOCUMENT.xpos = targetBeamPosition.X;
              DOCUMENT.ypos = targetBeamPosition.Y;

              TARGET_PLOT.displayBeamPosition(
                  targetBeamPosition.X,
                  targetBeamPosition.Y,
                  targetBeamPosition.X_RMS_ERROR,
                  targetBeamPosition.Y_RMS_ERROR);
            } catch (Exception exception) {
              exception.printStackTrace();
              JOptionPane.showMessageDialog(
                  FACE_VIEW,
                  exception.getMessage(),
                  "Error matching target beam position.",
                  JOptionPane.ERROR_MESSAGE);
            }
          }
        });

    final JButton copyReportButton = new JButton("Report");
    copyReportButton.setToolTipText("Copy a report to the clipboard.");
    targetBox.add(copyReportButton);
    copyReportButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            final StringBuffer reportBuffer = new StringBuffer("Target Beam Position Report\n");
            reportBuffer.append(
                "Date:\t" + new SimpleDateFormat("MMM dd, yyyy HH:mm:ss").format(new Date()));
            reportBuffer.append("\n");
            reportBuffer.append("BPM Data:\n");
            BPM_TABLE_MODEL.appendReport(reportBuffer);
            reportBuffer.append(
                "Matching Target X (mm):\t"
                    + xTargetField.getText()
                    + "\t+/-\t"
                    + xTargetErrorField.getText()
                    + "\n");
            reportBuffer.append(
                "Matching Target Y (mm):\t"
                    + yTargetField.getText()
                    + "\t+/-\t"
                    + yTargetErrorField.getText()
                    + "\n");

            final String report = reportBuffer.toString();
            final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            final StringSelection contents = new StringSelection(report);
            clipboard.setContents(contents, contents);
          }
        });

    return mainBox;
  }
예제 #15
0
  /** Create the frame. */
  public GIncidencia() {

    setIconImage(
        Toolkit.getDefaultToolkit()
            .getImage(
                GIncidencia.class.getResource("/javax/swing/plaf/basic/icons/JavaCup16.png")));
    setResizable(false);
    setTitle("  Ingresar Nueva GIncidencia");
    setBounds(100, 100, 887, 575);
    getContentPane().setLayout(null);

    lblMensListado2 = new JLabel("");
    lblMensListado2.setFont(new Font("Tahoma", Font.PLAIN, 13));
    lblMensListado2.setVisible(false);
    lblMensListado2.setBounds(349, 64, 346, 19);
    getContentPane().add(lblMensListado2);

    lblMensListado1 = new JLabel("");
    lblMensListado1.setVisible(false);
    lblMensListado1.setFont(new Font("Tahoma", Font.PLAIN, 13));
    lblMensListado1.setBounds(10, 64, 319, 19);
    getContentPane().add(lblMensListado1);

    panel = new JPanel();
    panel.setVisible(false);
    panel.setBounds(10, 11, 319, 515);
    panel.setBackground(new Color(51, 102, 153));
    panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    getContentPane().add(panel);
    panel.setLayout(null);

    btnListado = new JButton("LISTAR");
    btnListado.setVisible(false);
    btnListado.setBackground(SystemColor.controlShadow);
    btnListado.addActionListener(this);
    btnListado.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource("/com/sun/java/swing/plaf/motif/icons/Warn.gif")));

    Incidencia = new JScrollPane();
    Incidencia.setVisible(false);
    Incidencia.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
    Incidencia.setBounds(339, 103, 522, 388);
    getContentPane().add(Incidencia);

    txtIncidencia = new JTextArea();
    txtIncidencia.setFont(new Font("Arial", Font.PLAIN, 17));
    txtIncidencia.setToolTipText("");
    Incidencia.setViewportView(txtIncidencia);

    btnLimpiar = new JButton("LIMPIAR");
    btnLimpiar.setVisible(false);

    btnBuscar = new JButton("BUSCAR");
    btnBuscar.setVisible(false);

    btnNuevo = new JButton("NUEVO");
    btnNuevo.setVisible(false);
    btnNuevo.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource("/com/sun/java/swing/plaf/windows/icons/File.gif")));
    btnNuevo.setBackground(SystemColor.controlShadow);
    btnNuevo.setBounds(339, 11, 228, 33);
    getContentPane().add(btnNuevo);

    btnNuevo.addActionListener(this);
    btnBuscar.setBackground(SystemColor.controlShadow);
    btnBuscar.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource("/com/sun/java/swing/plaf/windows/icons/Directory.gif")));
    btnBuscar.setBounds(339, 11, 228, 33);
    getContentPane().add(btnBuscar);
    btnBuscar.addActionListener(this);
    btnLimpiar.setIcon(
        new ImageIcon(GIncidencia.class.getResource("/javax/swing/plaf/metal/icons/sortDown.png")));
    btnLimpiar.setBackground(SystemColor.controlShadow);
    btnLimpiar.setBounds(633, 11, 228, 33);
    getContentPane().add(btnLimpiar);
    btnLimpiar.addActionListener(this);

    btnRegistrar = new JButton("REGISTRAR");
    btnRegistrar.setVisible(false);
    btnRegistrar.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource(
                "/com/sun/javafx/webkit/prism/resources/mediaPlayDisabled.png")));
    btnRegistrar.setBackground(SystemColor.controlShadow);
    btnRegistrar.setBounds(339, 55, 522, 37);
    getContentPane().add(btnRegistrar);
    btnRegistrar.addActionListener(this);

    btnModificar = new JButton("MODIFICAR");
    btnModificar.setVisible(false);
    btnModificar.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource(
                "/com/sun/javafx/scene/control/skin/caspian/dialog-more-details.png")));
    btnModificar.setBackground(SystemColor.controlShadow);
    btnModificar.setBounds(339, 55, 522, 37);
    getContentPane().add(btnModificar);
    btnModificar.addActionListener(this);
    btnListado.setBounds(10, 11, 260, 37);
    getContentPane().add(btnListado);

    JSeparator separator = new JSeparator();
    separator.setBounds(10, 111, 299, 7);
    panel.add(separator);

    JSeparator separator_1 = new JSeparator();
    separator_1.setBounds(10, 294, 299, 14);
    panel.add(separator_1);

    JLabel lblNewLabel = new JLabel("CODIGO DE USUARIO:");
    lblNewLabel.setForeground(Color.WHITE);
    lblNewLabel.setBounds(10, 36, 172, 14);
    panel.add(lblNewLabel);

    JLabel lblCodigo = new JLabel("CODIGO DE INCIDENCIA: ");
    lblCodigo.setForeground(Color.WHITE);
    lblCodigo.setBounds(10, 11, 172, 14);
    panel.add(lblCodigo);

    txtCodigo = new JTextField();
    txtCodigo.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtCodigo.setHorizontalAlignment(SwingConstants.RIGHT);
    txtCodigo.setBackground(SystemColor.controlShadow);
    txtCodigo.setEditable(false);
    txtCodigo.setBounds(203, 9, 106, 17);
    panel.add(txtCodigo);
    txtCodigo.setColumns(10);

    txtCodUsu = new JTextField();
    txtCodUsu.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtCodUsu.setHorizontalAlignment(SwingConstants.RIGHT);
    txtCodUsu.setBackground(SystemColor.controlShadow);
    txtCodUsu.setEditable(false);
    txtCodUsu.setColumns(10);
    txtCodUsu.setBounds(203, 34, 106, 17);
    panel.add(txtCodUsu);

    JLabel lblCodigoDeEspecialista = new JLabel("CODIGO DE ESPECIALISTA:");
    lblCodigoDeEspecialista.setForeground(Color.WHITE);
    lblCodigoDeEspecialista.setBounds(10, 61, 172, 14);
    panel.add(lblCodigoDeEspecialista);

    JLabel lblCodigoDeTipo = new JLabel("CODIGO DE TIPO DE INCIDENCIA:");
    lblCodigoDeTipo.setForeground(Color.WHITE);
    lblCodigoDeTipo.setBounds(10, 86, 188, 14);
    panel.add(lblCodigoDeTipo);

    JLabel lblDescripcion = new JLabel("DESCRIPCION:");
    lblDescripcion.setForeground(Color.WHITE);
    lblDescripcion.setBounds(10, 115, 110, 14);
    panel.add(lblDescripcion);

    JLabel lblComentariosObservaciones = new JLabel("COMENTARIOS / OBSERVACIONES:");
    lblComentariosObservaciones.setForeground(Color.WHITE);
    lblComentariosObservaciones.setBounds(10, 198, 188, 28);
    panel.add(lblComentariosObservaciones);

    JLabel lblTiempoEstimadoDe = new JLabel("TIEMPO ESTIMADO DE SOLUCION:");
    lblTiempoEstimadoDe.setForeground(Color.WHITE);
    lblTiempoEstimadoDe.setBounds(10, 309, 203, 14);
    panel.add(lblTiempoEstimadoDe);

    txtTiempoEstimado = new JTextField();
    txtTiempoEstimado.addKeyListener(this);
    txtTiempoEstimado.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtTiempoEstimado.setHorizontalAlignment(SwingConstants.RIGHT);
    txtTiempoEstimado.setColumns(10);
    txtTiempoEstimado.setBounds(215, 306, 94, 17);
    panel.add(txtTiempoEstimado);

    JLabel lblTiempoRealDe = new JLabel("TIEMPO REAL DE SOLUCION:");
    lblTiempoRealDe.setForeground(Color.WHITE);
    lblTiempoRealDe.setBounds(10, 337, 172, 14);
    panel.add(lblTiempoRealDe);

    txtTiempoReal = new JTextField();
    txtTiempoReal.addKeyListener(this);
    txtTiempoReal.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtTiempoReal.setHorizontalAlignment(SwingConstants.RIGHT);
    txtTiempoReal.setColumns(10);
    txtTiempoReal.setBounds(215, 334, 94, 17);
    panel.add(txtTiempoReal);

    JLabel lblFechaDeRegistro = new JLabel("FECHA DE REGISTRO:");
    lblFechaDeRegistro.setForeground(Color.WHITE);
    lblFechaDeRegistro.setBounds(10, 365, 172, 14);
    panel.add(lblFechaDeRegistro);

    txtFecRegistro = new JTextField();
    txtFecRegistro.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtFecRegistro.setHorizontalAlignment(SwingConstants.RIGHT);
    txtFecRegistro.setBackground(SystemColor.controlShadow);
    txtFecRegistro.setEditable(false);
    txtFecRegistro.setColumns(10);
    txtFecRegistro.setBounds(181, 362, 128, 17);
    panel.add(txtFecRegistro);

    JLabel lblFechaDeInicio = new JLabel("FECHA DE INICIO DE ATENCION:");
    lblFechaDeInicio.setForeground(Color.WHITE);
    lblFechaDeInicio.setBounds(10, 393, 188, 14);
    panel.add(lblFechaDeInicio);

    try {
      MaskFormatter mascara = new MaskFormatter("##-##-####");
      mascara.setPlaceholderCharacter(' ');
      txtFecInicio = new JFormattedTextField(mascara);
      txtFecInicio.setHorizontalAlignment(SwingConstants.RIGHT);
      txtFecInicio.setFont(new Font("Tahoma", Font.PLAIN, 13));
      txtFecInicio.setBounds(215, 390, 100, 17);
      panel.add(txtFecInicio);
    } catch (Exception e) {
      e.printStackTrace();
    }

    JLabel lblFechaDeFin = new JLabel("FECHA FINAL DE ATENCION:");
    lblFechaDeFin.setForeground(Color.WHITE);
    lblFechaDeFin.setBounds(10, 421, 172, 14);
    panel.add(lblFechaDeFin);

    try {
      MaskFormatter mascara = new MaskFormatter("##-##-####");
      mascara.setPlaceholderCharacter(' ');
      txtFecFinal = new JFormattedTextField(mascara);
      txtFecFinal.setHorizontalAlignment(SwingConstants.RIGHT);
      txtFecFinal.setFont(new Font("Tahoma", Font.PLAIN, 13));
      txtFecFinal.setBounds(215, 418, 100, 17);
      panel.add(txtFecFinal);
    } catch (Exception e) {
      e.printStackTrace();
    }

    JLabel lblEstado = new JLabel("ESTADO:");
    lblEstado.setForeground(Color.WHITE);
    lblEstado.setBounds(10, 449, 86, 14);
    panel.add(lblEstado);

    cboEstado = new JComboBox();
    cboEstado.setFont(new Font("Tahoma", Font.PLAIN, 13));
    cboEstado.setBackground(UIManager.getColor("Button.background"));
    cboEstado.setModel(
        new DefaultComboBoxModel(new String[] {"Registrada", "Iniciada", "Cancelada", "Cerrada"}));
    cboEstado.setBounds(137, 446, 172, 20);
    panel.add(cboEstado);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(10, 129, 299, 69);
    panel.add(scrollPane_1);

    txtDescripcion = new JTextArea();
    txtDescripcion.addKeyListener(this);
    txtDescripcion.setFont(new Font("Arial", Font.PLAIN, 19));
    scrollPane_1.setViewportView(txtDescripcion);

    JScrollPane scrollPane_2 = new JScrollPane();
    scrollPane_2.setBounds(10, 220, 299, 69);
    panel.add(scrollPane_2);

    txtObservacion = new JTextArea();
    txtObservacion.addKeyListener(this);
    txtObservacion.setFont(new Font("Arial", Font.PLAIN, 19));
    scrollPane_2.setViewportView(txtObservacion);

    cboEspecialista = new JComboBox();
    cboEspecialista.setFont(new Font("Tahoma", Font.PLAIN, 13));
    cboEspecialista.setBounds(203, 58, 106, 20);
    cboEspecialista.addItem("");
    panel.add(cboEspecialista);

    cboTipoInc = new JComboBox();
    cboTipoInc.setFont(new Font("Tahoma", Font.PLAIN, 13));
    cboTipoInc.setBounds(203, 83, 106, 20);
    cboTipoInc.addItem("");
    panel.add(cboTipoInc);

    btnImprimir = new JButton("IMPRIMIR");
    btnImprimir.addActionListener(this);
    btnImprimir.setIcon(
        new ImageIcon(GIncidencia.class.getResource("/sun/print/resources/orientLandscape.png")));
    btnImprimir.setBounds(633, 493, 228, 33);
    getContentPane().add(btnImprimir);

    Listado = new JScrollPane(TablaIncidencias);
    Listado.setVisible(false);
    Listado.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
    JViewport viewport = new JViewport();
    Listado.setRowHeaderView(viewport);
    Listado.setBounds(10, 99, 861, 347);
    getContentPane().add(Listado);

    TablaIncidencias = new JTable();
    TablaIncidencias.setFont(new Font("Tahoma", Font.PLAIN, 13));
    TablaIncidencias.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    Listado.setViewportView(TablaIncidencias);
    columnas();
    tamañoColumnas();

    llenaCampos();
  }
예제 #16
0
  @Override
  public JComponent createControl() {
    layerCanvasModelChangeChangeHandler = new LayerCanvasModelChangeHandler();
    productNodeChangeHandler = createProductNodeListener();
    cursorSynchronizer = new CursorSynchronizer(VisatApp.getApp());

    final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.ENGLISH);
    scaleFormat = new DecimalFormat("#####.##", decimalFormatSymbols);
    scaleFormat.setGroupingUsed(false);
    scaleFormat.setDecimalSeparatorAlwaysShown(false);

    zoomInButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomIn24.gif"), false);
    zoomInButton.setToolTipText("Zoom in."); /*I18N*/
    zoomInButton.setName("zoomInButton");
    zoomInButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            zoom(getCurrentView().getZoomFactor() * 1.2);
          }
        });

    zoomOutButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomOut24.gif"), false);
    zoomOutButton.setName("zoomOutButton");
    zoomOutButton.setToolTipText("Zoom out."); /*I18N*/
    zoomOutButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            zoom(getCurrentView().getZoomFactor() / 1.2);
          }
        });

    zoomDefaultButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomPixel24.gif"), false);
    zoomDefaultButton.setToolTipText("Actual Pixels (image pixel = view pixel)."); /*I18N*/
    zoomDefaultButton.setName("zoomDefaultButton");
    zoomDefaultButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            zoomToPixelResolution();
          }
        });

    zoomAllButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomAll24.gif"), false);
    zoomAllButton.setName("zoomAllButton");
    zoomAllButton.setToolTipText("Zoom all."); /*I18N*/
    zoomAllButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            zoomAll();
          }
        });

    syncViewsButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/SyncViews24.png"), true);
    syncViewsButton.setToolTipText("Synchronise compatible product views."); /*I18N*/
    syncViewsButton.setName("syncViewsButton");
    syncViewsButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            maybeSynchronizeCompatibleProductViews();
          }
        });

    syncCursorButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/SyncCursor24.png"), true);
    syncCursorButton.setToolTipText("Synchronise cursor position."); /*I18N*/
    syncCursorButton.setName("syncCursorButton");
    syncCursorButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            cursorSynchronizer.setEnabled(syncCursorButton.isSelected());
          }
        });

    AbstractButton helpButton =
        ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help24.gif"), false);
    helpButton.setToolTipText("Help."); /*I18N*/
    helpButton.setName("helpButton");

    final JPanel eastPane = GridBagUtils.createPanel();
    final GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;

    gbc.gridy = 0;
    eastPane.add(zoomInButton, gbc);

    gbc.gridy++;
    eastPane.add(zoomOutButton, gbc);

    gbc.gridy++;
    eastPane.add(zoomDefaultButton, gbc);

    gbc.gridy++;
    eastPane.add(zoomAllButton, gbc);

    gbc.gridy++;
    eastPane.add(syncViewsButton, gbc);

    gbc.gridy++;
    eastPane.add(syncCursorButton, gbc);

    gbc.gridy++;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.VERTICAL;
    eastPane.add(new JLabel(" "), gbc); // filler
    gbc.fill = GridBagConstraints.NONE;
    gbc.weighty = 0.0;

    gbc.gridy++;
    eastPane.add(helpButton, gbc);

    zoomFactorField = new JTextField();
    zoomFactorField.setColumns(8);
    zoomFactorField.setHorizontalAlignment(JTextField.CENTER);
    zoomFactorField.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            handleZoomFactorFieldUserInput();
          }
        });
    zoomFactorField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(final FocusEvent e) {
            handleZoomFactorFieldUserInput();
          }
        });

    rotationAngleSpinner = new JSpinner(new SpinnerNumberModel(0.0, -1800.0, 1800.0, 5.0));
    final JSpinner.NumberEditor editor = (JSpinner.NumberEditor) rotationAngleSpinner.getEditor();
    rotationAngleField = editor.getTextField();
    final DecimalFormat rotationFormat;
    rotationFormat = new DecimalFormat("#####.##", decimalFormatSymbols);
    rotationFormat.setGroupingUsed(false);
    rotationFormat.setDecimalSeparatorAlwaysShown(false);
    rotationAngleField.setFormatterFactory(
        new JFormattedTextField.AbstractFormatterFactory() {
          @Override
          public JFormattedTextField.AbstractFormatter getFormatter(JFormattedTextField tf) {
            return new NumberFormatter(rotationFormat);
          }
        });
    rotationAngleField.setColumns(6);
    rotationAngleField.setEditable(true);
    rotationAngleField.setHorizontalAlignment(JTextField.CENTER);
    rotationAngleField.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            handleRotationAngleFieldUserInput();
          }
        });
    rotationAngleField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent e) {
            handleRotationAngleFieldUserInput();
          }
        });
    rotationAngleField.addPropertyChangeListener(
        "value",
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            handleRotationAngleFieldUserInput();
          }
        });

    zoomSlider = new JSlider(JSlider.HORIZONTAL);
    zoomSlider.setValue(0);
    zoomSlider.setMinimum(MIN_SLIDER_VALUE);
    zoomSlider.setMaximum(MAX_SLIDER_VALUE);
    zoomSlider.setPaintTicks(false);
    zoomSlider.setPaintLabels(false);
    zoomSlider.setSnapToTicks(false);
    zoomSlider.setPaintTrack(true);
    zoomSlider.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(final ChangeEvent e) {
            if (!inUpdateMode) {
              zoom(sliderValueToZoomFactor(zoomSlider.getValue()));
            }
          }
        });

    final JPanel zoomFactorPane = new JPanel(new BorderLayout());
    zoomFactorPane.add(zoomFactorField, BorderLayout.WEST);

    final JPanel rotationAnglePane = new JPanel(new BorderLayout());
    rotationAnglePane.add(rotationAngleSpinner, BorderLayout.EAST);
    rotationAnglePane.add(new JLabel(" "), BorderLayout.CENTER);

    final JPanel sliderPane = new JPanel(new BorderLayout(2, 2));
    sliderPane.add(zoomFactorPane, BorderLayout.WEST);
    sliderPane.add(zoomSlider, BorderLayout.CENTER);
    sliderPane.add(rotationAnglePane, BorderLayout.EAST);

    canvas = createNavigationCanvas();
    canvas.setBackground(new Color(138, 133, 128)); // image background
    canvas.setForeground(new Color(153, 153, 204)); // slider overlay

    final JPanel centerPane = new JPanel(new BorderLayout(4, 4));
    centerPane.add(BorderLayout.CENTER, canvas);
    centerPane.add(BorderLayout.SOUTH, sliderPane);

    final JPanel mainPane = new JPanel(new BorderLayout(8, 8));
    mainPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPane.add(centerPane, BorderLayout.CENTER);
    mainPane.add(eastPane, BorderLayout.EAST);

    mainPane.setPreferredSize(new Dimension(320, 320));

    if (getDescriptor().getHelpId() != null) {
      HelpSys.enableHelpOnButton(helpButton, getDescriptor().getHelpId());
      HelpSys.enableHelpKey(mainPane, getDescriptor().getHelpId());
    }

    setCurrentView(VisatApp.getApp().getSelectedProductSceneView());

    updateState();

    // Add an internal frame listener to VISAT so that we can update our
    // navigation window with the information of the currently activated
    // product scene view.
    //
    VisatApp.getApp().addInternalFrameListener(new NavigationIFL());

    return mainPane;
  }
예제 #17
0
  Liqui(Connection LoginCN) {
    cn = LoginCN;
    liquiwindow = new JFrame("Liquistatus");
    liquiwindow.setSize(800, 560);
    liquiwindow.setLocation(200, 200);
    liquiwindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    liquiwindow.setLayout(null);
    liquiwindow.setResizable(false);

    // schriftenfestlegungen
    fontTxtFields = new Font("Arial", Font.PLAIN, 16);
    fontCmbBoxes = new Font("Arial", Font.PLAIN, 16);
    fontLists = new Font("Arial", Font.PLAIN, 10);

    pnlAbrMonat = new JPanel();
    pnlAbrMonat.setLayout(null);
    pnlAbrMonat.setBounds(30, 30, 150, 60);
    pnlAbrMonat.setBorder(new TitledBorder("Abrechnungsmonat"));
    // inhalt fuer Panel AbrMonat erstellen
    try {
      txtAbrMonat = new JFormattedTextField(new MaskFormatter("01-##-20##"));
    } catch (ParseException e1) {
      e1.printStackTrace();
    }
    txtAbrMonat.setBounds(20, 25, 110, 25);
    txtAbrMonat.setHorizontalAlignment(JFormattedTextField.RIGHT);
    txtAbrMonat.setFont(fontTxtFields);
    txtAbrMonat.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent ke) {}

          @Override
          public void keyReleased(KeyEvent ke) {
            if (ke.getKeyCode() == KeyEvent.VK_ENTER
                && Pattern.matches("\\d{2}.\\d{2}.[1-9]{1}\\d{3}", txtAbrMonat.getText())) {
              txtHinweis.setText(""); // clear txtHinweis Field
              lstModelAllIncome.clear(); // clear form old values from the previos call
              cmbModelPerson.removeAllElements(); // clear befor put new elements in to it
              calculate_profit(BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0));
              putPersonNameToCmbPerson();
              putIncomeToListAllIncome(BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0));

              // check if the actual liquimonth is already fix and it is so, then set the buttons,
              // who put and remove
              // incomes to and from persons, inactive
              if (is_liqui_fix(BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0))) {
                btnAdd.setEnabled(false);
                btnRemove.setEnabled(false);
              } else {
                btnAdd.setEnabled(true);
                btnRemove.setEnabled(true);
              }
            }
          }

          @Override
          public void keyPressed(KeyEvent ke) {}
        });
    // inhalte fuer das Panel AbrMonat auf selbiges legen
    pnlAbrMonat.add(txtAbrMonat);

    pnlRestwert = new JPanel();
    pnlRestwert.setLayout(null);
    pnlRestwert.setBounds(30, 115, 150, 60);
    pnlRestwert.setBorder(new TitledBorder("Monatsrestwert"));
    // inhalt fuer Panel Restwert erstellen
    txtNutzBetr = new JFormattedTextField(new NumberFormatter(new DecimalFormat("#,##0.00")));
    txtNutzBetr.setBounds(20, 25, 110, 25);
    txtNutzBetr.setHorizontalAlignment(JFormattedTextField.RIGHT);
    txtNutzBetr.setFont(fontTxtFields);
    txtNutzBetr.setText("0,00");
    txtNutzBetr.addFocusListener(
        new FocusListener() {
          public void focusLost(FocusEvent fe) {}

          public void focusGained(FocusEvent fe) {
            txtNutzBetr.selectAll();
          }
        });
    // inhalte fuer das Panel AbrMonat auf selbiges legen
    pnlRestwert.add(txtNutzBetr);

    // Textfeld fuer Hinweise zum errechneten Betrag
    txtHinweis = new JTextArea();
    txtHinweis.setBounds(195, 30, 230, 205);
    txtHinweis.setBorder(BorderFactory.createEtchedBorder());
    txtHinweis.setEditable(false); // infos sollen nur vom Programm gesetzt werden

    // Bereich fuer die Einnahmenaufteilung anlegen
    pnlEinahmenAufteilung = new JPanel();
    pnlEinahmenAufteilung.setLayout(null);
    pnlEinahmenAufteilung.setBounds(30, 240, 640, 300);
    pnlEinahmenAufteilung.setBorder(new TitledBorder("Einnahmenaufteilung"));
    // elemente fuer die Einnahmenaufteilung anlegen
    lblPerson = new JLabel("Person");
    lblPerson.setBounds(20, 25, 110, 25);

    cmbModelPerson = new DefaultComboBoxModel<String>();
    cmbPerson = new JComboBox<String>(cmbModelPerson);
    cmbPerson.setBounds(130, 25, 170, 25);
    cmbPerson.setFont(fontCmbBoxes);
    cmbPerson.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == 1) {
              // clear the List IncomePerPerson when Person is changed (to another or to nothing)
              lstModelIncomePerPerson.clear();

              if (cmbPerson.getSelectedIndex() > 0) {
                // extract personen_id from selected Value
                String selectedValue = cmbPerson.getSelectedItem().toString();
                Integer personen_id =
                    Integer.valueOf(
                        selectedValue.substring(
                            selectedValue.indexOf("(") + 1, selectedValue.indexOf(")")));

                // fill lstIncomePerPerson
                getIncomeForSelectedPerson(
                    personen_id, BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0));
              }
            }
          }
        });

    // Scrollliste der gesammten Einnahmen
    lstModelAllIncome = new DefaultListModel<String>();

    lstAllIncome = new JList<String>(lstModelAllIncome);
    lstAllIncome.setFont(fontLists);
    lstAllIncome.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseExited(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {}

          @Override
          public void mouseClicked(MouseEvent e) {
            // do someone only when elements exist
            if (lstModelAllIncome.getSize() > 0) {
              String elementValue = lstModelAllIncome.getElementAt(lstAllIncome.getSelectedIndex());
              lblBuchtext.setToolTipText(
                  getBuchText(
                      elementValue.substring(
                          elementValue.indexOf("(") + 1, elementValue.indexOf(")"))));

              // chek if a splitted part of the transaktions_id of the selectet Value is already put
              // to a
              // person, if it is so, the checkbox split must checked and protect against unchecked
              if (existSplittedPartInIpp(
                  elementValue.substring(
                      elementValue.indexOf("(") + 1, elementValue.indexOf(")")))) {
                chkAufteilung.setSelected(true);
                chkAufteilung.setEnabled(false);
              } else {
                chkAufteilung.setSelected(false);
                chkAufteilung.setEnabled(true);
              }
            }
          }
        });

    spAllIncome = new JScrollPane(lstAllIncome);
    spAllIncome.setBounds(20, 65, 100, 205);

    // scrollliste der einnahmen pro Person
    lstModelIncomePerPerson = new DefaultListModel<String>();

    lstIncomPerPerson = new JList<String>(lstModelIncomePerPerson);
    lstIncomPerPerson.setFont(fontLists);

    spIncomePerPerson = new JScrollPane(lstIncomPerPerson);
    spIncomePerPerson.setBounds(220, 65, 100, 205);

    // checkbox fuer die Aufteilungskennzeichnung
    chkAufteilung = new JCheckBox("Split", false);
    chkAufteilung.setBounds(145, 70, 60, 30);

    // Buttons fuer das hinzufuegen und entfernen der Betraege zu den Personen
    btnAdd = new JButton(">>");
    btnAdd.setBounds(145, 130, 60, 20);
    btnAdd.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Integer AllIncomeSelectedIndex;
            Integer PersonSelectedIndex;

            // note important selected Index
            AllIncomeSelectedIndex = lstAllIncome.getSelectedIndex();
            PersonSelectedIndex = cmbPerson.getSelectedIndex();

            // move the selected field from lstAllIncome to lstIncomePerPerson
            if (AllIncomeSelectedIndex >= 0 && PersonSelectedIndex >= 1) {
              // note some selected Values
              String selectedValue = cmbPerson.getSelectedItem().toString();
              Integer personen_id =
                  Integer.valueOf(
                      selectedValue.substring(
                          selectedValue.indexOf("(") + 1, selectedValue.indexOf(")")));

              // get Selected Value from the AllIncomeList
              String selectedAmountWithKey = lstModelAllIncome.getElementAt(AllIncomeSelectedIndex);

              // extract transaktions_id from the selected Amountvalue
              Integer transaktions_id =
                  Integer.valueOf(
                      selectedAmountWithKey.substring(
                          selectedAmountWithKey.indexOf("(") + 1,
                          selectedAmountWithKey.indexOf(")")));
              String sAmount =
                  selectedAmountWithKey.substring(0, selectedAmountWithKey.indexOf(" ("));

              // check if Amount have to split and get the Person_id who get the splited Amount
              if (chkAufteilung.isSelected()) {
                String AmountPart =
                    JOptionPane.showInputDialog(
                        "Bitte den Teilbetrag von " + sAmount + " eingeben:", sAmount);
                AmountPart = AmountPart.replace(",", ".");
                if (AmountPart.matches("^[0-9]+(\\.[0-9]{1,2})?$")) {
                  lstModelIncomePerPerson.insertElementAt(
                      AmountPart + " (" + transaktions_id + ")", lstModelIncomePerPerson.getSize());

                  // remove old Amount Value from List AllIncome
                  lstModelAllIncome.remove(AllIncomeSelectedIndex);

                  // calculate the diffrence between Old Amount and the AmountPart
                  Float AmountAllIncomeNew = Float.valueOf(sAmount) - Float.valueOf(AmountPart);

                  // put difference in the List AllIncome if it greater then zero
                  if (AmountAllIncomeNew > 0)
                    lstModelAllIncome.insertElementAt(
                        AmountAllIncomeNew.toString() + " (" + transaktions_id + ")",
                        lstModelAllIncome.getSize());

                  // put AmountPart in the IPP Table
                  pushAmountToTableIPP(AmountPart, transaktions_id, personen_id, "true");
                } else {
                  JOptionPane.showMessageDialog(
                      liquiwindow,
                      "Eingabe ist kein gültiger Zahlwert! Der Gesamtbetrag wird genommen.");
                  lstModelIncomePerPerson.insertElementAt(
                      selectedAmountWithKey, lstModelIncomePerPerson.getSize());
                  lstModelAllIncome.remove(AllIncomeSelectedIndex);
                  pushAmountToTableIPP(sAmount, transaktions_id, personen_id, "false");
                }
              } else {
                lstModelIncomePerPerson.insertElementAt(
                    selectedAmountWithKey, lstModelIncomePerPerson.getSize());
                lstModelAllIncome.remove(AllIncomeSelectedIndex);
                pushAmountToTableIPP(sAmount, transaktions_id, personen_id, "false");
              }
            }
          }
        });

    btnRemove = new JButton("<<");
    btnRemove.setBounds(145, 175, 60, 20);
    btnRemove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Integer IncomePerPersonSelectedIndex;
            Integer PersonSelectedIndex;
            Boolean transaktions_id_is_in_elements = false;
            int eID =
                0; // counter for the elements in the Enumeration to find an element with the same
                   // transaktions_id

            // note important selected Indexes
            IncomePerPersonSelectedIndex = lstIncomPerPerson.getSelectedIndex();
            PersonSelectedIndex = cmbPerson.getSelectedIndex();

            // move the selected field from lstIncomePerPerson to lstAllIncome
            if (IncomePerPersonSelectedIndex >= 0 && PersonSelectedIndex >= 1) {
              String selectedPersonAmountWithKey =
                  lstModelIncomePerPerson.getElementAt(IncomePerPersonSelectedIndex);

              // note the transaktions_id from the selectet Value at the right site
              String transaktions_id_right_site =
                  selectedPersonAmountWithKey.substring(
                      selectedPersonAmountWithKey.indexOf("(") + 1,
                      selectedPersonAmountWithKey.indexOf(")"));

              // check if the transaktions_id from the element that remove from the
              // IncomPerPerson List at the right site, is alredy in the list AllIncome at the
              // left Site. If it is so, then we must add the amount of the elements at the left
              // side to the right
              // where the transaktions_id is the same
              Enumeration<String> e = lstModelAllIncome.elements();

              while (e.hasMoreElements() && !transaktions_id_is_in_elements) {
                // note the actual Elemant in the Enumeration
                String actualElement = e.nextElement().toString();

                // note the transaktions_id from the actual element at the left site
                String transaktions_id_left_site =
                    actualElement.substring(
                        actualElement.indexOf("(") + 1, actualElement.indexOf(")"));

                if (transaktions_id_right_site.equals(transaktions_id_left_site)) {
                  // we need not look further and set transaktions_id_is_in_elements to true
                  // that will break the while loop
                  transaktions_id_is_in_elements = true;
                } else {
                  transaktions_id_is_in_elements = false;
                  eID++;
                }
              }

              if (transaktions_id_is_in_elements) {
                // if found an element with the same id in the left field, add the amount of the
                // removed
                // element at the right site, to the amount of the found element and put the result
                // at the end of the listAllIncome

                // note the two Amounts that have to add
                String AmountFromRightSite =
                    selectedPersonAmountWithKey.substring(
                        0, selectedPersonAmountWithKey.indexOf(" ("));
                String AmountFromLeftSite =
                    lstModelAllIncome
                        .getElementAt(eID)
                        .substring(0, lstModelAllIncome.getElementAt(eID).indexOf(" ("));
                Float newAmount =
                    Float.valueOf(AmountFromRightSite) + Float.valueOf(AmountFromLeftSite);

                // remove the element at the right and the left site
                lstModelIncomePerPerson.remove(IncomePerPersonSelectedIndex);
                lstModelAllIncome.remove(eID);

                // put the new build Element to the left site
                lstModelAllIncome.insertElementAt(
                    newAmount + " (" + transaktions_id_right_site + ")",
                    lstModelAllIncome.getSize());
              } else {
                // if not found, only put the removed Elemnt to the end of the List at the left site
                lstModelAllIncome.insertElementAt(
                    selectedPersonAmountWithKey, lstModelAllIncome.getSize());
                lstModelIncomePerPerson.remove(IncomePerPersonSelectedIndex);
              }

              // delete the moved Amount in the Table ipp for the selected Person
              String selectedValue = cmbPerson.getSelectedItem().toString();
              Integer personen_id =
                  Integer.valueOf(
                      selectedValue.substring(
                          selectedValue.indexOf("(") + 1, selectedValue.indexOf(")")));
              deleteAmountFromTableIPP(selectedPersonAmountWithKey, personen_id);
            }
          }
        });

    lblBuchtext = new JLabel("Buchungstext (Tooltip)");
    lblBuchtext.setBounds(20, 275, 300, 20);

    btnCalcPercentualPortion = new JButton("Anteilberechnung");
    btnCalcPercentualPortion.setBounds(330, 65, 160, 20);
    btnCalcPercentualPortion.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            int personCount;
            double[] PersonAmount;
            double TotalPersonAmount = 0;

            // clear the infotextfield
            txtHinweisAufteilung.setText("");

            // note the amount of person in the cmb box person
            // the first entry is not a person
            personCount = cmbModelPerson.getSize() - 1;

            // sum up the acounts of each person if there are one
            if (personCount > 0) {
              PersonAmount = new double[personCount];
              double dResidualValue = Double.valueOf(txtNutzBetr.getText().replace(",", "."));

              for (int PersonCounter = 1; PersonCounter <= personCount; PersonCounter++) {
                String selectedValue = cmbPerson.getItemAt(PersonCounter).toString();
                Integer personen_id =
                    Integer.valueOf(
                        selectedValue.substring(
                            selectedValue.indexOf("(") + 1, selectedValue.indexOf(")")));

                PersonAmount[PersonCounter - 1] =
                    getPersonAcountSumPerLiqui(
                        personen_id, BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0));
                TotalPersonAmount =
                    roundScale2(TotalPersonAmount + PersonAmount[PersonCounter - 1]);
              }

              // hint the total sum of all person
              txtHinweisAufteilung.append("Gesammtsumme:\n");
              txtHinweisAufteilung.append(
                  Double.toString(TotalPersonAmount).replace(".", ",") + "\n");

              // calc the proportion of the sums in percent, to the total Sum of all persons
              txtHinweisAufteilung.append(
                  "Sparbetrag: " + Double.toString(dResidualValue).replace(".", ",") + "\n");
              for (int PersonCounter = 0; PersonCounter < PersonAmount.length; PersonCounter++) {
                double percent =
                    roundScale2((PersonAmount[PersonCounter] * 100) / TotalPersonAmount);
                double dValue = roundScale2((percent * dResidualValue) / 100);
                txtHinweisAufteilung.append(
                    Double.toString(percent).replace(".", ",")
                        + "% / "
                        + Double.toString(dValue).replace(".", ",")
                        + "\n");
              }
            }
          }
        });

    // Textfeld fuer Hinweise zum errechneten Betrag
    txtHinweisAufteilung = new JTextArea();
    txtHinweisAufteilung.setBounds(330, 90, 180, 180);
    txtHinweisAufteilung.setBorder(BorderFactory.createEtchedBorder());
    txtHinweisAufteilung.setEditable(false); // infos sollen nur vom Programm gesetzt werden

    // zuweisen der Elemente fuer das Panel Einnahmenaufteilung
    pnlEinahmenAufteilung.add(lblPerson);
    pnlEinahmenAufteilung.add(cmbPerson);
    pnlEinahmenAufteilung.add(spAllIncome);
    pnlEinahmenAufteilung.add(spIncomePerPerson);
    pnlEinahmenAufteilung.add(chkAufteilung);
    pnlEinahmenAufteilung.add(btnAdd);
    pnlEinahmenAufteilung.add(btnRemove);
    pnlEinahmenAufteilung.add(lblBuchtext);
    pnlEinahmenAufteilung.add(btnCalcPercentualPortion);
    pnlEinahmenAufteilung.add(txtHinweisAufteilung);

    liquiwindow.add(pnlAbrMonat);
    liquiwindow.add(pnlRestwert);
    liquiwindow.add(txtHinweis);
    liquiwindow.add(pnlEinahmenAufteilung);

    liquiwindow.setVisible(true);
  }
예제 #18
0
파일: CWNTPanel.java 프로젝트: tinevez/CWNS
  private void initGUI() {
    setLayout(new BorderLayout());

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    add(tabbedPane);

    {
      final JPanel panelIntroduction = new JPanel();
      tabbedPane.addTab("Intro", null, panelIntroduction, null);
      panelIntroduction.setLayout(null);

      final JLabel lblCrownwearingNucleiTracker = new JLabel("Crown-Wearing Nuclei Segmenter");
      lblCrownwearingNucleiTracker.setFont(BIG_FONT);
      lblCrownwearingNucleiTracker.setHorizontalAlignment(SwingConstants.CENTER);
      lblCrownwearingNucleiTracker.setBounds(10, 11, 268, 30);
      panelIntroduction.add(lblCrownwearingNucleiTracker);

      final JLabel labelIntro = new JLabel(INTRO_TEXT);
      labelIntro.setFont(SMALL_FONT.deriveFont(11f));
      labelIntro.setBounds(10, 52, 268, 173);
      panelIntroduction.add(labelIntro);

      final JButton btnTestParamtersLive =
          new JButton("<html><div align=\"center\">Live test parameters</dic></html>");
      btnTestParamtersLive.setBounds(10, 292, 103, 72);
      btnTestParamtersLive.setFont(FONT);
      liveLaunched = false;
      btnTestParamtersLive.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
              if (liveLaunched) {
                stopLive();
                btnTestParamtersLive.setText(
                    "<html><div align=\"center\">Live test parameters</div></html>");
                liveLaunched = false;
              } else {
                launchLive();
                btnTestParamtersLive.setText(
                    "<html><div align=\"center\">Stop live test</div></html>");
                liveLaunched = true;
              }
            }
          });
      panelIntroduction.add(btnTestParamtersLive);

      final String segFrameButtonText = "<html><CENTER>Segment current frame</center></html>";
      final JButton segFrameButton = new JButton(segFrameButtonText);
      segFrameButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
              new Thread("CWNT thread") {
                @Override
                public void run() {
                  segFrameButton.setText("Segmenting...");
                  segFrameButton.setEnabled(false);
                  try {
                    launchSingleFrameSegmentation();
                  } finally {
                    segFrameButton.setEnabled(true);
                    segFrameButton.setText(segFrameButtonText);
                  }
                }
              }.start();
            }
          });
      segFrameButton.setFont(FONT);
      segFrameButton.setBounds(175, 292, 103, 72);
      panelIntroduction.add(segFrameButton);

      labelDurationEstimate = new JLabel();
      labelDurationEstimate.setBounds(10, 375, 268, 14);
      panelIntroduction.setFont(FONT);
      panelIntroduction.add(labelDurationEstimate);
    }

    final JPanel panelParams1 = new JPanel();
    {
      tabbedPane.addTab("Param set 1", null, panelParams1, null);
      panelParams1.setLayout(null);

      final JLabel lblFiltering = new JLabel("1. Filtering");
      lblFiltering.setFont(BIG_FONT);
      lblFiltering.setBounds(10, 11, 268, 29);
      panelParams1.add(lblFiltering);

      {
        final JLabel lblGaussianFilter = new JLabel("Gaussian filter \u03C3:");
        lblGaussianFilter.setFont(SMALL_FONT);
        lblGaussianFilter.setBounds(10, 51, 268, 14);
        panelParams1.add(lblGaussianFilter);

        gaussFiltSigmaSlider =
            new DoubleJSlider(0, 5 * scale, (int) (maskingParams[0] * scale), scale);
        gaussFiltSigmaSlider.setBounds(10, 76, 223, 23);
        panelParams1.add(gaussFiltSigmaSlider);

        gaussFiltSigmaText = new JFormattedTextField(new Double(maskingParams[0]));
        gaussFiltSigmaText.setHorizontalAlignment(SwingConstants.CENTER);
        gaussFiltSigmaText.setBounds(243, 76, 35, 23);
        gaussFiltSigmaText.setFont(FONT);
        panelParams1.add(gaussFiltSigmaText);

        link(gaussFiltSigmaSlider, gaussFiltSigmaText);
        gaussFiltSigmaSlider.addChangeListener(step1ChangeListener);
        gaussFiltSigmaText.addKeyListener(step1KeyListener);
      }

      final JLabel lblAnisotropicDiffusion = new JLabel("2. Anisotropic diffusion");
      lblAnisotropicDiffusion.setFont(BIG_FONT);
      lblAnisotropicDiffusion.setBounds(10, 128, 268, 29);
      panelParams1.add(lblAnisotropicDiffusion);

      {
        final JLabel lblNumberOfIterations = new JLabel("Number of iterations:");
        lblNumberOfIterations.setFont(SMALL_FONT);
        lblNumberOfIterations.setBounds(10, 168, 268, 14);
        panelParams1.add(lblNumberOfIterations);

        aniDiffNIterText = new JFormattedTextField(new Integer((int) maskingParams[1]));
        aniDiffNIterText.setHorizontalAlignment(SwingConstants.CENTER);
        aniDiffNIterText.setFont(FONT);
        aniDiffNIterText.setBounds(243, 193, 35, 23);
        panelParams1.add(aniDiffNIterText);

        aniDiffNIterSlider = new DoubleJSlider(0, 10, (int) maskingParams[1], 1);
        aniDiffNIterSlider.setBounds(10, 193, 223, 23);
        panelParams1.add(aniDiffNIterSlider);

        link(aniDiffNIterSlider, aniDiffNIterText);
        aniDiffNIterSlider.addChangeListener(step2ChangeListener);
        aniDiffNIterText.addKeyListener(step2KeyListener);
      }

      {
        final JLabel lblGradientDiffusionThreshold =
            new JLabel("Gradient diffusion threshold \u03BA:");
        lblGradientDiffusionThreshold.setFont(SMALL_FONT);
        lblGradientDiffusionThreshold.setBounds(10, 227, 268, 14);
        panelParams1.add(lblGradientDiffusionThreshold);

        aniDiffKappaText = new JFormattedTextField(new Double(maskingParams[2]));
        aniDiffKappaText.setHorizontalAlignment(SwingConstants.CENTER);
        aniDiffKappaText.setFont(FONT);
        aniDiffKappaText.setBounds(243, 252, 35, 23);
        panelParams1.add(aniDiffKappaText);

        aniDiffKappaSlider = new DoubleJSlider(1, 100, (int) maskingParams[2], 1);
        aniDiffKappaSlider.setBounds(10, 252, 223, 23);
        panelParams1.add(aniDiffKappaSlider);

        link(aniDiffKappaSlider, aniDiffKappaText);
        aniDiffKappaSlider.addChangeListener(step2ChangeListener);
        aniDiffKappaText.addKeyListener(step2KeyListener);
      }

      final JLabel lblDerivativesCalculation = new JLabel("3. Derivatives calculation");
      lblDerivativesCalculation.setFont(BIG_FONT);
      lblDerivativesCalculation.setBounds(10, 298, 268, 29);
      panelParams1.add(lblDerivativesCalculation);

      {
        final JLabel lblGaussianGradient = new JLabel("Gaussian gradient \u03C3:");
        lblGaussianGradient.setFont(FONT);
        lblGaussianGradient.setBounds(10, 338, 268, 14);
        panelParams1.add(lblGaussianGradient);

        gaussGradSigmaText = new JFormattedTextField(new Double(maskingParams[3]));
        gaussGradSigmaText.setFont(FONT);
        gaussGradSigmaText.setHorizontalAlignment(SwingConstants.CENTER);
        gaussGradSigmaText.setBounds(243, 363, 35, 23);
        panelParams1.add(gaussGradSigmaText);

        gaussGradSigmaSlider =
            new DoubleJSlider(0, 5 * scale, (int) (maskingParams[3] * scale), scale);
        gaussGradSigmaSlider.setBounds(10, 363, 223, 23);
        panelParams1.add(gaussGradSigmaSlider);

        link(gaussGradSigmaSlider, gaussGradSigmaText);
        gaussGradSigmaSlider.addChangeListener(step3ChangeListener);
        gaussGradSigmaText.addKeyListener(step3KeyListener);
      }
    }

    final JPanel panelParams2 = new JPanel();
    {
      tabbedPane.addTab("Param set 2", panelParams2);
      panelParams2.setLayout(null);

      final JLabel lblMasking = new JLabel("4. Masking");
      lblMasking.setFont(BIG_FONT);
      lblMasking.setBounds(10, 11, 268, 29);
      panelParams2.add(lblMasking);

      {
        final JLabel gammeLabel = new JLabel("\u03B3: tanh shift");
        gammeLabel.setFont(SMALL_FONT);
        gammeLabel.setBounds(10, 51, 268, 14);
        panelParams2.add(gammeLabel);

        gammaSlider =
            new DoubleJSlider(-5 * scale, 5 * scale, (int) (maskingParams[4] * scale), scale);
        gammaSlider.setBounds(10, 76, 223, 23);
        panelParams2.add(gammaSlider);

        gammaText = new JFormattedTextField(new Double(maskingParams[4]));
        gammaText.setFont(FONT);
        gammaText.setBounds(243, 76, 35, 23);
        panelParams2.add(gammaText);

        link(gammaSlider, gammaText);
        gammaSlider.addChangeListener(step4ChangeListener);
        gammaSlider.addKeyListener(step4KeyListener);
      }
      {
        final JLabel lblNewLabel_3 = new JLabel("\u03B1: gradient prefactor");
        lblNewLabel_3.setFont(SMALL_FONT);
        lblNewLabel_3.setBounds(10, 110, 268, 14);
        panelParams2.add(lblNewLabel_3);

        alphaSlider = new DoubleJSlider(0, 20 * scale, (int) (maskingParams[5] * scale), scale);
        alphaSlider.setBounds(10, 135, 223, 23);
        panelParams2.add(alphaSlider);

        alphaText = new JFormattedTextField(new Double(maskingParams[5]));
        alphaText.setFont(FONT);
        alphaText.setBounds(243, 135, 35, 23);
        panelParams2.add(alphaText);

        link(alphaSlider, alphaText);
        alphaSlider.addChangeListener(step4ChangeListener);
        alphaText.addKeyListener(step4KeyListener);
      }
      {
        final JLabel betaLabel = new JLabel("\u03B2: positive laplacian magnitude prefactor");
        betaLabel.setFont(SMALL_FONT);
        betaLabel.setBounds(10, 169, 268, 14);
        panelParams2.add(betaLabel);

        betaSlider = new DoubleJSlider(0, 20 * scale, (int) (maskingParams[6] * scale), scale);
        betaSlider.setBounds(10, 194, 223, 23);
        panelParams2.add(betaSlider);

        betaText = new JFormattedTextField(new Double(maskingParams[6]));
        betaText.setFont(FONT);
        betaText.setBounds(243, 194, 35, 23);
        panelParams2.add(betaText);

        link(betaSlider, betaText);
        betaSlider.addChangeListener(step4ChangeListener);
        betaText.addKeyListener(step4KeyListener);
      }
      {
        final JLabel epsilonLabel = new JLabel("\u03B5: negative hessian magnitude");
        epsilonLabel.setFont(SMALL_FONT);
        epsilonLabel.setBounds(10, 228, 268, 14);
        panelParams2.add(epsilonLabel);

        epsilonSlider = new DoubleJSlider(0, 20 * scale, (int) (scale * maskingParams[7]), scale);
        epsilonSlider.setBounds(10, 253, 223, 23);
        panelParams2.add(epsilonSlider);

        epsilonText = new JFormattedTextField(new Double(maskingParams[7]));
        epsilonText.setFont(FONT);
        epsilonText.setText("" + maskingParams[7]);
        epsilonText.setBounds(243, 253, 35, 23);
        panelParams2.add(epsilonText);

        link(epsilonSlider, epsilonText);
        epsilonSlider.addChangeListener(step4ChangeListener);
        epsilonText.addKeyListener(step4KeyListener);
      }
      {
        final JLabel deltaLabel = new JLabel("\u03B4: derivatives sum scale");
        deltaLabel.setFont(SMALL_FONT);
        deltaLabel.setBounds(10, 287, 268, 14);
        panelParams2.add(deltaLabel);

        deltaText = new JFormattedTextField(new Double(maskingParams[8]));
        deltaText.setFont(FONT);
        deltaText.setText("" + maskingParams[8]);
        deltaText.setBounds(243, 312, 35, 23);
        panelParams2.add(deltaText);

        deltaSlider = new DoubleJSlider(0, 5 * scale, (int) (maskingParams[8] * scale), scale);
        deltaSlider.setBounds(10, 312, 223, 23);
        panelParams2.add(deltaSlider);

        link(deltaSlider, deltaText);
        deltaSlider.addChangeListener(step4ChangeListener);
        deltaText.addKeyListener(step4KeyListener);
      }

      final JLabel lblEquation =
          new JLabel(
              "<html>M = \u00BD ( 1 + <i>tanh</i> ( \u03B3 - ( \u03B1 G + \u03B2 L + \u03B5 H ) / \u03B4 ) )</html>");
      lblEquation.setHorizontalAlignment(SwingConstants.CENTER);
      lblEquation.setFont(FONT.deriveFont(12f));
      lblEquation.setBounds(10, 364, 268, 35);
      panelParams2.add(lblEquation);
    }

    {
      final JPanel panel = new JPanel();
      tabbedPane.addTab("Param set 3", null, panel, null);
      panel.setLayout(null);

      final JLabel labelThresholding = new JLabel("5. Thresholding");
      labelThresholding.setBounds(10, 11, 268, 28);
      labelThresholding.setFont(BIG_FONT);
      panel.add(labelThresholding);

      final JLabel labelThresholdFactor = new JLabel("Threshold factor:");
      labelThresholdFactor.setFont(SMALL_FONT);
      labelThresholdFactor.setBounds(10, 50, 268, 14);
      panel.add(labelThresholdFactor);

      thresholdFactorSlider =
          new DoubleJSlider(0, 5 * scale, (int) (thresholdFactor * scale), scale);
      thresholdFactorSlider.setBounds(10, 75, 223, 23);
      panel.add(thresholdFactorSlider);

      thresholdFactorText = new JFormattedTextField(new Double(thresholdFactor));
      thresholdFactorText.setFont(FONT);
      thresholdFactorText.setBounds(243, 75, 35, 23);
      panel.add(thresholdFactorText);

      link(thresholdFactorSlider, thresholdFactorText);
      thresholdFactorSlider.addChangeListener(step5ChangeListener);
      thresholdFactorText.addKeyListener(step5KeyListener);
    }
  }
예제 #19
0
  /** Create the frame. */
  public Calculator() {
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 384, 259);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new BorderLayout(7, 3));

    displayField = new JFormattedTextField();
    displayField.setFont(new Font("Tahoma", Font.PLAIN, 14));
    displayField.setPreferredSize(new Dimension(6, 30));
    displayField.setMinimumSize(new Dimension(10, 10));
    displayField.setEditable(false);
    displayField.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPane.add(displayField, BorderLayout.NORTH);

    JPanel panel = new JPanel();
    contentPane.add(panel, BorderLayout.CENTER);
    panel.setLayout(new GridLayout(4, 3, 3, 3));

    CalculatorActionsListener calcListener = new CalculatorActionsListener(this);

    JButton btnNewButton7 = new JButton("7");
    btnNewButton7.setFont(new Font("Tahoma", Font.PLAIN, 14));
    btnNewButton7.setSize(new Dimension(25, 23));
    btnNewButton7.setMaximumSize(new Dimension(23, 23));
    btnNewButton7.setPreferredSize(new Dimension(25, 23));
    panel.add(btnNewButton7);
    btnNewButton7.addActionListener(calcListener);

    JButton btnNewButton8 = new JButton("8");
    btnNewButton8.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton8);
    btnNewButton8.addActionListener(calcListener);

    JButton btnNewButton9 = new JButton("9");
    btnNewButton9.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton9);
    btnNewButton9.addActionListener(calcListener);

    JButton btnNewButton4 = new JButton("4");
    btnNewButton4.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton4);
    btnNewButton4.addActionListener(calcListener);

    JButton btnNewButton5 = new JButton("A");
    btnNewButton5.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton5);
    btnNewButton5.addActionListener(calcListener);

    JButton btnNewButton6 = new JButton("6");
    btnNewButton6.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton6);
    btnNewButton6.addActionListener(calcListener);

    JButton btnNewButton1 = new JButton("1");
    btnNewButton1.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton1);
    btnNewButton1.addActionListener(calcListener);

    JButton btnNewButton2 = new JButton("2");
    btnNewButton2.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton2);
    btnNewButton2.addActionListener(calcListener);

    JButton btnNewButton3 = new JButton("3");
    btnNewButton3.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton3);
    btnNewButton3.addActionListener(calcListener);

    JButton btnNewButtonZero = new JButton("0");
    btnNewButtonZero.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButtonZero);
    btnNewButtonZero.addActionListener(calcListener);

    JButton btnNewButtonDot = new JButton(".");
    btnNewButtonDot.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButtonDot);
    btnNewButtonDot.addActionListener(calcListener);

    btnNewButtonEqual = new JButton("=");
    btnNewButtonEqual.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButtonEqual);
    btnNewButtonEqual.addActionListener(calcListener);

    JPanel panel_1 = new JPanel();
    panel_1.setPreferredSize(new Dimension(80, 10));
    panel_1.setBounds(new Rectangle(5, 5, 5, 5));
    contentPane.add(panel_1, BorderLayout.EAST);
    panel_1.setLayout(new GridLayout(4, 1, 3, 3));

    btnNewButtonDiv = new JButton("/");
    btnNewButtonDiv.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonDiv);
    btnNewButtonDiv.addActionListener(calcListener);

    btnNewButtonMult = new JButton("*");
    btnNewButtonMult.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonMult);
    btnNewButtonMult.addActionListener(calcListener);

    btnNewButtonSub = new JButton("-");
    btnNewButtonSub.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonSub);
    btnNewButtonSub.addActionListener(calcListener);

    btnNewButtonAdd = new JButton("+");
    btnNewButtonAdd.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonAdd);
    btnNewButtonAdd.addActionListener(calcListener);
  }