Java Code Examples for javax.swing.JCheckBox#setName()

The following examples show how to use javax.swing.JCheckBox#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageGallery.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
/**
 * create returns the thumb selector component
 *
 * @param f
 * @return
 */
private JComponent getThumbSelector(final String f) {
    final JCheckBox cb = new JCheckBox();
    cb.setText("");
    cb.setSelected(false);
    cb.setName(f);
    cb.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (cb.isSelected()) {
                selflist.add(f);
            } else {
                selflist.remove(f);
            }
        }
    });
    cb.setPreferredSize(CB_SIZE);
    return cb;

}
 
Example 2
Source File: PluginQueryTokenizerPreferencesPanel.java    From bigtable-sql with Apache License 2.0 6 votes vote down vote up
private void addUseCustomQTCheckBox(JPanel panel, int col, int row)
{
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = col;
	c.gridy = row;
	c.insets = new Insets(5, 5, 0, 0);
	c.anchor = GridBagConstraints.WEST;
	c.gridwidth = 2; // Span across two columns
	useCustomQTCheckBox = new JCheckBox(i18n.USE_CUSTOM_QT_LABEL);
	useCustomQTCheckBox.setName("useCustomQTCheckBox");

	// i18n[PreferencesPanel.useCustomQTToolTip=Gives enhanced capabilities
	// over the default query tokenizer for handling {0} scripts]
	String USE_CUSTOM_QT_TOOLTIP =
		s_stringMgr.getString("PreferencesPanel.useCustomQTToolTip", _databaseName);

	useCustomQTCheckBox.setToolTipText(USE_CUSTOM_QT_TOOLTIP);
	useCustomQTCheckBox.addActionListener(new UseQTHandler());
	panel.add(useCustomQTCheckBox, c);
}
 
Example 3
Source File: PixelInfoTopComponent.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
public PixelInfoTopComponent() {
    setName(Bundle.CTL_PixelInfoTopComponentName());
    setToolTipText(Bundle.CTL_PixelInfoTopComponentDescription());
    putClientProperty(TopComponent.PROP_MAXIMIZATION_DISABLED, Boolean.TRUE);
    putClientProperty(TopComponent.PROP_KEEP_PREFERRED_SIZE_WHEN_SLIDED_IN, Boolean.TRUE);
    pixelPositionListener = new MyPixelPositionListener();
    pinSelectionChangeListener = new PinSelectionChangeListener();
    pinChangedListener = new PinChangedListener();
    pixelInfoView = new PixelInfoView();
    pinCheckbox = new JCheckBox("Snap to selected pin");
    pinCheckbox.setName("pinCheckbox");
    pinCheckbox.setSelected(false);
    pinCheckbox.addActionListener(e -> updatePixelInfo());
    setLayout(new BorderLayout());
    add(pixelInfoView, BorderLayout.CENTER);
    add(pinCheckbox, BorderLayout.SOUTH);

    final SnapApp snapApp = SnapApp.getDefault();
    snapApp.getProductManager().addListener(new PxInfoProductManagerListener());
    setCurrentView(snapApp.getSelectedProductSceneView());
}
 
Example 4
Source File: SettingsPage.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
private JCheckBox createCheckBox(String name, Font font) {
	JCheckBox chk = new JCheckBox(StringResource.get(name));
	chk.setName(name);
	chk.setIcon(ImageResource.getIcon("unchecked.png", 16, 16));
	chk.setSelectedIcon(ImageResource.getIcon("checked.png", 16, 16));
	chk.setOpaque(false);
	chk.setFocusPainted(false);
	chk.setForeground(Color.WHITE);
	chk.setFont(font);
	return chk;
}
 
Example 5
Source File: ForceGenerationOptionsPanel.java    From megamek with GNU General Public License v2.0 5 votes vote down vote up
private JCheckBox createSubtypeCheck(String text, String name, boolean select) {
    JCheckBox chk = new JCheckBox(text);
    chk.setName(name);
    chk.setSelected(select);
    subtypeChecks.add(chk);
    return chk;
}
 
