private JPanel getYearAndMonthPanal() {
    Calendar c = getDateCalendar();
    int currentYear = c.get(Calendar.YEAR);
    int currentMonth = c.get(Calendar.MONTH) + 1;
    int currentHour = c.get(Calendar.HOUR_OF_DAY);
    int currentMinute = c.get(Calendar.MINUTE);
    int currentSecond = c.get(Calendar.SECOND);

    JPanel result = new JPanel();
    result.setLayout(new FlowLayout());
    result.setBackground(controlLineColor);

    yearSpin = new JSpinner(new SpinnerNumberModel(currentYear, startYear, lastYear, 1));
    yearSpin.setPreferredSize(new Dimension(48, 20));
    yearSpin.setName("Year");
    yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));
    yearSpin.addChangeListener(this);
    result.add(yearSpin);
    JLabel yearLabel = new JLabel("年");
    yearLabel.setForeground(controlTextColor);
    result.add(yearLabel);

    monthSpin = new JSpinner(new SpinnerNumberModel(currentMonth, 1, 12, 1));
    monthSpin.setPreferredSize(new Dimension(35, 20));
    monthSpin.setName("Month");
    monthSpin.addChangeListener(this);
    result.add(monthSpin);
    JLabel monthLabel = new JLabel("月");
    monthLabel.setForeground(controlTextColor);
    result.add(monthLabel);

    hourSpin = new JSpinner(new SpinnerNumberModel(currentHour, 0, 23, 1));
    hourSpin.setPreferredSize(new Dimension(35, 20));
    hourSpin.setName("Hour");
    hourSpin.addChangeListener(this);
    result.add(hourSpin);
    JLabel hourLabel = new JLabel("时");
    hourLabel.setForeground(controlTextColor);
    result.add(hourLabel);

    minuteSpin = new JSpinner(new SpinnerNumberModel(currentMinute, 0, 59, 1));
    minuteSpin.setPreferredSize(new Dimension(35, 20));
    minuteSpin.setName("Minute");
    minuteSpin.addChangeListener(this);
    result.add(minuteSpin);
    JLabel minuteLabel = new JLabel("分");
    hourLabel.setForeground(controlTextColor);
    result.add(minuteLabel);

    secondSpin = new JSpinner(new SpinnerNumberModel(currentSecond, 0, 59, 1));
    secondSpin.setPreferredSize(new Dimension(35, 20));
    secondSpin.setName("Second");
    secondSpin.addChangeListener(this);
    result.add(secondSpin);
    JLabel secondLabel = new JLabel("秒");
    secondLabel.setForeground(controlTextColor);
    result.add(secondLabel);

    return result;
  }
示例#2
0
    private void createYearAndMonthPanal() {
      Calendar c = getNowCalendar();
      int currentYear = c.get(Calendar.YEAR);
      int currentMonth = c.get(Calendar.MONTH) + 1;
      int currentHour = c.get(Calendar.HOUR_OF_DAY);
      yearSpin =
          new JSpinner(new javax.swing.SpinnerNumberModel(currentYear, startYear, lastYear, 1));
      monthSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentMonth, 1, 12, 1));
      hourSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentHour, 0, 23, 1));

      yearPanel.setLayout(new java.awt.FlowLayout());
      yearPanel.setBackground(controlLineColor);

      yearSpin.setPreferredSize(new Dimension(48, 20));
      yearSpin.setName("Year");
      yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));
      yearSpin.addChangeListener(this);
      yearPanel.add(yearSpin);

      JLabel yearLabel = new JLabel("年");
      yearLabel.setForeground(controlTextColor);
      yearPanel.add(yearLabel);

      monthSpin.setPreferredSize(new Dimension(35, 20));
      monthSpin.setName("Month");
      monthSpin.addChangeListener(this);
      yearPanel.add(monthSpin);

      JLabel monthLabel = new JLabel("月");
      monthLabel.setForeground(controlTextColor);
      yearPanel.add(monthLabel);

      hourSpin.setPreferredSize(new Dimension(35, 20));
      hourSpin.setName("Hour");
      hourSpin.addChangeListener(this);
      yearPanel.add(hourSpin);

      JLabel hourLabel = new JLabel("日");
      hourLabel.setForeground(controlTextColor);
      yearPanel.add(hourLabel);
    }
  /** constructor */
  public JSpinnerExampleAUT() {
    super("JSpinner Example AUT");

    final int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    SpinnerNumberModel yearModel = new SpinnerNumberModel(currentYear, 0, 3000, 1);
    JSpinner spinnerYear = new JSpinner(yearModel);
    spinnerYear.setEditor(new JSpinner.NumberEditor(spinnerYear, "#"));
    spinnerYear.setName("Year Spinner");

    String[] months =
        new String[] {
          "January",
          "February",
          "March",
          "April",
          "May",
          "June",
          "July",
          "August",
          "September",
          "October",
          "November",
          "December"
        };
    SpinnerListModel monthModel = new SpinnerListModel(months);
    JSpinner spinnerMonth = new JSpinner(monthModel);
    spinnerMonth.setName("Month Spinner");

    Component spinnerEditor = spinnerMonth.getEditor();
    JFormattedTextField jftf = ((JSpinner.DefaultEditor) spinnerEditor).getTextField();
    jftf.setColumns(7);

    super.getContentPane().setLayout(new FlowLayout());
    super.getContentPane().add(spinnerYear);
    super.getContentPane().add(spinnerMonth);
  }
 private MyWindow(@Nonnull Class<?> testClass) {
   super(testClass);
   spinner.setName("spinMeSpinner");
   addComponents(spinner);
 }
