private void initGui() {
    setLayout(new GridBagLayout());

    ButtonGroup contentSourceRadioGroup = new ButtonGroup();
    contentSourceRadioGroup.add(genAttribRadioButton);
    contentSourceRadioGroup.add(fileRadioButton);
    contentSourceRadioGroup.add(genAttribAndFileRadioButton);

    includeDescription.setIconTextGap(10);
    add(
        includeDescription,
        GuiUtil.setConstraints(
            0,
            1,
            2,
            1,
            1.0,
            0.0,
            GridBagConstraints.BOTH,
            BORDER_THICKNESS,
            0,
            BORDER_THICKNESS,
            0));

    contentSourcePanel = new JPanel();
    contentSourcePanel.setLayout(new GridBagLayout());
    contentSourcePanel.setBorder(BorderFactory.createTitledBorder(""));
    add(
        contentSourcePanel,
        GuiUtil.setConstraints(
            0,
            2,
            2,
            1,
            1.0,
            0.0,
            GridBagConstraints.BOTH,
            BORDER_THICKNESS,
            0,
            BORDER_THICKNESS,
            0));

    genAttribRadioButton.setIconTextGap(10);
    fileRadioButton.setIconTextGap(10);
    genAttribAndFileRadioButton.setIconTextGap(10);

    GridBagConstraints garb =
        GuiUtil.setConstraints(
            0, 0, 0.0, 1.0, GridBagConstraints.BOTH, 0, BORDER_THICKNESS, 0, BORDER_THICKNESS);
    garb.gridwidth = 2;
    contentSourcePanel.add(genAttribRadioButton, garb);
    GridBagConstraints frb =
        GuiUtil.setConstraints(
            0, 1, 0.0, 1.0, GridBagConstraints.BOTH, 0, BORDER_THICKNESS, 0, BORDER_THICKNESS);
    frb.gridwidth = 2;
    contentSourcePanel.add(fileRadioButton, frb);
    browseText.setPreferredSize(browseText.getSize());
    contentSourcePanel.add(
        browseText,
        GuiUtil.setConstraints(
            0, 2, 1.0, 1.0, GridBagConstraints.BOTH, 0, BORDER_THICKNESS * 6, 0, 0));
    contentSourcePanel.add(
        browseButton,
        GuiUtil.setConstraints(
            1, 2, 0.0, 1.0, GridBagConstraints.BOTH, 0, BORDER_THICKNESS * 2, 0, BORDER_THICKNESS));
    GridBagConstraints gaafrb =
        GuiUtil.setConstraints(
            0,
            3,
            0.0,
            1.0,
            GridBagConstraints.BOTH,
            BORDER_THICKNESS,
            BORDER_THICKNESS,
            0,
            BORDER_THICKNESS);
    gaafrb.gridwidth = 2;
    contentSourcePanel.add(genAttribAndFileRadioButton, gaafrb);

    contentInSeparateFile.setIconTextGap(10);
    add(
        contentInSeparateFile,
        GuiUtil.setConstraints(
            0, 3, 2, 1, 1.0, 0.0, GridBagConstraints.BOTH, BORDER_THICKNESS, 0, 0, 0));
    add(
        warningLabel,
        GuiUtil.setConstraints(
            0, 4, 2, 1, 1.0, 0.0, GridBagConstraints.BOTH, 0, BORDER_THICKNESS * 6, 0, 0));

    PopupMenuDecorator.getInstance().decorate(browseText);

    includeDescription.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setEnabledComponents();
          }
        });

    browseButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            loadFile();
          }
        });

    genAttribRadioButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setEnabledComponents();
          }
        });

    fileRadioButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setEnabledComponents();
          }
        });

    genAttribAndFileRadioButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setEnabledComponents();
          }
        });
  }