Example 6
Source File: PluginQueryTokenizerPreferencesPanel.java    From bigtable-sql with Apache License 2.0 5 votes vote down vote up
private void addRemoveMultiLineCommentCheckBox(JPanel panel, int col, int row)
{
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = col;
	c.gridy = row;
	c.gridwidth = 2; // Span across two columns
	c.insets = new Insets(5, 30, 0, 0);
	String cbLabel = i18n.REMOVE_ML_COMMENT_LABEL;
	removeMultiLineCommentCheckBox = new JCheckBox(cbLabel);
	removeMultiLineCommentCheckBox.setName("removeMultiLineCommentCheckBox");
	removeMultiLineCommentCheckBox.setToolTipText(i18n.REMOVE_ML_COMMENT_LABEL_TT);
	panel.add(removeMultiLineCommentCheckBox, c);
}
 
Example 7
Source File: SwingRemoteDrillDownUi.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create top checkbox with "Include server URL in path" label.
 *
 * @return created checkbox.
 */
private JCheckBox createServerUrlCheckBox() {
  JCheckBox checkBox = new JCheckBox();
  checkBox.setName( ComponentLookup.SERVER_URL_CHECKBOX.name() );
  checkBox.setText( Messages.getString( "DrillDownDialog.ServerUrlCheckBox.Text" ) );
  return checkBox;
}
 
Example 8
Source File: MultipleSelectionInputComponent.java    From chipster with MIT License 5 votes vote down vote up
protected MultipleSelectionInputComponent(EnumParameter param, 
                                          ParameterPanel parameterPanel) {
    super(parameterPanel);
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    this.param = param;
    
    // Generate a list of checkboxes representing available choices
    boolean selected;
    for (Object choice : param.getOptions()) {
        SelectionOption option = (SelectionOption) choice;
        
        // Select default values
        selected = false; 
        if (param.getSelectedOptions().contains(option)) {
            selected = true;
        }
        
        // Create the component
        JCheckBox checkbox = new JCheckBox(option.toString(), selected);
        checkbox.setName(option.getValue());
        checkbox.addActionListener(this);
        checkbox.addFocusListener(this);
        
        // Add checkbox to lists
        checkboxes.add(checkbox);
        this.add(checkbox);
    }
    this.getComponent(0);
        
}
 
Example 9
Source File: HttpSimpleTableControlGui.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
private JPanel createPortPanel() {
    portField = new JTextField(HttpSimpleTableControl.DEFAULT_PORT_S, 8);
    portField.setName(HttpSimpleTableControl.PORT);

    JLabel label = new JLabel(JMeterUtils.getResString("port")); 
    label.setLabelFor(portField);

    datasetDirectoryField = new JTextField(
            HttpSimpleTableControl.DEFAULT_DATA_DIR, 8);
    datasetDirectoryField.setName(HttpSimpleTableControl.DATA_DIR);

    JLabel ddLabel = new JLabel("Dataset directory:"); 
    ddLabel.setLabelFor(datasetDirectoryField);

    timestampChkBox = new JCheckBox();
    timestampChkBox.setSelected(HttpSimpleTableControl.DEFAULT_TIMESTAMP);
    timestampChkBox.setName(HttpSimpleTableControl.TIMESTAMP);

    JLabel tsLabel = new JLabel("Timestamp:"); 
    tsLabel.setLabelFor(timestampChkBox);

    HorizontalPanel panel = new HorizontalPanel();
    panel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createEtchedBorder(), "Settings")); 

    panel.add(label);
    panel.add(portField);

    panel.add(ddLabel);
    panel.add(datasetDirectoryField);

    panel.add(tsLabel);
    panel.add(timestampChkBox);

    panel.add(Box.createHorizontalStrut(10));

    return panel;
}
 
Example 10
Source File: SettingsDialog.java    From portmapper with GNU General Public License v3.0 5 votes vote down vote up
private JPanel getDialogPane() {
    final ActionMap actionMap = app.getContext().getActionMap(this.getClass(), this);
    final Settings settings = app.getSettings();

    final JPanel dialogPane = new JPanel(new MigLayout("", // Layout
            // Constraints
            "[right]rel[left,grow 100]", // Column Constraints
            "")); // Row Constraints

    logger.debug("Use entity encoding is {}", settings.isUseEntityEncoding());
    useEntityEncoding = new JCheckBox("settings_dialog.use_entity_encoding", settings.isUseEntityEncoding());
    useEntityEncoding.setName("settings_dialog.use_entity_encoding");

    dialogPane.add(useEntityEncoding, "span 2, wrap");

    dialogPane.add(createLabel("settings_dialog.log_level"));

    logLevelComboBox = new JComboBox<>(new Vector<>(AVAILABLE_LOG_LEVELS));
    logLevelComboBox.setSelectedItem(Level.toLevel(settings.getLogLevel()));

    dialogPane.add(logLevelComboBox, "wrap");

    dialogPane.add(createLabel("settings_dialog.upnp_lib"));

    routerFactoryClassComboBox = new JComboBox<>(new Vector<>(AVAILABLE_ROUTER_FACTORIES));
    routerFactoryClassComboBox.setSelectedItem(settings.getRouterFactoryClassName());
    dialogPane.add(routerFactoryClassComboBox, "span 2, wrap");

    dialogPane.add(new JButton(actionMap.get(ACTION_CANCEL)), "tag cancel, span 2");
    okButton = new JButton(actionMap.get(ACTION_SAVE));
    dialogPane.add(okButton, "tag ok, wrap");

    return dialogPane;
}
 
