Пример #1
1
  protected JPanel createShowResultPanel() {
    JPanel panel = new JPanel(new GridBagLayout());

    panel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createEtchedBorder(), resources.getString("ShowResultPanel.title")));

    ExtendedGridBagConstraints gbc = new ExtendedGridBagConstraints();
    gbc.insets = new Insets(2, 2, 2, 2);

    gbc.anchor = ExtendedGridBagConstraints.WEST;
    gbc.fill = ExtendedGridBagConstraints.NONE;
    gbc.setWeight(0, 0);

    ButtonGroup grp = new ButtonGroup();

    highlightButton = buttonFactory.createJRadioButton("Highlight");
    highlightButton.setSelected(true);
    grp.add(highlightButton);
    gbc.setGridBounds(0, 0, 1, 1);
    panel.add(highlightButton, gbc);

    highlightCenterButton = buttonFactory.createJRadioButton("HighlightAndCenter");
    grp.add(highlightCenterButton);
    gbc.setGridBounds(0, 1, 1, 1);
    panel.add(highlightCenterButton, gbc);

    highlightCenterZoomButton = buttonFactory.createJRadioButton("HighlightCenterAndZoom");
    grp.add(highlightCenterZoomButton);
    gbc.setGridBounds(0, 2, 1, 1);
    panel.add(highlightCenterZoomButton, gbc);

    return panel;
  }
Пример #2
0
  private JPanel createRadioButtonPanel() {

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(1, 3));

    middleButton = new JRadioButton("Middle Page");
    middleButton.setHorizontalAlignment(AbstractButton.CENTER);
    middleButton.setActionCommand(Page.MIDDLE);
    middleButton.setEnabled(false);

    endButton = new JRadioButton("End Page");
    endButton.setHorizontalAlignment(AbstractButton.CENTER);
    endButton.setActionCommand(Page.END);
    endButton.setEnabled(false);

    initButton = new JRadioButton("Start Page");
    initButton.setHorizontalAlignment(AbstractButton.CENTER);
    initButton.setActionCommand(Page.START);
    initButton.setEnabled(false);

    ButtonGroup group = new ButtonGroup();
    group.add(initButton);
    group.add(middleButton);
    group.add(endButton);

    buttonPanel.add(initButton);
    buttonPanel.add(middleButton);
    buttonPanel.add(endButton);
    buttonPanel.setBorder(BorderFactory.createEtchedBorder());

    return buttonPanel;
  }
  /**
   * Create file selection panel
   *
   * @return the panel
   */
  private JPanel createSelectionPanel() {
    FormLayout layout =
        new FormLayout(
            "0dlu:n, pref:grow, 2dlu, pref:grow, 2dlu, pref:grow, 40dlu, 4dlu, min",
            "pref:grow, 6dlu, pref:grow, 6dlu, pref:grow");
    JPanel sPanel = new JPanel(layout);
    CellConstraints cc = new CellConstraints();

    //        JLabel note = new JLabel("Choose  by: ");
    //        Font oldFont = note.getFont();
    //        Font newFont = new Font(oldFont.getName(), oldFont.getStyle(), oldFont.getSize() + 2);
    //        note.setFont(newFont);
    sPanel.add(choosebyLabel, cc.xy(2, 1));
    sPanel.add(dirRadio, cc.xy(4, 1));
    sPanel.add(fileRadio, cc.xy(6, 1));
    sPanel.add(srcFilesDirField, cc.xyw(2, 3, 6));
    sPanel.add(srcFilesBrowseBtn, cc.xy(9, 3));
    sPanel.add(selectedFileCountLabel, cc.xyw(2, 5, 6));

    ButtonGroup selectGroup = new ButtonGroup();
    selectGroup.add(fileRadio);
    selectGroup.add(dirRadio);

    sPanel.setBorder(BorderFactory.createTitledBorder("1. Choose source files"));

    return sPanel;
  }
