コード例 #1
0
ファイル: MyDateChooseBtn.java プロジェクト: singleD/se2
    public void stateChanged(ChangeEvent e) {
      JSpinner source = (JSpinner) e.getSource();
      if (source.getName().equals("Hour")) {
        calendar.set(Calendar.HOUR_OF_DAY, getSelectedHour());
        return;
      }
      if (source.getName().equals("Year")) {

        calendar.set(Calendar.YEAR, getSelectedYear());
        dayPanel.removeAll();
        this.flushWeekAndDayPanal(calendar);
        dayPanel.revalidate();
        dayPanel.updateUI();
        return;
      }
      if (source.getName().equals("Month")) {
        calendar.set(Calendar.MONTH, getSelectedMonth() - 1);

        dayPanel.removeAll();
        this.flushWeekAndDayPanal(calendar);
        dayPanel.revalidate();
        dayPanel.updateUI();
        return;
      }
    }
コード例 #2
0
ファイル: CrearTaulerAutomatic.java プロジェクト: Nalaboo/BD
  private void onOK() {
    System.out.println("pase por aqui");
    int tamanyHidato = (int) spinnerTamanyHidato.getValue();
    int forats = (int) spinnerForats.getValue();
    int numerosPrecolocats = (int) spinnerNumerosPrecolocats.getValue();
    String dificultat = (String) comboBoxDificultat.getSelectedItem();

    ControladorHidato.fesCreacioAutomatica(tamanyHidato, forats, numerosPrecolocats, dificultat);
    dispose();
  }
コード例 #3
0
  /** Set the time spinner's font. */
  protected void setupTimeFont() {
    Font font;
    if (spinner == null) return;

    // If not null, use what the user gave us

    if (timeFont != null) {
      spinner.setFont(timeFont);
    } else {
      font = UIManager.getFont("Spinner.font");
      spinner.setFont(font);
    }
  }
コード例 #4
0
 private void onOK() {
   // add your code here
   game = new Game(((Number) numberOfRounds.getValue()).intValue());
   game.setMaxProcessorSpeed(((Number) maxCpu.getValue()).intValue());
   for (RobotSource factory : entrantsModel.getList()) {
     try {
       game.addEntrant(factory.createFactory());
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
   }
   dispose();
 }
コード例 #5
0
 public void hideTime() {
   mMaxXTLabel.setEnabled(false);
   mMinXTLabel.setEnabled(false);
   mMaxXLabel.setEnabled(true);
   mMinXLabel.setEnabled(true);
   mIncLabel.setEnabled(true);
   xMin.setEnabled(true);
   xMax.setEnabled(true);
   xInc.setEnabled(true);
   mStartSpinner.setEnabled(false);
   mEndSpinner.setEnabled(false);
   xTics.setEnabled(true);
   mPlotXGrid.setEnabled(true);
   mXIncLabel.setEnabled(true);
 }
コード例 #6
0
 private void preferredIndexFieldChanged(ChangeEvent e) {
   Integer indx = (Integer) (preferredIndexField.getValue());
   int index = indx.intValue();
   if (index != objEntityViewField.getPrefIndex()) {
     objEntityViewField.setPrefIndex(index);
   }
 }
コード例 #7
0
  /** {@inheritDoc} */
  public void setEnabled(boolean b) {
    if (b != isEnabled()) {
      super.setEnabled(b);

      if ((selectedComponents & DISPLAY_DATE) > 0) {
        yearDecrButton.setEnabled(b);
        monthDecrButton.setEnabled(b);
        monthYearLabel.setEnabled(b);
        monthIncrButton.setEnabled(b);
        yearIncrButton.setEnabled(b);

        for (int day = 0; day < 7; day++) {
          dayOfWeekLabels[day].setEnabled(b);
        }

        for (int row = 0; row < 6; row++) {
          for (int day = 0; day < 7; day++) {
            if (dayButtons[row][day].getText().length() > 0) {
              dayButtons[row][day].setEnabled(b);
            }
          }
        }
      }

      if ((selectedComponents & DISPLAY_TIME) > 0) {
        spinner.setEnabled(b);
      }
    }
  }
コード例 #8
0
  public void setXRangeToTime() {
    showTime();
    // set the x axis from the time range of the data
    GeoDate minDate = mFileViewer.getMinDate();
    GeoDate maxDate = mFileViewer.getMaxDate();

    xTics.setValue(new Integer(xTicsVal));
  }
コード例 #9
0
    protected JPanel createForm() {
      JPanel panel = new JPanel();
      panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
      // Time
      JPanel pT = new JPanel(new FlowLayout());
      pT.setBorder(BorderFactory.createTitledBorder("Start Time"));
      hh = new JSpinner(new SpinnerNumberModel(Util.getHours(myrow.getTime()), 0, 99, 1));
      hh.setEditor(new JSpinner.NumberEditor(hh, "00"));
      pT.add(hh);
      pT.add(new JLabel("h "));
      mm = new JSpinner(new SpinnerNumberModel(Util.getMinutes(myrow.getTime()), 0, 59, 1));
      mm.setEditor(new JSpinner.NumberEditor(mm, "00"));
      pT.add(mm);
      pT.add(new JLabel("m "));
      ss = new JSpinner(new SpinnerNumberModel(Util.getSeconds(myrow.getTime()), 0, 59, 1));
      ss.setEditor(new JSpinner.NumberEditor(ss, "00"));
      pT.add(ss);
      pT.add(new JLabel("s"));
      panel.add(pT);
      // Green
      JPanel pG = new JPanel(new BorderLayout());
      pG.setBorder(BorderFactory.createTitledBorder("Green (sec.)"));
      green = new JSpinner(new SpinnerNumberModel(myrow.getGreen() * conversion, 0.0, 99999.99, 1));
      green.setEditor(new JSpinner.NumberEditor(green, "####0.##"));
      pG.add(green);
      panel.add(pG);
      // Red
      JPanel pR = new JPanel(new BorderLayout());
      pR.setBorder(BorderFactory.createTitledBorder("Red (sec.)"));
      red = new JSpinner(new SpinnerNumberModel(myrow.getRed() * conversion, 0.0, 99999.99, 1));
      red.setEditor(new JSpinner.NumberEditor(red, "####0.##"));
      pR.add(red);
      panel.add(pR);

      JPanel bp = new JPanel(new FlowLayout());
      JButton bOK = new JButton("    OK    ");
      bOK.setActionCommand(cmdOK);
      bOK.addActionListener(new ButtonEventsListener());
      JButton bCancel = new JButton("Cancel");
      bCancel.setActionCommand(cmdCancel);
      bCancel.addActionListener(new ButtonEventsListener());
      bp.add(bOK);
      bp.add(bCancel);
      panel.add(bp);
      return panel;
    }
コード例 #10
0
ファイル: GenericListener.java プロジェクト: q1051278389/HMCL
  protected void attachTo(Component jc) {
    if (extListener != null && extListener.accept(jc)) {
      extListener.startListeningTo(jc, extNotifier);
      listenedTo.add(jc);
      if (wizardPage.getMapKeyFor(jc) != null) {
        wizardPage.maybeUpdateMap(jc);
      }
      return;
    }
    if (isProbablyAContainer(jc)) {
      attachToHierarchyOf((Container) jc);
    } else if (jc instanceof JList) {
      listenedTo.add(jc);
      ((JList) jc).addListSelectionListener(this);
    } else if (jc instanceof JComboBox) {
      ((JComboBox) jc).addActionListener(this);
    } else if (jc instanceof JTree) {
      listenedTo.add(jc);
      ((JTree) jc).getSelectionModel().addTreeSelectionListener(this);
    } else if (jc instanceof JToggleButton) {
      ((AbstractButton) jc).addItemListener(this);
    } else if (jc
        instanceof JFormattedTextField) { // JFormattedTextField must be tested before JTextCompoent
      jc.addPropertyChangeListener("value", this);
    } else if (jc instanceof JTextComponent) {
      listenedTo.add(jc);
      ((JTextComponent) jc).getDocument().addDocumentListener(this);
    } else if (jc instanceof JColorChooser) {
      listenedTo.add(jc);
      ((JColorChooser) jc).getSelectionModel().addChangeListener(this);
    } else if (jc instanceof JSpinner) {
      ((JSpinner) jc).addChangeListener(this);
    } else if (jc instanceof JSlider) {
      ((JSlider) jc).addChangeListener(this);
    } else if (jc instanceof JTable) {
      listenedTo.add(jc);
      ((JTable) jc).getSelectionModel().addListSelectionListener(this);
    } else {
      if (logger.isLoggable(Level.FINE)) {
        logger.fine(
            "Don't know how to listen to a "
                + // NOI18N
                jc.getClass().getName());
      }
    }

    if (accept(jc) && !(jc instanceof JPanel)) {
      jc.addPropertyChangeListener("name", this);
      if (wizardPage.getMapKeyFor(jc) != null) {
        wizardPage.maybeUpdateMap(jc);
      }
    }

    if (logger.isLoggable(Level.FINE) && accept(jc)) {
      logger.fine("Begin listening to " + jc); // NOI18N
    }
  }
コード例 #11
0
  private void makeGridOverlay(int centerX, int centerY) {
    IJ.setTool(Toolbar.SPARE2);
    Overlay overlay = vad_.getImagePlus().getOverlay();
    if (overlay == null || overlay.size() == 0) {
      overlay = new Overlay();
    } else {
      overlay.clear();
    }

    int gridWidth = (Integer) gridXSpinner_.getValue();
    int gridHeight = (Integer) gridYSpinner_.getValue();
    int roiWidth = gridWidth * tileWidth_;
    int roiHeight = gridHeight * tileHeight_;

    Roi rectangle = new Roi(centerX - roiWidth / 2, centerY - roiHeight / 2, roiWidth, roiHeight);
    rectangle.setStrokeWidth(20f);
    overlay.add(rectangle);
    vad_.getImagePlus().setOverlay(overlay);
  }
コード例 #12
0
ファイル: MyDateChooseBtn.java プロジェクト: singleD/se2
    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);
    }