Example 11
Source File: AlertsPanel.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
private void initialize(List<String> alertTypes) {

        selections = new ArrayList<JCheckBox>();
        // Alert selection Panel
        JPanel selectionPanel = new JPanel();
        selectionPanel.setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(2, 5, 30, 10);

        selectionPanel.add(
                getRiskBox(
                        Constant.messages.getString("customreport.alertspanel.risk.high"), "High"),
                gbc);

        gbc.gridx++;
        selectionPanel.add(
                getRiskBox(
                        Constant.messages.getString("customreport.alertspanel.risk.medium"),
                        "Medium"),
                gbc);

        gbc.gridx++;
        selectionPanel.add(
                getRiskBox(Constant.messages.getString("customreport.alertspanel.risk.low"), "Low"),
                gbc);

        gbc.gridx++;
        selectionPanel.add(
                getRiskBox(
                        Constant.messages.getString("customreport.alertspanel.risk.info"),
                        "Informational"),
                gbc);

        gbc.insets = new Insets(0, 20, 2, 0);
        gbc.gridy = 1;
        gbc.gridwidth = 4;

        for (String alertType : alertTypes) {

            JCheckBox selection = new JCheckBox();
            selection.setText(alertType);
            selection.setSelected(true);
            selection.setName(alertType);

            gbc.gridx = 0;
            gbc.anchor = GridBagConstraints.CENTER;
            selectionPanel.add(selection, gbc);
            this.getSelections().add(selection);
            gbc.gridy += 1;
        }

        this.setLayout(new BorderLayout());
        this.add(
                new JLabel(Constant.messages.getString("customreport.alertspanel.label")),
                BorderLayout.NORTH);
        this.add(new JScrollPane(selectionPanel), BorderLayout.CENTER);
    }
 
Example 12
Source File: KsTplTextEditor.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
@Override
protected void addCustomComponents(@Nonnull final JPanel panel,
                                   @Nonnull final GridBagConstraints gbdata) {
  final JButton buttonClipboardText = new JButton(ICON_PLANTUML);
  buttonClipboardText.setName("BUTTON.PLANTUML");
  buttonClipboardText.setToolTipText("Copy formed PlantUML script to clipboard");
  buttonClipboardText.addActionListener((ActionEvent e) -> {
    Toolkit.getDefaultToolkit().getSystemClipboard()
        .setContents(new StringSelection(preprocessEditorText(editor.getText())), null);
  });

  checkBoxGroupTopics = new JCheckBox("Group topics  ", this.modeGroupTopics);
  checkBoxGroupTopics.setName(PROPERTY_TOPICS_GROUP);
  checkBoxGroupTopics.setToolTipText("Group all topics on scheme together");
  checkBoxGroupTopics.addActionListener((x) -> {
    this.onConfigCheckboxChange(checkBoxGroupTopics);
  });

  checkBoxGroupStores = new JCheckBox("Group stores  ", this.modeGroupStores);
  checkBoxGroupStores.setName(PROPERTY_STORE_GROUP);
  checkBoxGroupStores.setToolTipText("Group all stores on scheme together");
  checkBoxGroupStores.addActionListener((x) -> {
    this.onConfigCheckboxChange(checkBoxGroupStores);
  });

  checkBoxOrtho = new JCheckBox("Orthogonal lines  ", this.modeOrtho);
  checkBoxOrtho.setName(PROPERTY_ORTHOGONAL);
  checkBoxOrtho.setToolTipText("Orthogonal connector lines");
  checkBoxOrtho.addActionListener((x) -> {
    this.onConfigCheckboxChange(checkBoxOrtho);
  });

  checkBoxHorizontal = new JCheckBox("Horizontal layout  ", this.modeHoriz);
  checkBoxHorizontal.setName(PROPERTY_LAYOUT_HORIZ);
  checkBoxHorizontal.setToolTipText("Horizontal layouting of components");
  checkBoxHorizontal.addActionListener((x) -> {
    this.onConfigCheckboxChange(checkBoxHorizontal);
  });

  panel.add(buttonClipboardText, gbdata);
  panel.add(checkBoxGroupTopics, gbdata);
  panel.add(checkBoxGroupStores, gbdata);
  panel.add(checkBoxOrtho, gbdata);
  panel.add(checkBoxHorizontal, gbdata);
}
 