Пример #4
0
  /** @param index */
  private void createPlayerTypeOptions() {
    radioHuman = new FRadioButton("Human");
    radioAi = new FRadioButton("AI");
    radioOpen = new FRadioButton("Open");

    final JPopupMenu menu = new JPopupMenu();
    radioAiUseSimulation = new JCheckBoxMenuItem("Use Simulation");
    menu.add(radioAiUseSimulation);
    radioAiUseSimulation.addActionListener(
        new ActionListener() {
          @Override
          public final void actionPerformed(final ActionEvent e) {
            lobby.firePlayerChangeListener(index);
          }
        });
    radioAi.setComponentPopupMenu(menu);

    radioHuman.addMouseListener(radioMouseAdapter(radioHuman, LobbySlotType.LOCAL));
    radioAi.addMouseListener(radioMouseAdapter(radioAi, LobbySlotType.AI));
    radioOpen.addMouseListener(radioMouseAdapter(radioOpen, LobbySlotType.OPEN));

    final ButtonGroup tempBtnGroup = new ButtonGroup();
    tempBtnGroup.add(radioHuman);
    tempBtnGroup.add(radioAi);
    tempBtnGroup.add(radioOpen);
  }
Пример #5
0
    protected void refreshTransformers() {
      if (model != null) {
        // Select the right transformer
        int index = 0;
        for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) {
          for (TransformerCategory c : controller.getCategories(elmtType)) {
            ButtonGroup g = buttonGroups.get(index);

            boolean active =
                model.getSelectedElementClass().equals(elmtType)
                    && model.getSelectedCategory().equals(c);
            g.clearSelection();
            TransformerUI t = model.getSelectedTransformerUI();

            for (Enumeration<AbstractButton> btns = g.getElements(); btns.hasMoreElements(); ) {
              AbstractButton btn = btns.nextElement();
              btn.setVisible(active);
              if (t != null && btn.getName().equals(t.getDisplayName())) {
                g.setSelected(btn.getModel(), true);
              }
            }
            index++;
          }
        }
      }
    }
Пример #6
0
  private JPanel getJContentPane() {
    if (jContentPane == null) {
      jLabel6 = new JLabel();
      jLabel6.setBounds(new Rectangle(11, 72, 218, 19));
      jLabel6.setText("Install log directory:");
      jLabel5 = new JLabel();
      jLabel5.setBounds(new Rectangle(11, 2, 394, 26));
      jLabel5.setText("Advanced Install. Please select your preferences");
      ButtonGroup group = new ButtonGroup();
      pathSuffix = new JTextArea();
      pathSuffix.setBounds(new Rectangle(232, 48, 61, 21));
      pathSuffix.setText("BIRCH");
      jLabel4 = new JLabel();
      jLabel4.setBounds(new Rectangle(22, 351, 312, 20));
      jLabel4.setText("* - Automatically detected, recommended.");
      jLabel3 = new JLabel();
      jLabel3.setBounds(new Rectangle(220, 48, 10, 21));
      jLabel3.setText(" /");
      jLabel2 = new JLabel();
      jLabel2.setBounds(new Rectangle(18, 250, 132, 18));
      jLabel2.setText("Binaries:");
      jLabel1 = new JLabel();
      jLabel1.setBounds(new Rectangle(11, 115, 127, 21));
      jLabel1.setText("Framework Type:");
      jLabel = new JLabel();
      jLabel.setBounds(new Rectangle(11, 28, 131, 17));
      jLabel.setText("Install directory:");
      jContentPane = new JPanel();
      jContentPane.setLayout(null);
      jContentPane.setSize(new Dimension(464, 376));
      jContentPane.add(jLabel, null);
      jContentPane.add(getJButton(), null);
      jContentPane.add(getJTextArea(), null);
      jContentPane.add(jLabel3, null);
      jContentPane.add(pathSuffix, null);
      jContentPane.add(jLabel1, null);
      jContentPane.add(getJCheckBox(), null);
      jContentPane.add(getJCheckBox1(), null);
      jContentPane.add(jLabel2, null);
      jContentPane.add(getJCheckBox2(), null);
      jContentPane.add(getJCheckBox3(), null);
      jContentPane.add(getJCheckBox4(), null);
      jContentPane.add(getJCheckBox5(), null);
      jContentPane.add(getJCheckBox6(), null);

      jContentPane.add(getLogTextField(), null);
      jContentPane.add(getLogButton(), null);
      jContentPane.add(jLabel4, null);
      jContentPane.add(getWindows32Checkbox(), null);
      jContentPane.add(getJRadioButton(), null);
      jContentPane.add(jLabel5, null);
      jContentPane.add(jLabel6, null);
      jContentPane.add(getGitRadioButton(), null);
      jContentPane.add(getGitComboBox(), null);
      group.add(releaseRadioButton);
      group.add(developmentRadioButton);
      group.add(gitRadioButton);
    }
    return jContentPane;
  }
  private JPanel createFieldPanel() {
    myDoNotReplaceRadioButton =
        new JBRadioButton(UIUtil.replaceMnemonicAmpersand("Do n&ot replace"));
    myReplaceFieldsInaccessibleInRadioButton =
        new JBRadioButton(
            UIUtil.replaceMnemonicAmpersand("Replace fields &inaccessible in usage context"));
    myReplaceAllFieldsRadioButton =
        new JBRadioButton(UIUtil.replaceMnemonicAmpersand("&Replace all fields"));

    myDoNotReplaceRadioButton.setFocusable(false);
    myReplaceFieldsInaccessibleInRadioButton.setFocusable(false);
    myReplaceAllFieldsRadioButton.setFocusable(false);

    final ButtonGroup group = new ButtonGroup();
    group.add(myDoNotReplaceRadioButton);
    group.add(myReplaceFieldsInaccessibleInRadioButton);
    group.add(myReplaceAllFieldsRadioButton);

    final JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(myDoNotReplaceRadioButton);
    panel.add(myReplaceFieldsInaccessibleInRadioButton);
    panel.add(myReplaceAllFieldsRadioButton);

    panel.setBorder(
        IdeBorderFactory.createTitledBorder(
            "Replace fields used in expression with their getters", true));
    return panel;
  }