コード例 #13
0
  private void onOK() {

    String columnNames[] = {"Clerk", "Salary"};
    int month = (int) monthSpinner.getValue();
    Object rowData[][] = saleSystem.salaryCheck.salaryRowDataProduce(month);

    JTable table = new JTable(rowData, columnNames);

    tcl = new TableCellListener(table, action);

    tableInitialise(table);
  }
コード例 #14
0
 private void resetPanel() {
   cal =
       new GregorianCalendar(
           Integer.parseInt(yearSpi.getValue().toString()),
           monthBox.getSelectedIndex(),
           Integer.parseInt(lastLabel.getText()));
   startPoint_x = 20;
   startPoint_y = 10;
   panel.removeAll();
   panel.repaint();
   initCalPanel();
 }
コード例 #15
0
ファイル: GenericListener.java プロジェクト: q1051278389/HMCL
  protected void detachFrom(Component jc) {
    listenedTo.remove(jc);
    if (extListener != null && extListener.accept(jc)) {
      extListener.stopListeningTo(jc);
    }
    if (isProbablyAContainer(jc)) {
      detachFromHierarchyOf((Container) jc);
    } else if (jc instanceof JList) {
      ((JList) jc).removeListSelectionListener(this);
    } else if (jc instanceof JComboBox) {
      ((JComboBox) jc).removeActionListener(this);
    } else if (jc instanceof JTree) {
      ((JTree) jc).getSelectionModel().removeTreeSelectionListener(this);
    } else if (jc instanceof JToggleButton) {
      ((AbstractButton) jc).removeActionListener(this);
    } else if (jc instanceof JTextComponent) {
    } else if (jc
        instanceof JFormattedTextField) { // JFormattedTextField must be tested before JTextCompoent
      jc.removePropertyChangeListener("value", this);
      ((JTextComponent) jc).getDocument().removeDocumentListener(this);
    } else if (jc instanceof JColorChooser) {
      ((JColorChooser) jc).getSelectionModel().removeChangeListener(this);
    } else if (jc instanceof JSpinner) {
      ((JSpinner) jc).removeChangeListener(this);
    } else if (jc instanceof JSlider) {
      ((JSlider) jc).removeChangeListener(this);
    } else if (jc instanceof JTable) {
      ((JTable) jc).getSelectionModel().removeListSelectionListener(this);
    }

    if (accept(jc) && !(jc instanceof JPanel)) {
      jc.removePropertyChangeListener("name", this);
      Object key = wizardPage.getMapKeyFor(jc);

      if (key != null) {
        if (logger.isLoggable(Level.FINE)) {
          logger.fine(
              "Named component removed from hierarchy: "
                  + // NOI18N
                  key
                  + ".  Removing any corresponding "
                  + // NOI18N
                  "value from the wizard settings map."); // NOI18N
        }

        wizardPage.removeFromMap(key);
      }
    }

    if (logger.isLoggable(Level.FINE) && accept(jc)) {
      logger.fine("Stop listening to " + jc); // NOI18N
    }
  }