Example 13
Source File: EditPresetDialog.java    From portmapper with GNU General Public License v3.0 4 votes vote down vote up
private void initComponents() {
    final ActionMap actionMap = app.getContext().getActionMap(this.getClass(), this);

    final JPanel dialogPane = new JPanel(new MigLayout("", // Layout
            // Constraints
            "[right]rel[left,grow 100]", // Column Constraints
            "")); // Row Constraints

    presetNameTextField = new JTextField();
    dialogPane.add(createLabel("preset_dialog.description"), "align label");
    dialogPane.add(presetNameTextField, "span 2, growx, wrap");

    remoteHostTextField = new JTextField();
    remoteHostTextField.setColumns(10);
    dialogPane.add(createLabel("preset_dialog.remote_host"), "");
    dialogPane.add(remoteHostTextField, "growx");
    dialogPane.add(createLabel("preset_dialog.remote_host_empty_for_all"), "wrap"); //$NON-NLS-2$

    internalClientTextField = new JTextField();
    internalClientTextField.setColumns(10);

    useLocalhostCheckBox = new JCheckBox("preset_dialog.internal_client_use_local_host", true);
    useLocalhostCheckBox.setName("preset_dialog.internal_client_use_local_host");
    useLocalhostCheckBox.addActionListener(event -> {
        internalClientTextField.setEnabled(!useLocalhostCheckBox.isSelected());
        if (useLocalhostCheckBox.isSelected()) {
            internalClientTextField.setText(app.getLocalHostAddress());
        }
    });

    // Check if the local host address can be retrieved

    final String localHostAddress = app.getLocalHostAddress();

    if (localHostAddress != null) {
        LOG.debug("Found localhost address {}. Enable localhost checkbox.", localHostAddress);
        internalClientTextField.setText(localHostAddress);
        internalClientTextField.setEnabled(false);
        useLocalhostCheckBox.setEnabled(true);
    } else {
        LOG.debug("Did not find localhost address: disable localhost checkbox.");
        useLocalhostCheckBox.setSelected(false);
        useLocalhostCheckBox.setEnabled(false);
        internalClientTextField.setEnabled(true);
        internalClientTextField.setText("");
    }

    dialogPane.add(createLabel("preset_dialog.internal_client"), "align label");
    dialogPane.add(internalClientTextField, "growx");
    dialogPane.add(useLocalhostCheckBox, "wrap");

    dialogPane.add(getPortsPanel(), "span 3, grow, wrap");

    dialogPane.add(new JButton(actionMap.get(ACTION_CANCEL)), "tag cancel, span 2");
    final JButton okButton = new JButton(actionMap.get(ACTION_SAVE));
    dialogPane.add(okButton, "tag ok, wrap");

    setContentPane(dialogPane);
    dialogPane.getRootPane().setDefaultButton(okButton);
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setModal(true);
    pack();
}
 