Пример #8
0
  private Component crearCentral() {
    JPanel panel = new JPanel(new GridLayout(2, 1, 10, 0));
    JPanel panelSuperior = new JPanel(new GridLayout(1, 3, 10, 0));
    JPanel panelInferior = new JPanel(new FlowLayout());
    textField = new JTextField();
    panelSuperior.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.GREEN),
            BorderFactory.createTitledBorder("Places")));
    panelSuperior.setBackground(Color.WHITE);

    place = new JRadioButton[2];
    place[0] = new JRadioButton("Take in the local factory");
    place[1] = new JRadioButton("Take it in: ");
    place[0].addItemListener(this);
    place[1].addItemListener(this);

    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(place[0]);
    buttonGroup.add(place[1]);

    panelSuperior.add(place[0]);
    panelSuperior.add(place[1]);
    panelSuperior.add(textField);

    confirm = new JButton("Confirm");
    confirm.addActionListener(this);
    panelInferior.add(confirm);

    panel.add(panelSuperior);
    panel.add(panelInferior);
    return panel;
  }
Пример #9
0
  private JXPanel radioPan() {
    JXPanel radio = new JXPanel();
    radio.setOpaque(false);
    radio.setLayout(new GridLayout(3, 1, 0, 3));
    jrbg = new ButtonGroup();

    rb[0] = new JRadioButton("rechne Endzeit aus Startzeit + Dauer");
    rb[0].addKeyListener(this);
    rb[0].addActionListener(this);
    rb[0].setOpaque(false);
    rb[0].setName("radio1");
    jrbg.add(rb[0]);
    radio.add(rb[0]);

    rb[1] = new JRadioButton("rechne Startzeit aus Endzeit - Dauer");
    rb[1].addKeyListener(this);
    rb[1].addActionListener(this);
    rb[1].setOpaque(false);
    rb[1].setName("radio2");
    jrbg.add(rb[1]);
    radio.add(rb[1]);

    rb[2] = new JRadioButton("rechne Dauer aus Startzeit und Endzeit");
    rb[2].addKeyListener(this);
    rb[2].addActionListener(this);
    rb[2].setOpaque(false);
    rb[2].setName("radio3");
    jrbg.add(rb[2]);
    radio.add(rb[2]);

    rb[0].setSelected(true);
    return radio;
  }