コード例 #16
0
  public void setAdvancedValues() {
    // get pretty ranges for the current parameters
    // get the range for the station value
    double min = 10000;
    double max = 0;
    for (int fc = 0; fc < mFileViewer.mNumOpenFiles; fc++) {
      OpenDataFile of = (OpenDataFile) mFileViewer.mOpenFiles.elementAt(fc);

      for (int sec = 0; sec < of.mNumSections; sec++) {
        Section sech = (Section) of.mSections.elementAt(sec);

        if (sech.mNumCasts == 0) {
          continue;
        }

        for (int stc = 0; stc < sech.mStations.size(); stc++) {
          Station sh = (Station) sech.mStations.elementAt(stc);
          if (!sh.mUseStn) {
            continue;
          }

          // get the station value
          double y = sh.getStnValue(mSelYParam);
          if (y == JOAConstants.MISSINGVALUE || y >= JOAConstants.EPICMISSINGVALUE) {
            continue;
          } else {
            min = y < min ? y : min;
            max = y > max ? y : max;
          }
        }
      }
    }

    Triplet newRange = JOAFormulas.GetPrettyRange(min, max);
    double yMinv = newRange.getVal1();
    double yMaxv = newRange.getVal2();
    double yIncv = newRange.getVal3();
    yMin.setText(JOAFormulas.formatDouble(String.valueOf(yMinv), 3, false));
    yMax.setText(JOAFormulas.formatDouble(String.valueOf(yMaxv), 3, false));
    yInc.setText(JOAFormulas.formatDouble(String.valueOf(yIncv), 3, false));
    yTics.setValue(new Integer(yTicsVal));
    if (b1.isSelected()) {
      mOffset = JOAConstants.PROFSEQUENCE;
      setXRangeToSequence();
    } else if (b2.isSelected()) {
      mOffset = JOAConstants.PROFDISTANCE;
      setXRangeToDistance();
    } else if (b3.isSelected()) {
      mOffset = JOAConstants.PROFTIME;
      setXRangeToTime();
    }
  }
コード例 #17
0
  // Add course method
  public void addCourse() {
    try {
      Database db = new Database();

      String coursename = (String) coursecombobox.getSelectedItem();
      if (coursecombobox.getSelectedIndex() == 0) {
        throw new Exception("No course selected");
      }

      float fees = db.getCoursefees(coursename);
      float totalfees = fees + (ims.main.Settings.getInstallment() * (int) spinner.getValue());

      long id = (long) table.getValueAt((int) table.getSelectionModel().getMinSelectionIndex(), 0);

      db.addCourseToCurrentStudent(id, totalfees, (int) spinner.getValue(), coursename);

      updateFeesData(id);
      courseReset();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, e.getMessage(), null, JOptionPane.ERROR_MESSAGE);
    }
  }
コード例 #18
0
 public void setXRangeToDistance() {
   hideTime();
   // set the x axis from the total mercator distance
   double tempXMin = 0;
   double tempXMax = mFileViewer.mTotMercDist * 1.852;
   Triplet newRange = JOAFormulas.GetPrettyRange(tempXMin, tempXMax);
   double xMinv = newRange.getVal1();
   double xMaxv = newRange.getVal2();
   double xIncv = newRange.getVal3();
   xMin.setText(JOAFormulas.formatDouble(String.valueOf(xMinv), 3, false));
   xMax.setText(JOAFormulas.formatDouble(String.valueOf(xMaxv), 3, false));
   xInc.setText(JOAFormulas.formatDouble(String.valueOf(xIncv), 3, false));
   xTics.setValue(new Integer(xTicsVal));
 }
コード例 #19
0
 public void setXRangeToSequence() {
   hideTime();
   // set the x axis from the total mercator distance
   double tempXMin = 0;
   double tempXMax = mFileViewer.mTotalStations;
   Triplet newRange = JOAFormulas.GetPrettyRange(tempXMin, tempXMax);
   double xMinv = newRange.getVal1();
   double xMaxv = newRange.getVal2();
   double xIncv = newRange.getVal3();
   xMin.setText(String.valueOf((int) xMinv));
   xMax.setText(String.valueOf((int) xMaxv));
   xInc.setText(String.valueOf((int) xIncv));
   xTics.setValue(new Integer(xTicsVal));
 }
コード例 #20
0
ファイル: PlayerWaitingView.java プロジェクト: 255/catan
  @Override
  public void setAIChoices(String[] value) {

    java.util.List<String> choiceList = new ArrayList<String>();
    for (String v : value) {
      choiceList.add(v);
    }

    aiModel.setList(choiceList);

    if (value.length > 0) {
      aiChoices.setValue(value[0]);
    }
  }
コード例 #21
0
  // calculate and display amounts
  private void calculateJButtonActionPerformed(ActionEvent event) {
    // declare variables to store user input
    double principal = Double.parseDouble(principalJTextField.getText());
    double rate = Double.parseDouble(interestRateJTextField.getText());

    Integer integerObject = (Integer) yearsJSpinner.getValue();
    Integer year = integerObject.intValue();

    yearlyBalanceJTextArea.setText("Year\tAmount on Deposit");
    DecimalFormat dollars = new DecimalFormat("$0.00");

    // calculate the total value for each year
    for (int count = 1; count <= year; count++) {
      double amount = principal * Math.pow((1 + rate / 100), count);
      yearlyBalanceJTextArea.append("\n" + count + "\t" + dollars.format(amount));
    } // end for
  } // end method calculateJButtonActionPerformed