示例#5
0
 /** Fills the panel with event specific fields. */
 protected void fillPanel() {
   JLabel l;
   Box fdp = Box.createVerticalBox();
   fdp.setBorder(BorderFactory.createTitledBorder("Fundamental Diagram"));
   fdChart = makeFDChart();
   ChartPanel cp = new ChartPanel(fdChart);
   cp.setMinimumDrawWidth(100);
   cp.setMinimumDrawHeight(60);
   cp.setPreferredSize(new Dimension(250, 80));
   fdp.add(new JScrollPane(cp));
   JPanel prmp = new JPanel(new SpringLayout());
   l = new JLabel("Capacity:", JLabel.TRAILING);
   prmp.add(l);
   spinMaxFlow = new JSpinner(new SpinnerNumberModel(mf, 0, 99999, 1.0));
   spinMaxFlow.setEditor(new JSpinner.NumberEditor(spinMaxFlow, "####0.00"));
   spinMaxFlow.addChangeListener(this);
   spinMaxFlow.setName(nmSpinMaxFlow);
   l.setLabelFor(spinMaxFlow);
   prmp.add(spinMaxFlow);
   l = new JLabel("Cap.Drop:", JLabel.TRAILING);
   prmp.add(l);
   spinCapDrop = new JSpinner(new SpinnerNumberModel(drp, 0, 99999, 1.0));
   spinCapDrop.setEditor(new JSpinner.NumberEditor(spinCapDrop, "####0.00"));
   spinCapDrop.addChangeListener(this);
   spinCapDrop.setName(nmSpinCapDrop);
   l.setLabelFor(spinCapDrop);
   prmp.add(spinCapDrop);
   l = new JLabel("C.Density:", JLabel.TRAILING);
   prmp.add(l);
   spinCritDen = new JSpinner(new SpinnerNumberModel(cd, 0, 99999, 1.0));
   spinCritDen.setEditor(new JSpinner.NumberEditor(spinCritDen, "####0.00"));
   spinCritDen.addChangeListener(this);
   spinCritDen.setName(nmSpinCritDen);
   l.setLabelFor(spinCritDen);
   prmp.add(spinCritDen);
   l = new JLabel("  V:", JLabel.TRAILING);
   prmp.add(l);
   spinVff = new JSpinner(new SpinnerNumberModel(mf / cd, 0, 200, 1.0));
   spinVff.setEditor(new JSpinner.NumberEditor(spinVff, "#0.00"));
   spinVff.addChangeListener(this);
   spinVff.setName(nmSpinVff);
   l.setLabelFor(spinVff);
   prmp.add(spinVff);
   l = new JLabel("J.Density:", JLabel.TRAILING);
   prmp.add(l);
   spinJamDen = new JSpinner(new SpinnerNumberModel(jd, 0, 99999, 1.0));
   spinJamDen.setEditor(new JSpinner.NumberEditor(spinJamDen, "####0.00"));
   spinJamDen.addChangeListener(this);
   spinJamDen.setName(nmSpinJamDen);
   l.setLabelFor(spinJamDen);
   prmp.add(spinJamDen);
   l = new JLabel("  W:", JLabel.TRAILING);
   prmp.add(l);
   if (jd == cd) jd = cd + 1;
   int ulim = (int) Math.max(Math.ceil(mf / (jd - cd)), 999);
   spinWc = new JSpinner(new SpinnerNumberModel(mf / (jd - cd), 0, ulim, 1.0));
   spinWc.setEditor(new JSpinner.NumberEditor(spinWc, "#0.00"));
   spinWc.addChangeListener(this);
   spinWc.setName(nmSpinWc);
   l.setLabelFor(spinWc);
   prmp.add(spinWc);
   SpringUtilities.makeCompactGrid(prmp, 3, 4, 2, 2, 2, 2);
   fdp.add(prmp);
   // add(new JScrollPane(fdp));
   add(fdp);
   return;
 }
  private void initComponents() {
    jLabel1 = new javax.swing.JLabel();
    spinDays = new javax.swing.JSpinner();
    spinMonth = new javax.swing.JSpinner();
    spinYear = new javax.swing.JSpinner();
    jLabel2 = new javax.swing.JLabel();
    txtWeek = new javax.swing.JTextField(2);
    jLabel3 = new javax.swing.JLabel();
    txtDays = new javax.swing.JTextField(1);
    jLabel4 = new javax.swing.JLabel();
    btnLMP = new javax.swing.JButton();
    btnUSG = new javax.swing.JButton();
    btnClear = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    txtResult = new javax.swing.JTextArea();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenu3 = new javax.swing.JMenuItem();

    jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    jLabel1.setText("Date");

    spinDays.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
    spinDays.setName("spDay"); // NOI18N
    spinDays.setNextFocusableComponent(spinMonth);
    spinDays.addChangeListener(
        new javax.swing.event.ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent evt) {
            jSpinner2StateChanged(evt);
          }
        });

    spinMonth.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
    spinMonth.setName("spMonth"); // NOI18N
    spinMonth.setNextFocusableComponent(spinYear);
    spinMonth.addChangeListener(
        new javax.swing.event.ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent evt) {
            jSpinner3StateChanged(evt);
          }
        });

    spinYear.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
    spinYear.setName("spYear"); // NOI18N
    spinYear.addChangeListener(
        new javax.swing.event.ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent evt) {
            jSpinner4StateChanged(evt);
          }
        });

    jLabel2.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    jLabel2.setText("Gestacional age");

    txtWeek.setColumns(2);
    txtWeek.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
    txtWeek.setText("00");

    jLabel3.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    jLabel3.setText("weeks");

    txtDays.setColumns(1);
    txtDays.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
    txtDays.setText("0");

    jLabel4.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    jLabel4.setText("days");

    btnLMP.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    btnLMP.setText("L.M.P.");
    btnLMP.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Calendar lpm = Calendar.getInstance();
            Calendar today = Calendar.getInstance();
            lpm.set(dtYear, dtMonth, dtDay);
            txtResult.setText("");
            if (lpm.getTime().after(today.getTime())) {
              txtResult.insert("Invalid L.P.M.", 0);
            } else {
              // defines gestacional ages
              gest.setDum(lpm.getTime());
              // show calcs
              ShowCalcs("L.P.M.");
            }
            ;
          }
        });

    btnUSG.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    btnUSG.setText("Exam");
    btnUSG.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Calendar dtExam = Calendar.getInstance();
            Calendar today = Calendar.getInstance();
            dtExam.set(dtYear, dtMonth, dtDay);
            txtResult.setText("");
            if (dtExam.getTime().after(today.getTime())) {
              txtResult.insert("Invalid Date", 0);
            } else {
              // defines gestacional ages
              try {
                if (txtWeek.getText().equals("")) {
                  txtWeek.setText("0");
                }
                if (txtDays.getText().equals("")) {
                  txtDays.setText("0");
                }
                int wk = Integer.parseInt(txtWeek.getText()),
                    dy = Integer.parseInt(txtDays.getText());
                gest.setDum(dtExam.getTime(), wk, dy);
                // show calcs
                ShowCalcs("US");
              } catch (NumberFormatException nfex) {
                JOptionPane.showMessageDialog(
                    null, nfex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
              } catch (Exception ex) {
                JOptionPane.showMessageDialog(
                    null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
              }
            }
          }
        });

    btnClear.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    btnClear.setText("Clear");
    btnClear.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            txtResult.setText("");
          }
        });

    txtResult.setColumns(20);
    txtResult.setRows(5);
    txtResult.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jScrollPane1.setViewportView(txtResult);

    jMenuBar1.setName("mainMenuBar"); // NOI18N

    jMenu1.setText("File");

    jMenu3.setMnemonic('x');
    jMenu3.setText("Exit");
    jMenu3.setName("mnitExit"); // NOI18N
    jMenu3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            exit();
          }
        });

    jMenu1.add(jMenu3);

    jMenuBar1.add(jMenu1);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(
                                        spinDays,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        77,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                    .addComponent(
                                        spinMonth,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        77,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(
                                        spinYear,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        117,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel1)
                                            .addComponent(
                                                jLabel2,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                194,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addComponent(
                                                        txtWeek,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        66,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement
                                                            .RELATED)
                                                    .addComponent(jLabel3)
                                                    .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement
                                                            .UNRELATED)
                                                    .addComponent(
                                                        txtDays,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement
                                                            .RELATED)
                                                    .addComponent(jLabel4)))
                                    .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(
                                        btnLMP,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        81,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                    .addComponent(
                                        btnUSG,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        81,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(
                                        btnClear,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        82,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(
                                        spinDays,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        66,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(
                                        spinMonth,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        66,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(
                                spinYear,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                66,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel2)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                txtWeek,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                50,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)
                            .addComponent(
                                txtDays,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                50,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                btnLMP,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                48,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                btnUSG,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                48,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                btnClear,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                48,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(
                        jScrollPane1,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        225,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(18, Short.MAX_VALUE)));

    pack();
  }
 private MyWindow() {
   super(JSpinnerFixture_constructor_withRobotAndName_Test.class);
   spinner.setName("spinner");
   addComponents(spinner);
 }
  /**
   * Creates the sub-panel that will contains the following widgets:
   *
   * <pre>
   * __________________________________________
   * |                    ___________________ |  ____________
   * |   Batch Writing:   |               |v| |<-| None     |
   * |                    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ |  | JDBC     |
   * |                          _____________ |  | Buffered |
   * | x String Binding   Size: |         |I| |  ¯¯¯¯¯¯¯¯¯¯¯¯
   * |                          ¯¯¯¯¯¯¯¯¯¯¯¯¯ |
   * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯</pre>
   *
   * @return The fully initializes sub-pane with its widgets
   */
  private JComponent buildBatchWritingStringBindingPane() {
    GridBagConstraints constraints = new GridBagConstraints();
    int space = SwingTools.checkBoxIconWidth();

    // Create the container
    JPanel container = new JPanel(new GridBagLayout());
    container
        .getAccessibleContext()
        .setAccessibleName(resourceRepository().getString("LOGIN_JDBC_OPTIONS_TITLE"));

    // Batch Writing label
    JLabel batchWritingLabel = buildLabel("LOGIN_BATCH_WRITING_COMBO_BOX");

    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.LINE_START;
    constraints.insets = new Insets(2, space, 0, 0);

    container.add(batchWritingLabel, constraints);

    // Batch Writing combo box
    JComboBox batchWritingComboBox = new JComboBox(buildBatchWritingComboBoxAdapter());
    batchWritingComboBox.setRenderer(
        new AdaptableListCellRenderer(buildBatchWritingLabelDecorator()));
    batchWritingComboBox.setName("LOGIN_BATCH_WRITING_COMBO_BOX");

    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.insets = new Insets(2, 20, 0, 0);

    container.add(batchWritingComboBox, constraints);
    batchWritingLabel.setLabelFor(batchWritingComboBox);

    // String size label
    JLabel stringSizeLabel = buildLabel("LOGIN_MAX_BATCH_WRITING_SIZE_SPINNER");

    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 1;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.LAST_LINE_START;
    constraints.insets = new Insets(2, 40, 0, 0);

    container.add(stringSizeLabel, constraints);

    // String size spinner
    JSpinner stringSizeSpinner =
        SwingComponentFactory.buildSpinnerNumber(buildStringSizeSpinnerAdapter());
    stringSizeSpinner.setName("LOGIN_MAX_BATCH_WRITING_SIZE_SPINNER");

    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.insets = new Insets(2, 5, 0, 0);

    container.add(stringSizeSpinner, constraints);
    stringSizeLabel.setLabelFor(stringSizeSpinner);

    // String Binding check box
    JCheckBox stringBindingCheckBox =
        buildCheckBox("LOGIN_STRING_BINDING_CHECK_BOX", buildStringBindingCheckBoxAdapter());

    constraints.gridx = 0;
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.LINE_START;
    constraints.insets = new Insets(4, 0, 0, 0);

    container.add(stringBindingCheckBox, constraints);

    return container;
  }
示例#9
0
 public void setName(String name) {
   spinner.setName(name);
 }
  /**
   * Creates the panel for a view class according to a <code>HashMap</code> of values
   *
   * @param className the full qualified class name
   * @param defaults the defaults to create the panel for
   * @return a jpanel containing ui elements for a specific set of properties
   */
  @SuppressWarnings("unchecked")
  public JPanel createParamPanel(String className, HashMap defaults) {

    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBackground(Color.WHITE);
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    GridBagConstraints constraints = new GridBagConstraints();

    constraints.gridwidth = 1;
    constraints.insets = new Insets(3, 3, 3, 3);
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;

    int row = 0;

    Object[] keys = defaults.keySet().toArray();
    Arrays.sort(keys);

    for (int k = 0; k < keys.length; k++) {

      String key = (String) keys[k];

      if (key.startsWith(className) && !key.endsWith("optionValues")) {

        constraints.gridy = row;
        constraints.gridx = 0;

        JLabel label = new JLabel(resources.getResourceByKey(key));
        panel.add(label, constraints);

        if (defaults.get(key) instanceof String) {

          if (defaults.get(key + ".optionValues") != null) {

            String optionValues = (String) defaults.get(key + ".optionValues");

            JComboBox comboBox = new JComboBox();
            comboBox.setName(key);

            String value = (String) defaults.get(key);

            String[] options = optionValues.split(",");

            for (int i = 0; i < options.length; i++) {
              comboBox.addItem(options[i]);
            }

            comboBox.setSelectedItem(value);

            constraints.gridx = 1;
            panel.add(comboBox, constraints);

          } else {

            JTextField textfield = new JTextField(30);
            textfield.setName(key);
            String value = (String) defaults.get(key);
            textfield.setText(value);
            constraints.gridx = 1;
            panel.add(textfield, constraints);
          }

        } else if (defaults.get(key) instanceof Boolean) {
          JCheckBox checkBox = new JCheckBox();
          checkBox.setName(key);
          checkBox.setBackground(Color.WHITE);
          Boolean value = (Boolean) defaults.get(key);
          checkBox.setSelected(value);
          constraints.gridx = 1;
          panel.add(checkBox, constraints);
        } else if (defaults.get(key) instanceof Integer) {
          JSpinner spinner = new JSpinner();
          spinner.setName(key);
          Integer value = (Integer) defaults.get(key);
          spinner.setValue(value);
          constraints.gridx = 1;
          panel.add(spinner, constraints);
        } else if (defaults.get(key) instanceof FileObject) {
          FileBrowserTextfield textField = new FileBrowserTextfield();
          textField.setBackground(Color.WHITE);
          textField.setName(key);
          FileObject value = (FileObject) defaults.get(key);
          textField.getPathField().setText(value.getAbsolutePath());
          textField.getPathField().setBackground(Color.WHITE);
          constraints.gridx = 1;
          panel.add(textField, constraints);
        }

        row++;
      }
    }

    /** Add fill label for GridBagLayout */
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    panel.add(new JLabel(), constraints);

    return panel;
  }