Пример #10
0
  private SubscriberBeanInterface createBean() {
    SubscriberBeanInterface subscriber = new SubscriberBean();

    subscriber.setMsisdn(msisdnField.getText());
    subscriber.setAction(actionButtonGroup.getSelection().getActionCommand());
    subscriber.setMarket(marketButtonGroup.getSelection().getActionCommand());
    subscriber.setCtype(ctypeButtonGroup.getSelection().getActionCommand());
    subscriber.setRefill_type((String) refillTypeComboboxSelection.getSelectedItem());
    subscriber.setTariff_plan((String) tariffPlanComboboxSelection.getSelectedItem());
    subscriber.setDay(dayField.getText());
    subscriber.setMonth(monthField.getText());
    subscriber.setAmount(amountField.getText());
    subscriber.setAmount_ids(amountIdField.getText());
    subscriber.setData_services(dataServicesField.getText());
    subscriber.setNational(nationaCostControlManagment());
    subscriber.setInternational(internationaCostControlManagment());
    subscriber.setLine_state(lineStateManagment());
    subscriber.setSave_balance(saveBalanceManager());
    subscriber.setExpiry_date(expiryDateField.getText());
    subscriber.setFeediscount(feediscountField.getText());
    subscriber.setFeedelay(feedelayField.getText());
    subscriber.setMsisdn_new(msisdnNewField.getText());
    subscriber.setMsisdn_new_refill(msisdnNewRefillField.getText());
    subscriber.setChannel((String) channelComboboxSelection.getSelectedItem());
    subscriber.setCommunityId(preferentialList.getText());
    return subscriber;
  }
  public void createPopupMenu() {
    super.createPopupMenu();

    JPopupMenu popupMenu = getPopupMenu();
    if (popupMenu == null) {
      popupMenu = new JPopupMenu();
      setPopupMenu(popupMenu);
    } else {
      popupMenu.addSeparator();
    }

    propertiesItem = new JMenuItem("Properties ...");

    propertiesItem.addActionListener(this);
    propertiesItem.setMnemonic('s');
    popupMenu.add(propertiesItem);

    popupMenu.addSeparator();
    ButtonGroup group = new ButtonGroup();
    inItem = new JRadioButtonMenuItem("IN");
    group.add(inItem);
    inItem.addActionListener(this);
    popupMenu.add(inItem);
    outItem = new JRadioButtonMenuItem("OUT");
    group.add(outItem);
    outItem.addActionListener(this);
    popupMenu.add(outItem);
    inoutItem = new JRadioButtonMenuItem("INOUT");
    group.add(inoutItem);
    inoutItem.addActionListener(this);
    popupMenu.add(inoutItem);
  }
Пример #12
0
 private void saveSessionInfo() {
   components.getLogger().info("SAVING SESSION");
   if (!components
       .getConnectionManagerStandard()
       .getSession()
       .getCurrent_msisdn()
       .equals(msisdnField.getText())) {
     components
         .getConnectionManagerStandard()
         .getSession()
         .setCurrent_msisdn(msisdnField.getText());
     components.getMsisdnCompleter().store(msisdnField.getText());
   }
   if (!components
       .getConnectionManagerStandard()
       .getSession()
       .getCurrent_market()
       .equals(marketButtonGroup.getSelection().getActionCommand())) {
     components
         .getConnectionManagerStandard()
         .getSession()
         .setCurrent_market(marketButtonGroup.getSelection().getActionCommand());
   }
   if (!components
       .getConnectionManagerStandard()
       .getSession()
       .getCurrent_ctype()
       .equals(ctypeButtonGroup.getSelection().getActionCommand())) {
     components
         .getConnectionManagerStandard()
         .getSession()
         .setCurrent_ctype(ctypeButtonGroup.getSelection().getActionCommand());
   }
   components.getLogger().info("SESSION SAVED");
 }
Пример #13
0
 private String lineStateManagment() {
   String local_line_state = "";
   if (lineStateButtonGroup.getSelection() != null) {
     local_line_state = lineStateButtonGroup.getSelection().getActionCommand();
   }
   return local_line_state;
 }
Пример #14
0
 private String saveBalanceManager() {
   String local_save_balance = "";
   if (saveBalanceButtonGroup.getSelection() != null) {
     local_save_balance = saveBalanceButtonGroup.getSelection().getActionCommand();
   }
   return local_save_balance;
 }