コード例 #22
0
  private void addEventListener() {
    btn.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            int year = cal.get(Calendar.YEAR);
            int month = cal.get(Calendar.MONTH);
            String date = lastLabel.getText();
            String str2 = month + 1 + "";
            String str3 = date;
            if (month + 1 < 10) {
              str2 = "0" + (month + 1);
            }

            if (Integer.valueOf(date) < 10) {
              str3 = "0" + date;
            }
            text.setText(year + "-" + str2 + "-" + str3);
            MySimpleCal.this.dispose();
          }
        });

    monthBox.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            resetPanel();
          }
        });

    yearSpi.addChangeListener(
        new ChangeListener() {

          public void stateChanged(ChangeEvent e) {
            resetPanel();
          }
        });
  }
コード例 #23
0
ファイル: Shapes.java プロジェクト: syzh1991/DigitalEarth
    private JPanel makeInteriorAttributesPanel() {
      JPanel outerPanel = new JPanel(new BorderLayout(6, 6));
      outerPanel.setBorder(this.createTitleBorder("Surface Attributes"));

      GridLayout nameLayout = new GridLayout(0, 1, 6, 6);
      JPanel namePanel = new JPanel(nameLayout);

      GridLayout valueLayout = new GridLayout(0, 1, 6, 6);
      JPanel valuePanel = new JPanel(valueLayout);

      namePanel.add(new JLabel("Style"));
      final JComboBox cb1 = new JComboBox(new String[] {"None", "Solid"});
      cb1.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentInteriorStyle = (String) cb1.getSelectedItem();
              update();
            }
          });
      cb1.setSelectedItem("Solid");
      valuePanel.add(cb1);

      namePanel.add(new JLabel("Opacity"));
      JSpinner sp = new JSpinner(new SpinnerNumberModel(this.currentBorderOpacity, 0, 10, 1));
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              currentInteriorOpacity = (Integer) ((JSpinner) changeEvent.getSource()).getValue();
              update();
            }
          });
      valuePanel.add(sp);

      namePanel.add(new JLabel("Color"));
      final JComboBox cb2 = new JComboBox(new String[] {"Red", "Green", "Blue", "Yellow"});
      cb2.setSelectedItem(currentInteriorColor);
      cb2.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentInteriorColor =
                  (String) ((JComboBox) actionEvent.getSource()).getSelectedItem();
              update();
            }
          });
      valuePanel.add(cb2);

      namePanel.add(new JLabel("Border"));
      final JComboBox cb5 = new JComboBox(new String[] {"None", "Solid"});
      cb5.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentBorderStyle = (String) cb5.getSelectedItem();
              update();
            }
          });
      cb5.setSelectedItem("Solid");
      valuePanel.add(cb5);

      namePanel.add(new JLabel("Border Width"));
      sp = new JSpinner(new SpinnerNumberModel(this.currentBorderWidth, 1d, 10d, 1d));
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              currentBorderWidth = (Double) ((JSpinner) changeEvent.getSource()).getValue();
              update();
            }
          });
      sp.setValue(currentBorderWidth);
      valuePanel.add(sp);

      namePanel.add(new JLabel("Border Color"));
      JComboBox cb4 = new JComboBox(new String[] {"Red", "Green", "Blue", "Yellow"});
      cb4.setSelectedItem(currentBorderColor);
      cb4.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentBorderColor = (String) ((JComboBox) actionEvent.getSource()).getSelectedItem();
              update();
            }
          });
      valuePanel.add(cb4);

      namePanel.add(new JLabel("Border Opacity"));
      sp = new JSpinner(new SpinnerNumberModel(this.currentBorderOpacity, 0, 10, 1));
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              currentBorderOpacity = (Integer) ((JSpinner) changeEvent.getSource()).getValue();
              update();
            }
          });
      valuePanel.add(sp);

      outerPanel.add(namePanel, BorderLayout.WEST);
      outerPanel.add(valuePanel, BorderLayout.CENTER);

      return outerPanel;
    }
コード例 #24
0
ファイル: Shapes.java プロジェクト: syzh1991/DigitalEarth
    private JPanel makePathAttributesPanel() {
      JPanel outerPanel = new JPanel(new BorderLayout(6, 6));
      outerPanel.setBorder(this.createTitleBorder("Path Attributes"));

      GridLayout nameLayout = new GridLayout(0, 1, 6, 6);
      JPanel namePanel = new JPanel(nameLayout);

      GridLayout valueLayout = new GridLayout(0, 1, 6, 6);
      JPanel valuePanel = new JPanel(valueLayout);

      namePanel.add(new JLabel("Follow Terrain"));
      JCheckBox ckb = new JCheckBox();
      ckb.setSelected(currentFollowTerrain);
      ckb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentFollowTerrain = ((JCheckBox) actionEvent.getSource()).isSelected();
              update();
            }
          });
      valuePanel.add(ckb);

      JLabel label;

      namePanel.add(label = new JLabel("Conformance"));
      int[] values = new int[] {1, 2, 4, 8, 10, 15, 20, 30, 40, 50};
      String[] strings = new String[values.length];
      for (int i = 0; i < values.length; i++) {
        strings[i] = Integer.toString(values[i]) + " pixels";
      }
      JSpinner sp = new JSpinner(new SpinnerListModel(strings));
      onTerrainOnlyItems.add(label);
      onTerrainOnlyItems.add(sp);
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              String v = (String) ((JSpinner) changeEvent.getSource()).getValue();
              currentTerrainConformance = Integer.parseInt(v.substring(0, v.indexOf(" ")));
              update();
            }
          });
      sp.setValue(Integer.toString(currentTerrainConformance) + " pixels");
      valuePanel.add(sp);

      namePanel.add(label = new JLabel("Subsegments"));
      sp = new JSpinner(new SpinnerListModel(new String[] {"1", "2", "5", "10", "20", "40", "50"}));
      offTerrainOnlyItems.add(label);
      offTerrainOnlyItems.add(sp);
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              String v = (String) ((JSpinner) changeEvent.getSource()).getValue();
              currentNumSubsegments = Integer.parseInt(v);
              update();
            }
          });
      sp.setValue(Integer.toString(currentNumSubsegments));
      valuePanel.add(sp);

      namePanel.add(new JLabel("Type"));
      final JComboBox cb = new JComboBox(new String[] {"Great Circle", "Linear", "Rhumb Line"});
      cb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentPathType = (String) cb.getSelectedItem();
              update();
            }
          });
      cb.setSelectedItem("Great Circle");
      valuePanel.add(cb);

      namePanel.add(new JLabel("Style"));
      final JComboBox cb1 = new JComboBox(new String[] {"None", "Solid", "Dash"});
      cb1.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentPathStyle = (String) cb1.getSelectedItem();
              update();
            }
          });
      cb1.setSelectedItem("Solid");
      valuePanel.add(cb1);

      namePanel.add(new JLabel("Width"));
      sp = new JSpinner(new SpinnerNumberModel(this.currentPathWidth, 1d, 10d, 1d));
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              currentPathWidth = (Double) ((JSpinner) changeEvent.getSource()).getValue();
              update();
            }
          });
      sp.setValue(currentPathWidth);
      valuePanel.add(sp);

      namePanel.add(new JLabel("Color"));
      JComboBox cb2 = new JComboBox(new String[] {"Red", "Green", "Blue", "Yellow"});
      cb2.setSelectedItem(currentPathColor);
      cb2.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              currentPathColor = (String) ((JComboBox) actionEvent.getSource()).getSelectedItem();
              update();
            }
          });
      valuePanel.add(cb2);

      namePanel.add(new JLabel("Opacity"));
      sp = new JSpinner(new SpinnerNumberModel(this.currentPathOpacity, 0, 10, 1));
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              currentPathOpacity = (Integer) ((JSpinner) changeEvent.getSource()).getValue();
              update();
            }
          });
      valuePanel.add(sp);

      namePanel.add(new JLabel("Offset"));
      sp =
          new JSpinner(
              new SpinnerListModel(
                  new String[] {"0", "10", "100", "1000", "10000", "100000", "1000000"}));
      sp.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
              currentOffset =
                  Float.parseFloat((String) ((JSpinner) changeEvent.getSource()).getValue());
              update();
            }
          });
      sp.setValue("0");
      valuePanel.add(sp);

      outerPanel.add(namePanel, BorderLayout.WEST);
      outerPanel.add(valuePanel, BorderLayout.CENTER);

      return outerPanel;
    }
