Example #1
0
    private JPanel createCompPanel() {
      filesets = new Vector();

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

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

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

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

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

        filesets.addElement(new Integer(i));

        panel.add(checkBox);
      }

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

      return panel;
    }
  public NameBean() {

    setLayout(LAYOUT.copy());

    cLast = new ChoiceWidget();
    cLast.addChangeListener(changeSupport);
    cLast.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            String msg = getReplaceAllMsg();
            if (msg != null) {
              cAll.setVisible(true);
              cAll.setToolTipText(msg);
            }
          }
        });
    cLast.setIgnoreCase(true);
    cFirst = new ChoiceWidget();
    cFirst.addChangeListener(changeSupport);
    cFirst.setIgnoreCase(true);
    tSuff = new TextFieldWidget("", 10);
    tSuff.addChangeListener(changeSupport);
    tNick = new TextFieldWidget("", 10);
    tNick.addChangeListener(changeSupport);

    cAll = new JCheckBox();
    cAll.setBorder(new EmptyBorder(1, 1, 1, 1));
    cAll.setVisible(false);
    cAll.setRequestFocusEnabled(false);

    add(new JLabel(PropertyName.getLabelForFirstName()));
    add(cFirst);

    add(new JLabel(PropertyName.getLabelForLastName()));
    add(cLast);
    add(cAll);

    add(new JLabel(PropertyName.getLabelForSuffix()));
    add(tSuff);

    add(new JLabel(Gedcom.getName("NICK")));
    add(tNick);

    // listen to selection of global and ask for confirmation
    cAll.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String msg = getReplaceAllMsg();
            if (msg != null && cAll.isSelected()) {
              int rc =
                  DialogHelper.openDialog(
                      RESOURCES.getString("choice.global.enable"),
                      DialogHelper.QUESTION_MESSAGE,
                      msg,
                      Action2.yesNo(),
                      NameBean.this);
              cAll.setSelected(rc == 0);
            }
          }
        });

    // we're done aside from declaring the default focus
    defaultFocus = cFirst;
  }