Пример #15
0
  void jbInit() throws Exception {

    setLayout(new AlignLayout(2, 5, 5));

    all = new JRadioButton("All");

    all.setSelected(true);

    select = new JRadioButton("User Data");
    select.setSelected(false);
    select.addItemListener(
        new java.awt.event.ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            select_itemStateChanged(e);
          }
        });

    userData = new JTextField(15);
    //      userData.setEnabled(false);
    ToggleDocument td = new ToggleDocument();
    td.addToggleDocumentListener(this);
    userData.setDocument(td);

    ButtonGroup bg = new ButtonGroup();
    bg.add(all);
    bg.add(select);

    add(all);
    add(new JLabel(""));
    add(select);
    add(userData);

    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  }
Пример #16
0
  // -----------------------------------------------------------------
  //  Sets up a panel with a label and a set of radio buttons
  //  that control its text.
  // -----------------------------------------------------------------
  public QuoteOptionsPanel() {
    comedyQuote = "Take my wife, please.";
    philosophyQuote = "I think, therefore I am.";
    carpentryQuote = "Measure twice. Cut once.";

    quote = new JLabel(comedyQuote);
    quote.setFont(new Font("Helvetica", Font.BOLD, 24));
    comedy = new JRadioButton("Comedy", true);
    comedy.setBackground(Color.green);
    philosophy = new JRadioButton("Philosophy");
    philosophy.setBackground(Color.green);
    carpentry = new JRadioButton("Carpentry");
    carpentry.setBackground(Color.green);

    ButtonGroup group = new ButtonGroup();
    group.add(comedy);
    group.add(philosophy);
    group.add(carpentry);

    QuoteListener listener = new QuoteListener();
    comedy.addActionListener(listener);
    philosophy.addActionListener(listener);
    carpentry.addActionListener(listener);

    add(quote);
    add(comedy);
    add(philosophy);
    add(carpentry);

    setBackground(Color.green);
    setPreferredSize(new Dimension(300, 100));
  }
  private void buildRadio(JPanel pnl) {
    bg = new ButtonGroup();
    pnl.setLayout(new GridLayout(2, 3, 15, -10));

    rdbtnPlainText = new JRadioButton("Plaintext");
    rdbtnPlainText.setSelected(true);
    bg.add(rdbtnPlainText);
    pnl.add(rdbtnPlainText);

    rdbtnVigenere = new JRadioButton("Vigenere");
    pnl.add(rdbtnVigenere);
    bg.add(rdbtnVigenere);

    rdbtnRsa = new JRadioButton("RSA");
    bg.add(rdbtnRsa);
    pnl.add(rdbtnRsa);

    rdbtnCaesarShift = new JRadioButton("Caesar shift");
    bg.add(rdbtnCaesarShift);
    pnl.add(rdbtnCaesarShift);

    rdbtnTEA = new JRadioButton("TEA");
    pnl.add(rdbtnTEA);
    bg.add(rdbtnTEA);
  }
Пример #18
0
  @Override
  public JPopupMenu getComponentPopupMenu() {
    if (popupMenu == null) {
      popupMenu = new JPopupMenu(Messages.CHART_COLON);
      timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU);
      timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU));
      popupMenu.add(timeRangeMenu);
      menuRBs = new JRadioButtonMenuItem[rangeNames.length];
      ButtonGroup rbGroup = new ButtonGroup();
      for (int i = 0; i < rangeNames.length; i++) {
        menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]);
        rbGroup.add(menuRBs[i]);
        menuRBs[i].addActionListener(this);
        if (viewRange == rangeValues[i]) {
          menuRBs[i].setSelected(true);
        }
        timeRangeMenu.add(menuRBs[i]);
      }

      popupMenu.addSeparator();

      saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM);
      saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM));
      saveAsMI.addActionListener(this);
      popupMenu.add(saveAsMI);
    }
    return popupMenu;
  }