Example 14
Source File: SwingCheckBoxListWidget.java    From atdl4j with MIT License 4 votes vote down vote up
@Override
public List< ? extends Component> createBrickComponents() {
  
  List<Component> components = new ArrayList<Component>();
  // wrapper
  JPanel wrapper = new JPanel();
  
  // tooltip
  String tooltip = control.getTooltip();
  
  // label
  if (control.getLabel() != null) {
    label = new JLabel();
    label.setName(getName() + "/label");
    label.setText(control.getLabel());
    if (tooltip != null)
      label.setToolTipText(tooltip);
    components.add(label);
  }
  
  if (((CheckBoxListT) control).getOrientation() != null
      && PanelOrientationT.VERTICAL.equals(((CheckBoxListT) control)
          .getOrientation())) {
    // TODO: NOT IMPLEMENTED
  }
  else {
    // TODO: NOT IMPLEMENTED
  }
  
  // checkBoxes
  List<ListItemT> listItems = ((CheckBoxListT) control).getListItem();
  for (ListItemT listItem : listItems) {
  
    JCheckBox checkBox = new JCheckBox();
    checkBox.setName(getName() + "/button/" + listItem.getEnumID());
  
    if (listItem.getUiRep() != null)
      checkBox.setText(listItem.getUiRep());
  
    if (parameter != null) {
      for (EnumPairT enumPair : parameter.getEnumPair()) {
        if (enumPair.getEnumID() == listItem.getEnumID()) {
  
          // set tooltip
          if (enumPair.getDescription() != null)
            checkBox.setToolTipText(enumPair.getDescription());
          else if (tooltip != null)
            checkBox.setToolTipText(tooltip);
          break;
        }
      }
    }
    else {
      if (tooltip != null)
        checkBox.setToolTipText(tooltip);
    }
    multiCheckBox.add(checkBox);
    components.add(checkBox);
  }
  
  // set initValue
  if (((CheckBoxListT) control).getInitValue() != null)
    setValue(((CheckBoxListT) control).getInitValue(), true);
  
  return components;
}
 
Example 15
Source File: SwingJideClockWidget.java    From atdl4j with MIT License 4 votes vote down vote up
@Override
protected List< ? extends Component> createBrickComponents() {
  
  List<Component> components = new ArrayList<Component>();
  
  // tooltip
     String tooltip = control.getTooltip();      
     
     if ( parameter instanceof UTCTimestampT || parameter instanceof TZTimestampT )
     {
             if (getAtdl4jOptions()==null||getAtdl4jOptions().isShowDateInputOnTimestampClockControl())
             {
                 showMonthYear = true;
                 showDay = true;
             } else {
                 showMonthYear = false;
                 showDay = false;
                 useNowAsDate = true;
             }
         showTime = true;
     }
     else if ( parameter instanceof UTCDateOnlyT || parameter instanceof LocalMktDateT )
     {
         showMonthYear = true;
         showDay = true;
         showTime = false;
     }
     else if ( parameter instanceof MonthYearT )
     {
         showMonthYear = true;
         showDay = false;
         showTime = false;
     }
     else if ( parameter == null || parameter instanceof UTCTimeOnlyT || parameter instanceof TZTimeOnlyT )
     {
         showMonthYear = false;
         showDay = false;
         showTime = true;
     }
     
     if ( getAtdl4jOptions() != null && 
         getAtdl4jOptions().isShowEnabledCheckboxOnOptionalClockControl() && 
         parameter != null && 
         UseT.OPTIONAL.equals( parameter.getUse() ) )
     {
         hasLabelOrCheckbox = true;
         enabledButton = new JCheckBox();
         enabledButton.setName(getName()+"/enablebutton");
         if (control.getLabel() != null) {
             enabledButton.setText(control.getLabel());
         }
         enabledButton.setToolTipText("Click to enable optional parameter");
         enabledButton.setSelected(false);
         enabledButton.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
               updateFromView();                  
             }
         });
         components.add(enabledButton);
     }       
     else if (control.getLabel() != null)
     {
         // add label
         hasLabelOrCheckbox = true;
         label = new JLabel();
         label.setName(getName()+"/label");
         label.setText(control.getLabel());
         if (tooltip != null) label.setToolTipText(tooltip);
         components.add(label);
     }
     
     // date clock
     if (showMonthYear) {
         dateClock = new DateSpinner(showDay ? "dd.MM.yyyy" : "MM.yyyy");
         dateClock.setName(getName()+"/dateclock");
         if (tooltip != null) dateClock.setToolTipText(tooltip);
         components.add(dateClock);
     }
     // time clock
     if (showTime) {
         timeClock = new DateSpinner(show24HourClock ? "HH:mm:ss" : "hh:mm:ss");
         timeClock.setName(getName()+"/timeclock");
         if (tooltip != null) timeClock.setToolTipText(tooltip);
         components.add(timeClock);
     }

     // init value, if applicable
     setAndRenderInitValue( (XMLGregorianCalendar ) ControlHelper.getInitValue( control, getAtdl4jOptions() ), ((ClockT) control).getInitValueMode() );
     
     updateFromModel();
     return components;
}