コード例 #2
0
  private void initGui() {
    block1 = new JPanel();
    block2 = new JPanel();
    expResMinThreadsLabel = new JLabel();
    expResMaxThreadsLabel = new JLabel();
    expResGeomLabel = new JLabel();
    expResGeomCacheLabel = new JLabel();
    expResGeomDrainLabel = new JLabel();
    expResGeomPartLabel = new JLabel();
    expResFeatLabel = new JLabel();
    expResFeatCacheLabel = new JLabel();
    expResFeatDrainLabel = new JLabel();
    expResFeatPartLabel = new JLabel();

    DecimalFormat threeIntFormat = new DecimalFormat("###");
    threeIntFormat.setMaximumIntegerDigits(3);
    threeIntFormat.setMinimumIntegerDigits(1);
    expResMinThreadsText = new JFormattedTextField(threeIntFormat);
    expResMaxThreadsText = new JFormattedTextField(threeIntFormat);
    expResGeomDrainText = new JFormattedTextField(threeIntFormat);
    expResFeatDrainText = new JFormattedTextField(threeIntFormat);
    expResGeomPartText = new JFormattedTextField(threeIntFormat);
    expResFeatPartText = new JFormattedTextField(threeIntFormat);

    DecimalFormat cacheEntryFormat = new DecimalFormat("########");
    cacheEntryFormat.setMaximumIntegerDigits(8);
    cacheEntryFormat.setMinimumIntegerDigits(1);
    expResGeomCacheText = new JFormattedTextField(cacheEntryFormat);
    expResFeatCacheText = new JFormattedTextField(cacheEntryFormat);

    PopupMenuDecorator.getInstance()
        .decorate(
            expResMinThreadsText,
            expResMaxThreadsText,
            expResGeomDrainText,
            expResFeatDrainText,
            expResGeomPartText,
            expResFeatPartText,
            expResGeomCacheText,
            expResFeatCacheText);

    expResMinThreadsText.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            checkNonNegative(expResMinThreadsText, 1);
          }
        });

    expResMaxThreadsText.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            checkNonNegative(expResMaxThreadsText, 1);
          }
        });

    expResGeomCacheText.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            checkNonNegative(expResGeomCacheText, 200000);
          }
        });

    expResFeatCacheText.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            checkNonNegative(expResFeatCacheText, 200000);
          }
        });

    expResGeomDrainText.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            checkNonNegativeRange(expResGeomDrainText, 85, 100);
          }
        });

    expResFeatDrainText.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            checkNonNegativeRange(expResFeatDrainText, 85, 100);
          }
        });

    expResGeomPartText.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            checkNonNegativeRange(expResGeomPartText, 10, 100);
          }
        });

    expResFeatPartText.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            checkNonNegativeRange(expResFeatPartText, 10, 100);
          }
        });

    setLayout(new GridBagLayout());
    add(block1, GuiUtil.setConstraints(0, 0, 1.0, 0.0, GridBagConstraints.BOTH, 5, 0, 5, 0));
    block1.setBorder(BorderFactory.createTitledBorder(""));
    block1.setLayout(new GridBagLayout());
    {
      block1.add(
          expResMinThreadsLabel,
          GuiUtil.setConstraints(0, 0, 0.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block1.add(
          expResMinThreadsText,
          GuiUtil.setConstraints(1, 0, 1.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block1.add(
          expResMaxThreadsLabel,
          GuiUtil.setConstraints(0, 1, 0.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block1.add(
          expResMaxThreadsText,
          GuiUtil.setConstraints(1, 1, 1.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
    }

    add(block2, GuiUtil.setConstraints(0, 1, 1.0, 0.0, GridBagConstraints.BOTH, 5, 0, 5, 0));
    block2.setBorder(BorderFactory.createTitledBorder(""));
    block2.setLayout(new GridBagLayout());
    {
      block2.add(
          expResGeomLabel,
          GuiUtil.setConstraints(0, 0, 0.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResGeomCacheText,
          GuiUtil.setConstraints(1, 0, 1.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResGeomCacheLabel,
          GuiUtil.setConstraints(2, 0, 0.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResGeomDrainText,
          GuiUtil.setConstraints(1, 1, 1.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResGeomDrainLabel,
          GuiUtil.setConstraints(2, 1, 0.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResGeomPartText,
          GuiUtil.setConstraints(1, 2, 1.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResGeomPartLabel,
          GuiUtil.setConstraints(2, 2, 0.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResFeatLabel,
          GuiUtil.setConstraints(0, 3, 0.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResFeatCacheText,
          GuiUtil.setConstraints(1, 3, 1.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResFeatCacheLabel,
          GuiUtil.setConstraints(2, 3, 0.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResFeatDrainText,
          GuiUtil.setConstraints(1, 4, 1.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResFeatDrainLabel,
          GuiUtil.setConstraints(2, 4, 0.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResFeatPartText,
          GuiUtil.setConstraints(1, 5, 1.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
      block2.add(
          expResFeatPartLabel,
          GuiUtil.setConstraints(2, 5, 0.0, 1.0, GridBagConstraints.BOTH, 0, 5, 5, 5));
    }
  }