Пример #19
0
 public RadioButtonDemo() {
   setTitle("RadioButtonDemo");
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   // Create a JPanel to be used as the content pane.
   JPanel aPanel = new JPanel();
   aPanel.setLayout(new BoxLayout(aPanel, BoxLayout.Y_AXIS));
   // Create a button group for the buttons.
   buttonGroup = new ButtonGroup();
   buttonGroup2 = new ButtonGroup();
   // Create radio buttons and add them to the panel.
   // Also add them to the button group.
   ActionListener newSelection = new SelectionChangeMade();
   for (int i = 0; i < selections.length; i++) {
     radioButtons[i] = new JRadioButton(selections[i]);
     radioButtons[i].getModel().setActionCommand(selections[i]);
     radioButtons[i].addActionListener(newSelection);
     buttonGroup.add(radioButtons[i]);
     aPanel.add(radioButtons[i]);
   }
   //        ActionListener newSeclection = new SelectionChangeMade2();
   for (int i = 0; i < selections2.length; i++) {
     radioButtons2[i] = new JRadioButton(selections2[i]);
     radioButtons2[i].getModel().setActionCommand(selections2[i]);
     radioButtons2[i].addActionListener(newSelection);
     buttonGroup2.add(radioButtons2[i]);
     aPanel.add(radioButtons2[i]);
   }
   setContentPane(aPanel);
   pack();
 }
Пример #20
0
 private JPanel getSouthWestPanel() {
   JPanel ret = new JPanel();
   JRadioButton low = new JRadioButton("小写显示");
   low.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           uppercase = false;
         }
       });
   ret.add(low);
   JRadioButton up = new JRadioButton("大写显示");
   up.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           uppercase = true;
         }
       });
   ret.add(up);
   ButtonGroup bg = new ButtonGroup();
   bg.add(low);
   bg.add(up);
   low.setSelected(true);
   return ret;
 }
Пример #21
0
  // ----------------------------------------------------------------------------
  private JPanel createFontEffects() {
    JPanel panel = new JPanel(new GridLayout(1, 3, 10, 5));
    panel.setToolTipText("Effects are only visible in Flash.");
    panel.setBorder(new TitledBorder(new EtchedBorder(), "Effects"));

    ButtonGroup group = new ButtonGroup();
    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            effect_ = Integer.parseInt(e.getActionCommand());
          }
        };

    effect_buttons_[0] = new JRadioButton("No effect");
    effect_buttons_[0].setSelected(true);
    effect_buttons_[0].setActionCommand("" + DrawSWFFont.NO_EFFECT);
    panel.add(effect_buttons_[0]);
    group.add(effect_buttons_[0]);
    effect_buttons_[0].addActionListener(listener);

    effect_buttons_[1] = new JRadioButton("Type chars");
    effect_buttons_[1].setActionCommand("" + DrawSWFFont.EFFECT_TYPE);
    panel.add(effect_buttons_[1]);
    group.add(effect_buttons_[1]);
    effect_buttons_[1].addActionListener(listener);

    effect_buttons_[2] = new JRadioButton("Fade in");
    effect_buttons_[2].setActionCommand("" + DrawSWFFont.EFFECT_FADE_IN);
    panel.add(effect_buttons_[2]);
    group.add(effect_buttons_[2]);
    effect_buttons_[2].addActionListener(listener);

    return panel;
  }
Пример #22
0
  SurveyPanel(String ques, String[] resp, int def) {
    super();
    setSize(160, 110);
    question = new JLabel(ques);
    response = new JRadioButton[resp.length];
    JPanel sub1 = new JPanel();
    ButtonGroup group = new ButtonGroup();
    JLabel quesLabel = new JLabel(ques);
    sub1.add(quesLabel);
    JPanel sub2 = new JPanel();
    for (int i = 0; i < resp.length; i++) {

      if (def == i) {

        response[i] = new JRadioButton(resp[i], true);
      } else {
        response[i] = new JRadioButton(resp[i], false);
      }

      group.add(response[i]);
      sub2.add(response[i]);
    }

    JPanel sub3 = new JPanel();
    nextButton.setEnabled(true);
    sub3.add(nextButton);
    finalButton.setEnabled(false);
    sub3.add(finalButton);
    GridLayout grid = new GridLayout(3, 1);
    setLayout(grid);
    add(sub1);
    add(sub2);
    add(sub3);
  }