コード例 #25
0
  /**
   * Creates, binds and configures the UI components.
   *
   * <p>If possible, the components are created using the BasicComponentFactory, or the Bindings
   * class.
   */
  private void initComponents() {
    // Text Components
    textField =
        BasicComponentFactory.createTextField(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_TEXT));
    textArea =
        BasicComponentFactory.createTextArea(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_TEXT));
    passwordField =
        BasicComponentFactory.createPasswordField(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_TEXT));
    textLabel =
        BasicComponentFactory.createLabel(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_TEXT));

    // Formatted Input
    dateField =
        BasicComponentFactory.createDateField(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_DATE));
    integerField =
        BasicComponentFactory.createIntegerField(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_INT_VALUE));
    longField =
        BasicComponentFactory.createLongField(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_LONG_VALUE));

    // Choice
    ValueModel intChoiceModel = presentationModel.getModel(ExampleBean.PROPERTYNAME_INT_CHOICE);
    leftIntRadio =
        BasicComponentFactory.createRadioButton(intChoiceModel, ExampleBean.LEFT_INTEGER, "Left");
    centerIntRadio =
        BasicComponentFactory.createRadioButton(
            intChoiceModel, ExampleBean.CENTER_INTEGER, "Center");
    rightIntRadio =
        BasicComponentFactory.createRadioButton(intChoiceModel, ExampleBean.RIGHT_INTEGER, "Right");
    alignmentIntCombo =
        BasicComponentFactory.createComboBox(
            new SelectionInList(ExampleBean.INTEGER_CHOICES, intChoiceModel));

    ValueModel objectChoiceModel =
        presentationModel.getModel(ExampleBean.PROPERTYNAME_OBJECT_CHOICE);
    leftObjectRadio =
        BasicComponentFactory.createRadioButton(objectChoiceModel, ExampleBean.LEFT, "Left");
    centerObjectRadio =
        BasicComponentFactory.createRadioButton(objectChoiceModel, ExampleBean.CENTER, "Center");
    rightObjectRadio =
        BasicComponentFactory.createRadioButton(objectChoiceModel, ExampleBean.RIGHT, "Right");
    alignmentObjectCombo =
        BasicComponentFactory.createComboBox(
            new SelectionInList(ExampleBean.OBJECT_CHOICES, objectChoiceModel));

    // Lists
    comboBox =
        BasicComponentFactory.createComboBox(
            presentationModel.getSelectionInList(), TutorialUtils.createAlbumListCellRenderer());

    list =
        BasicComponentFactory.createList(
            presentationModel.getSelectionInList(), TutorialUtils.createAlbumListCellRenderer());

    table = new JTable();
    table.setModel(TutorialUtils.createAlbumTableModel(presentationModel.getSelectionInList()));
    table.setSelectionModel(
        new SingleListSelectionAdapter(
            presentationModel.getSelectionInList().getSelectionIndexHolder()));

    // Misc
    checkBox =
        BasicComponentFactory.createCheckBox(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_BOOLEAN_VALUE), "available");
    colorPreview = new JPanel();
    colorPreview.setBorder(new LineBorder(Color.GRAY));
    updatePreviewPanel();

    ValueModel floatModel = presentationModel.getModel(ExampleBean.PROPERTYNAME_FLOAT_VALUE);
    slider = new JSlider();
    slider.setModel(
        new BoundedRangeAdapter(
            ConverterFactory.createFloatToIntegerConverter(floatModel, 100), 0, 0, 100));
    floatLabel =
        BasicComponentFactory.createLabel(
            ConverterFactory.createStringConverter(floatModel, NumberFormat.getPercentInstance()));
    spinner = new JSpinner();
    spinner.setModel(
        SpinnerAdapterFactory.createNumberAdapter(
            presentationModel.getModel(ExampleBean.PROPERTYNAME_INT_LIMITED),
            0, // defaultValue
            0, // minValue
            100, // maxValue
            5)); // step
  }