Пример #23
0
    protected void setup() {
      clear();
      if (model != null) {
        // Add transformers buttons, separate them by element group
        for (String elmtType : AppearanceUIController.ELEMENT_CLASSES) {
          ButtonGroup buttonGroup = new ButtonGroup();
          for (final TransformerCategory c : controller.getCategories(elmtType)) {
            // Build button
            Icon icon = c.getIcon();
            //                        DecoratedIcon decoratedIcon = getDecoratedIcon(icon, t);
            //                        JToggleButton btn = new JToggleButton(decoratedIcon);
            JToggleButton btn = new JToggleButton(icon);

            btn.setToolTipText(c.getDisplayName());
            btn.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    controller.setSelectedCategory(c);
                  }
                });
            btn.setName(c.getDisplayName());
            btn.setFocusPainted(false);
            buttonGroup.add(btn);
            add(btn);
          }

          buttonGroups.add(buttonGroup);
        }
      } else {
        elementGroup.clearSelection();
      }
    }
Пример #24
0
 private Map<StateExport, JRadioButton> computeExportButtonMap() {
   Map<StateExport, JRadioButton> result =
       new EnumMap<StateExport, JRadioButton>(StateExport.class);
   ButtonGroup group = new ButtonGroup();
   for (StateExport mode : StateExport.values()) {
     String text = null;
     switch (mode) {
       case TOP:
         text = "Top-level states";
         break;
       case ALL:
         text = "All states";
         if (getGTS().hasTransientStates()) {
           text += " (including recipe stages)";
         }
         break;
       case FINAL:
         text = "Final states";
         break;
       case NONE:
         text = "None";
         break;
       case RESULT:
         text = "Result states";
         break;
       default:
         assert false;
     }
     JRadioButton button = new JRadioButton(text, mode == StateExport.NONE);
     result.put(mode, button);
     group.add(button);
   }
   return result;
 }
 public TestFrame() {
   super("Home Plan Component Test");
   this.home = new Home();
   this.home.getCompass().setVisible(false);
   UserPreferences preferences = new DefaultUserPreferences();
   ViewFactory viewFactory = new SwingViewFactory();
   this.homeController = new HomeController(home, preferences, viewFactory);
   JComponent homeView = (JComponent) this.homeController.getView();
   ActionMap actions = homeView.getActionMap();
   // Create buttons from HomePane actions map
   this.selectButton = new JToggleButton(actions.get(HomePane.ActionType.SELECT));
   this.createWallsButton = new JToggleButton(actions.get(HomePane.ActionType.CREATE_WALLS));
   this.createDimensionsButton =
       new JToggleButton(actions.get(HomePane.ActionType.CREATE_DIMENSION_LINES));
   ButtonGroup group = new ButtonGroup();
   group.add(this.selectButton);
   group.add(this.createWallsButton);
   group.add(this.createDimensionsButton);
   this.addButton = new JButton(actions.get(HomePane.ActionType.ADD_HOME_FURNITURE));
   this.undoButton = new JButton(actions.get(HomePane.ActionType.UNDO));
   this.redoButton = new JButton(actions.get(HomePane.ActionType.REDO));
   // Put them it a tool bar
   JToolBar toolBar = new JToolBar();
   toolBar.add(this.selectButton);
   toolBar.add(this.createWallsButton);
   toolBar.add(this.addButton);
   toolBar.add(this.undoButton);
   toolBar.add(this.redoButton);
   // Display the tool bar and main view in this pane
   add(toolBar, BorderLayout.NORTH);
   add(homeView, BorderLayout.CENTER);
   pack();
 }