コード例 #26
0
  /**
   * Set up the calendar panel with the basic layout and components. These are not date specific.
   */
  private void createCalendarComponents() {
    // The date panel will hold the calendar and/or the time spinner

    JPanel datePanel = new JPanel(new BorderLayout(2, 2));

    // Create the calendar if we are displaying a calendar

    if ((selectedComponents & DISPLAY_DATE) > 0) {
      formatMonth = new SimpleDateFormat("MMM", locale);
      formatWeekDay = new SimpleDateFormat("EEE", locale);

      // Set up the shared keyboard bindings

      setInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, inputMap);
      setActionMap(actionMap);

      // Set up the decrement buttons

      yearDecrButton =
          new JButton(
              new ButtonAction(
                  "YearDecrButton",
                  "YearDecrButtonMnemonic",
                  "YearDecrButtonAccelerator",
                  "YearDecrButtonImage",
                  "YearDecrButtonShort",
                  "YearDecrButtonLong",
                  YEAR_DECR_BUTTON));
      monthDecrButton =
          new JButton(
              new ButtonAction(
                  "MonthDecrButton",
                  "MonthDecrButtonMnemonic",
                  "MonthDecrButtonAccelerator",
                  "MonthDecrButtonImage",
                  "MonthDecrButtonShort",
                  "MonthDecrButtonLong",
                  MONTH_DECR_BUTTON));
      JPanel decrPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0));
      decrPanel.add(yearDecrButton);
      decrPanel.add(monthDecrButton);

      // Set up the month/year label

      monthYearLabel = new JLabel();
      monthYearLabel.setHorizontalAlignment(JLabel.CENTER);

      // Set up the increment buttons

      monthIncrButton =
          new JButton(
              new ButtonAction(
                  "MonthIncrButton",
                  "MonthIncrButtonMnemonic",
                  "MonthIncrButtonAccelerator",
                  "MonthIncrButtonImage",
                  "MonthIncrButtonShort",
                  "MonthIncrButtonLong",
                  MONTH_INCR_BUTTON));
      yearIncrButton =
          new JButton(
              new ButtonAction(
                  "YearIncrButton",
                  "YearIncrButtonMnemonic",
                  "YearIncrButtonAccelerator",
                  "YearIncrButtonImage",
                  "YearIncrButtonShort",
                  "YearIncrButtonLong",
                  YEAR_INCR_BUTTON));
      JPanel incrPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0));
      incrPanel.add(monthIncrButton);
      incrPanel.add(yearIncrButton);

      // Put them all together

      JPanel monthYearNavigator = new JPanel(new BorderLayout(2, 2));
      monthYearNavigator.add(decrPanel, BorderLayout.WEST);
      monthYearNavigator.add(monthYearLabel);
      monthYearNavigator.add(incrPanel, BorderLayout.EAST);

      // Set up the day panel

      JPanel dayPanel = new JPanel(new GridLayout(7, 7));
      int firstDay = displayCalendar.getFirstDayOfWeek();

      // Get the week day labels. The following technique is used so
      // that we can start the calendar on the right day of the week and
      // we can get the week day labels properly localized

      Calendar temp = Calendar.getInstance(locale);
      temp.set(2000, Calendar.MARCH, 15);
      while (temp.get(Calendar.DAY_OF_WEEK) != firstDay) {
        temp.add(Calendar.DATE, 1);
      }
      dayOfWeekLabels = new JLabel[7];
      for (int i = 0; i < 7; i++) {
        Date date = temp.getTime();
        String dayOfWeek = formatWeekDay.format(date);
        dayOfWeekLabels[i] = new JLabel(dayOfWeek);
        dayOfWeekLabels[i].setHorizontalAlignment(JLabel.CENTER);
        dayPanel.add(dayOfWeekLabels[i]);
        temp.add(Calendar.DATE, 1);
      }

      // Add all the day buttons

      dayButtons = new JToggleButton[6][7];
      dayGroup = new ButtonGroup();
      DayListener dayListener = new DayListener();
      for (int row = 0; row < 6; row++) {
        for (int day = 0; day < 7; day++) {
          dayButtons[row][day] = new JToggleButton();
          dayButtons[row][day].addItemListener(dayListener);
          dayPanel.add(dayButtons[row][day]);
          dayGroup.add(dayButtons[row][day]);
        }
      }

      // We add this special button to the button group, so we have a
      // way of unselecting all the visible buttons

      offScreenButton = new JToggleButton("X");
      dayGroup.add(offScreenButton);

      // Combine the navigators and days

      datePanel.add(monthYearNavigator, BorderLayout.NORTH);
      datePanel.add(dayPanel);
    }

    // Create the time spinner field if we are displaying the time

    if ((selectedComponents & DISPLAY_TIME) > 0) {

      // Create the time component

      spinnerDateModel = new SpinnerDateModel();
      spinnerDateModel.addChangeListener(new TimeListener());
      spinner = new JSpinner(spinnerDateModel);

      JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(spinner, timePattern);
      dateEditor.getTextField().setEditable(false);
      dateEditor.getTextField().setHorizontalAlignment(JTextField.CENTER);
      spinner.setEditor(dateEditor);

      // Set the input/action maps for the spinner. (Only BACK_SPACE
      // seems to work!)

      InputMap sim = new InputMap();
      sim.put(KeyStroke.getKeyStroke("BACK_SPACE"), "setNullDate");
      sim.put(KeyStroke.getKeyStroke("DELETE"), "setNullDate");
      sim.setParent(spinner.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));

      ActionMap sam = new ActionMap();
      sam.put(
          "setNullDate",
          new AbstractAction("setNullDate") {
            public void actionPerformed(ActionEvent e) {
              JCalendar.this.setDate(null);
            }
          });
      sam.setParent(spinner.getActionMap());

      spinner.setInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, sim);
      spinner.setActionMap(sam);

      // Create a special panel for the time display

      JPanel timePanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 2, 2));
      timePanel.add(spinner);

      // Now add it to the bottom

      datePanel.add(timePanel, BorderLayout.SOUTH);
    }

    setLayout(new BorderLayout(2, 2));
    add(datePanel);

    // Add today's date at the bottom of the calendar/time, if needed

    if (isTodayDisplayed) {
      Object[] args = {new Date()};
      String todaysDate = MessageFormat.format(bundle.getString("Today"), args);
      todaysLabel = new JLabel(todaysDate);
      todaysLabel.setHorizontalAlignment(JLabel.CENTER);

      // Add today's date at the very bottom

      add(todaysLabel, BorderLayout.SOUTH);
    }
  }