Пример #26
0
  /** Return a menu for DesktopWindow and add a special listener. */
  public static JMenu getCurrencyMenu(ActionListener listener) {
    JRadioButtonMenuItem menuItem;
    String defaultCurrency = Money.getCurrencyFor(Money.getDefaultCurrency());

    JMenu menu = new JMenu("Währung");
    ButtonGroup group = new ButtonGroup();

    JMenu europeanMenu = new JMenu("Europa");
    String europeanCurrencies[] = Money.getEuropeanCurrencyList();

    for (int i = 0; i < europeanCurrencies.length; i++) {
      menuItem = new RadioCurrencyMenuItem(europeanCurrencies[i]);
      menuItem.addActionListener(listener);
      europeanMenu.add(menuItem);

      group.add(menuItem);

      if (europeanCurrencies[i].startsWith(defaultCurrency)) {
        menuItem.setSelected(true);
      }

      if (i == 0) {
        europeanMenu.addSeparator();
      }
    }

    menu.add(europeanMenu);

    return menu;
  }
  /*
   * Update radio button names in the same order as the table
   */
  private void updateControlPanel() {
    schedule.removeAll();
    noneButton.setName(""); // Name holds schedule id for the selected radio button
    noneButton.setSelected(true);
    commentTextArea.setText(""); // no text for the noneButton
    enableButtons(false);
    schedule.add(noneButton);
    schGroup.add(noneButton);

    for (int i = trainsScheduleModel.getFixedColumn();
        i < trainsScheduleModel.getColumnCount();
        i++) {
      log.debug("Column name: {}", trainsScheduleTable.getColumnName(i));
      TrainSchedule ts =
          trainScheduleManager.getScheduleByName(trainsScheduleTable.getColumnName(i));
      if (ts != null) {
        JRadioButton b = new JRadioButton();
        b.setText(ts.getName());
        b.setName(ts.getId());
        schedule.add(b);
        schGroup.add(b);
        addRadioButtonAction(b);
        if (b.getName().equals(trainManager.getTrainScheduleActiveId())) {
          b.setSelected(true);
          enableButtons(true);
          // update comment field
          commentTextArea.setText(ts.getComment());
        }
      }
    }
    schedule.revalidate();
  }
  /**
   * Add an {@link AbstractMenuOptionGroup option group} to the list of components
   *
   * @param components List of components where to add the created {@link JMenu}
   * @param optionGroupId The {@link URI} identifying the option group
   * @param isToolbar True if the option group is to be added to a toolbar
   */
  private void addOptionGroup(
      List<Component> components, URI optionGroupId, MenuOptions menuOptions) {
    MenuOptions childOptions = new MenuOptions(menuOptions);
    childOptions.setOptionGroup(true);

    List<Component> buttons = makeComponents(optionGroupId, childOptions);
    addNullSeparator(components);
    if (buttons.isEmpty()) {
      logger.warn("No sub components found for option group " + optionGroupId);
      return;
    }
    ButtonGroup buttonGroup = new ButtonGroup();

    for (Component button : buttons) {
      if (button instanceof AbstractButton) buttonGroup.add((AbstractButton) button);
      else
        logger.warn(
            "Component of button group " + optionGroupId + " is not an AbstractButton: " + button);
      if (button == null) {
        logger.warn("Separator found within button group");
        addNullSeparator(components);
      } else components.add(button);
    }
    addNullSeparator(components);
  }
 private static void groupButtons(AbstractButton... buttons) {
   ButtonGroup group = new ButtonGroup();
   for (AbstractButton button : buttons) {
     group.add(button);
   }
   if (buttons.length > 0) buttons[0].setSelected(true);
 }
Пример #30
0
 /**
  * Adds the connection speed options to the display.
  *
  * @param index The default index.
  * @param comp The component to add to the display.
  * @return See above.
  */
 private JPanel buildConnectionSpeed(int index, JComponent comp) {
   JPanel p = new JPanel();
   p.setBorder(BorderFactory.createTitledBorder("Connection Speed"));
   buttonsGroup = new ButtonGroup();
   JRadioButton button = new JRadioButton();
   button.setText("LAN");
   button.setActionCommand("" + HIGH_SPEED);
   button.addActionListener(this);
   button.setSelected(index == LoginCredentials.HIGH);
   buttonsGroup.add(button);
   p.add(button);
   button = new JRadioButton();
   button.setText("High (Broadband)");
   button.setActionCommand("" + MEDIUM_SPEED);
   button.setSelected(index == LoginCredentials.MEDIUM);
   button.addActionListener(this);
   buttonsGroup.add(button);
   p.add(button);
   button = new JRadioButton();
   button.setText("Low (Dial-up)");
   button.setActionCommand("" + LOW_SPEED);
   button.setSelected(index == LoginCredentials.LOW);
   button.addActionListener(this);
   buttonsGroup.add(button);
   p.add(button);
   if (comp == null) return p;
   JPanel content = new JPanel();
   content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
   content.add(comp);
   p = UIUtilities.buildComponentPanel(p);
   content.add(p);
   return content;
 }