コード例 #27
0
 /** Add the given input/action maps to the spinner. */
 void addSpinnerMaps(InputMap sim, ActionMap sam) {
   sim.setParent(spinner.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
   spinner.setInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, sim);
   sam.setParent(spinner.getActionMap());
   spinner.setActionMap(sam);
 }
コード例 #28
0
  /** Update the calendar panel to display the currently selected date. */
  private void updateCalendarComponents() {
    if ((selectedComponents & DISPLAY_DATE) > 0) {

      // Unselect all visible dates

      offScreenButton.setSelected(true);

      // Get the display date. We only need the month and year

      displayMonth = displayCalendar.get(Calendar.MONTH);
      displayYear = displayCalendar.get(Calendar.YEAR);

      // Get the localized display month name and year

      String month = formatMonth.format(displayCalendar.getTime());
      String year = Integer.toString(displayYear);

      {
        Object[] args = {month, year};
        monthYearLabel.setText(MessageFormat.format(bundle.getString("MonthYearTitle"), args));
      }

      // If the month or year have changed, we need to re-lay out
      // the days. Otherwise, we don't

      if (!month.equals(lastMonth) || !year.equals(lastYear)) {

        // Create a temporary calendar that we will use to
        // determine where day 1 goes and how many days there are
        // in this month

        Calendar temp = (Calendar) displayCalendar.clone();
        temp.set(Calendar.DATE, 1);

        int dayOfWeek = temp.get(Calendar.DAY_OF_WEEK);
        int firstDay = temp.getFirstDayOfWeek();

        // Determine how many blank slots occur before day 1 of this
        // month

        int dayPtr;
        for (dayPtr = 0; dayPtr < 7; dayPtr++) {
          int curDay = ((firstDay - 1) + dayPtr) % 7 + 1;
          if (curDay != dayOfWeek) {
            dayButtons[0][dayPtr].setText("");
            dayButtons[0][dayPtr].setEnabled(false);
          } else {
            break;
          }
        }

        // Determine the number of days in this month

        int maxDays = temp.getActualMaximum(Calendar.DATE);

        // Fill in the days

        int row = 0;
        for (int day = 1; day <= maxDays; day++) {
          dayButtons[row][dayPtr].setText(Integer.toString(day));
          dayButtons[row][dayPtr].setEnabled(true);

          // If this is the selected date, select the button;
          // otherwise, deselect it

          if (day == selectedDay && displayMonth == selectedMonth && displayYear == selectedYear) {
            dayButtons[row][dayPtr].setSelected(true);
          } else {
            dayButtons[row][dayPtr].getModel().setSelected(false);
          }

          // Wrap as needed

          dayPtr = (dayPtr + 1) % 7;
          if (dayPtr == 0) row++;
        }

        // Set the blanks slots after the last day

        while (row < 6) {
          dayButtons[row][dayPtr].setText("");
          dayButtons[row][dayPtr].setEnabled(false);
          dayButtons[row][dayPtr].getModel().setSelected(false);
          dayPtr = (dayPtr + 1) % 7;
          if (dayPtr == 0) row++;
        }
      }
    }

    // Update the time component, if displayed

    if ((selectedComponents & DISPLAY_TIME) > 0) {

      // If no date is selected, we set the date used by the time
      // field to today @ noon. We also make the field insensitive
      // -- the user must pick a non-null date before being able to
      // change the time (unless all we have is a time field)

      if (isNullDate) {
        Calendar temp = (Calendar) selectedCalendar.clone();
        temp.setTime(new Date());
        temp.set(Calendar.HOUR, 12);
        temp.set(Calendar.MINUTE, 0);
        temp.set(Calendar.SECOND, 0);
        spinnerDateModel.setValue(temp.getTime());
        spinner.setEnabled((selectedComponents & DISPLAY_DATE) == 0);
      }

      // If a date is selected, use it

      else {
        spinner.setEnabled(JCalendar.this.isEnabled());
        spinnerDateModel.setValue(selectedCalendar.getTime());
        spinnerDateModel.setStart(null);
        spinnerDateModel.setEnd(null);
        spinner.revalidate();
      }
    }
  }
コード例 #29
0
  // create and position GUI components; register event handlers
  private void createUserInterface() {
    // get content pane for attaching GUI components
    Container contentPane = getContentPane();

    // enable explicit positioning of GUI components
    contentPane.setLayout(null);

    // set up principalJLabel
    principalJLabel = new JLabel();
    principalJLabel.setBounds(16, 16, 56, 24);
    principalJLabel.setText("Principal:");
    contentPane.add(principalJLabel);

    // set up principalJTextField
    principalJTextField = new JTextField();
    principalJTextField.setBounds(100, 16, 100, 24);
    principalJTextField.setHorizontalAlignment(JTextField.RIGHT);
    contentPane.add(principalJTextField);

    // set up interestRateJLabel
    interestRateJLabel = new JLabel();
    interestRateJLabel.setBounds(16, 56, 80, 24);
    interestRateJLabel.setText("Interest rate:");
    contentPane.add(interestRateJLabel);

    // set up interestRateJTextField
    interestRateJTextField = new JTextField();
    interestRateJTextField.setBounds(100, 56, 100, 24);
    interestRateJTextField.setHorizontalAlignment(JTextField.RIGHT);
    contentPane.add(interestRateJTextField);

    // set up yearsJLabel
    yearsJLabel = new JLabel();
    yearsJLabel.setBounds(16, 96, 48, 24);
    yearsJLabel.setText("Years:");
    contentPane.add(yearsJLabel);

    // set up yearsJSpinner
    yearsJSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 10, 1));
    yearsJSpinner.setBounds(100, 96, 100, 24);
    contentPane.add(yearsJSpinner);

    // set up yearlyBalanceJLabel
    yearlyBalanceJLabel = new JLabel();
    yearlyBalanceJLabel.setBounds(16, 136, 150, 24);
    yearlyBalanceJLabel.setText("Yearly account balance:");
    contentPane.add(yearlyBalanceJLabel);

    // set up yearlyBalanceJTextArea
    yearlyBalanceJTextArea = new JTextArea();
    yearlyBalanceJTextArea.setEditable(false);

    // set up yearlyBalanceJScrollPane
    yearlyBalanceJScrollPane = new JScrollPane(yearlyBalanceJTextArea);
    yearlyBalanceJScrollPane.setBounds(16, 160, 300, 92);
    contentPane.add(yearlyBalanceJScrollPane);

    // set up calculateJButton
    calculateJButton = new JButton();
    calculateJButton.setBounds(216, 16, 100, 24);
    calculateJButton.setText("Calculate");
    contentPane.add(calculateJButton);
    calculateJButton.addActionListener(
        new ActionListener() // anonymous inner class
        {
          // event handler called when calculateJButton is clicked
          public void actionPerformed(ActionEvent event) {
            calculateJButtonActionPerformed(event);
          }
        } // end anonymous inner class
        ); // end call to addActionListener

    // set properties of application's window
    setTitle("Interest Calculator"); // set title bar text
    setSize(340, 296); // set window size
    setVisible(true); // display window
  } // end method createUserInterface
コード例 #30
0
ファイル: MediaConfiguration.java プロジェクト: onsip/jitsi
  /**
   * Creates the video advanced settings.
   *
   * @return video advanced settings panel.
   */
  private static Component createVideoAdvancedSettings() {
    ResourceManagementService resources = NeomediaActivator.getResources();

    final DeviceConfiguration deviceConfig = mediaService.getDeviceConfiguration();

    TransparentPanel centerPanel = new TransparentPanel(new GridBagLayout());
    centerPanel.setMaximumSize(new Dimension(WIDTH, 150));

    JButton resetDefaultsButton =
        new JButton(resources.getI18NString("impl.media.configform.VIDEO_RESET"));
    JPanel resetButtonPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
    resetButtonPanel.add(resetDefaultsButton);

    final JPanel centerAdvancedPanel = new TransparentPanel(new BorderLayout());
    centerAdvancedPanel.add(centerPanel, BorderLayout.NORTH);
    centerAdvancedPanel.add(resetButtonPanel, BorderLayout.SOUTH);

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.insets = new Insets(5, 5, 0, 0);
    constraints.gridx = 0;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.gridy = 0;

    centerPanel.add(
        new JLabel(resources.getI18NString("impl.media.configform.VIDEO_RESOLUTION")), constraints);
    constraints.gridy = 1;
    constraints.insets = new Insets(0, 0, 0, 0);
    final JCheckBox frameRateCheck =
        new SIPCommCheckBox(resources.getI18NString("impl.media.configform.VIDEO_FRAME_RATE"));
    centerPanel.add(frameRateCheck, constraints);
    constraints.gridy = 2;
    constraints.insets = new Insets(5, 5, 0, 0);
    centerPanel.add(
        new JLabel(resources.getI18NString("impl.media.configform.VIDEO_PACKETS_POLICY")),
        constraints);

    constraints.weightx = 1;
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.insets = new Insets(5, 0, 0, 5);
    Object[] resolutionValues = new Object[DeviceConfiguration.SUPPORTED_RESOLUTIONS.length + 1];
    System.arraycopy(
        DeviceConfiguration.SUPPORTED_RESOLUTIONS,
        0,
        resolutionValues,
        1,
        DeviceConfiguration.SUPPORTED_RESOLUTIONS.length);
    final JComboBox sizeCombo = new JComboBox(resolutionValues);
    sizeCombo.setRenderer(new ResolutionCellRenderer());
    sizeCombo.setEditable(false);
    centerPanel.add(sizeCombo, constraints);

    // default value is 20
    final JSpinner frameRate = new JSpinner(new SpinnerNumberModel(20, 5, 30, 1));
    frameRate.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            deviceConfig.setFrameRate(
                ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue());
          }
        });
    constraints.gridy = 1;
    constraints.insets = new Insets(0, 0, 0, 5);
    centerPanel.add(frameRate, constraints);

    frameRateCheck.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (frameRateCheck.isSelected()) {
              deviceConfig.setFrameRate(
                  ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue());
            } else // unlimited framerate
            deviceConfig.setFrameRate(-1);

            frameRate.setEnabled(frameRateCheck.isSelected());
          }
        });

    final JSpinner videoMaxBandwidth =
        new JSpinner(
            new SpinnerNumberModel(deviceConfig.getVideoMaxBandwidth(), 1, Integer.MAX_VALUE, 1));
    videoMaxBandwidth.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            deviceConfig.setVideoMaxBandwidth(
                ((SpinnerNumberModel) videoMaxBandwidth.getModel()).getNumber().intValue());
          }
        });
    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.insets = new Insets(0, 0, 5, 5);
    centerPanel.add(videoMaxBandwidth, constraints);

    resetDefaultsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // reset to defaults
            sizeCombo.setSelectedIndex(0);
            frameRateCheck.setSelected(false);
            frameRate.setEnabled(false);
            frameRate.setValue(20);
            // unlimited framerate
            deviceConfig.setFrameRate(-1);
            videoMaxBandwidth.setValue(DeviceConfiguration.DEFAULT_VIDEO_MAX_BANDWIDTH);
          }
        });

    // load selected value or auto
    Dimension videoSize = deviceConfig.getVideoSize();

    if ((videoSize.getHeight() != DeviceConfiguration.DEFAULT_VIDEO_HEIGHT)
        && (videoSize.getWidth() != DeviceConfiguration.DEFAULT_VIDEO_WIDTH))
      sizeCombo.setSelectedItem(deviceConfig.getVideoSize());
    else sizeCombo.setSelectedIndex(0);
    sizeCombo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Dimension selectedVideoSize = (Dimension) sizeCombo.getSelectedItem();

            if (selectedVideoSize == null) {
              // the auto value, default one
              selectedVideoSize =
                  new Dimension(
                      DeviceConfiguration.DEFAULT_VIDEO_WIDTH,
                      DeviceConfiguration.DEFAULT_VIDEO_HEIGHT);
            }
            deviceConfig.setVideoSize(selectedVideoSize);
          }
        });

    frameRateCheck.setSelected(
        deviceConfig.getFrameRate() != DeviceConfiguration.DEFAULT_VIDEO_FRAMERATE);
    frameRate.setEnabled(frameRateCheck.isSelected());

    if (frameRate.isEnabled()) frameRate.setValue(deviceConfig.getFrameRate());

    return centerAdvancedPanel;
  }