javax.swing.ButtonGroup Java Examples

The following examples show how to use javax.swing.ButtonGroup. 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: ButtonHelper.java    From javamoney-examples with Apache License 2.0 6 votes vote down vote up
/**
 * This method builds the specified button according to the specified
 * parameters.
 *
 * @param button The button to build.
 * @param text The text displayed on the button.
 * @param icon The icon to use.
 * @param handler The action listener that monitors the buttons events.
 * @param command The action command used when the button is clicked.
 * @param group The group the button should belong to.
 * @param selected The initial selected state of the button.
 * @param tip The tool tip to display.
 */
public
static
void
buildButton(AbstractButton button, String text, Icon icon,
    ActionListener handler, String command, ButtonGroup group,
    boolean selected, String tip)
{
  button.addActionListener(handler);
  button.setActionCommand(command);
  button.setIcon(icon);
  button.setSelected(selected);
  button.setText(text);
  button.setToolTipText(tip);

  if(group != null)
  {
    group.add(button);
  }
}
 
Example #2
Source File: JWSProjectProperties.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void initRadioButtons() {
    
    applicationDescButtonModel = new ToggleButtonModel();
    appletDescButtonModel = new ToggleButtonModel();
    compDescButtonModel = new ToggleButtonModel();
    bg = new ButtonGroup();
    applicationDescButtonModel.setGroup(bg);
    appletDescButtonModel.setGroup(bg);
    compDescButtonModel.setGroup(bg);
    
    String desc = evaluator.getProperty(JNLP_DESCRIPTOR);
    if (desc != null) {
        if (desc.equals(DescType.application.toString())) {
            applicationDescButtonModel.setSelected(true);
        } else if (desc.equals(DescType.applet.toString())) {
            appletDescButtonModel.setSelected(true);
        } else if (desc.equals(DescType.component.toString())) {
            compDescButtonModel.setSelected(true);
        }
    } else {
        applicationDescButtonModel.setSelected(true);
    }

}
 
Example #3
Source File: ToggleDrawDirectedAction.java    From constellation with Apache License 2.0 6 votes vote down vote up
/**
 * Construct a new action.
 *
 * @param context Graph Node.
 * @param buttonGroup The button group to which this action belongs.
 */
public ToggleDrawDirectedAction(final GraphNode context, final ButtonGroup buttonGroup) {
    this.context = context;
    this.buttonGroup = buttonGroup;

    final ReadableGraph rg = context.getGraph().getReadableGraph();
    final boolean drawDirected;
    try {
        final int drawDirectedAttribute = VisualConcept.GraphAttribute.DRAW_DIRECTED_TRANSACTIONS.get(rg);
        drawDirected = drawDirectedAttribute != Graph.NOT_FOUND ? rg.getBooleanValue(drawDirectedAttribute, 0) : VisualGraphDefaults.DEFAULT_DRAWING_DIRECTED_TRANSACTIONS;
    } finally {
        rg.release();
    }
    putValue(
            Action.SMALL_ICON,
            drawDirected ? DIRECTED_ICON : UNDIRECTED_ICON
    );
    putValue(Action.SHORT_DESCRIPTION, Bundle.CTL_ToggleDrawDirectedAction());
    putValue(Action.SELECTED_KEY, drawDirected);
}
 
Example #4
Source File: ToolBarManager.java    From openAGV with Apache License 2.0 6 votes vote down vote up
/**
   * Method addSelectionToolButton must have been invoked prior to this on the
   * JToolBar.
   *
   * @param toolBar
   * @param editor
   * @param tool
   * @param toolTipText
   * @param labels
   * @return
   */
  private JToggleButton addToolButton(JToolBar toolBar,
                                      DrawingEditor editor,
                                      Tool tool,
                                      String toolTipText,
                                      ImageIcon iconBase) {
    JToggleButton toggleButton = new JToggleButton();

    toggleButton.setIcon(iconBase);
    toggleButton.setText(null);
    toggleButton.setToolTipText(toolTipText);
    toggleButton.addItemListener(new ToolButtonListener(tool, editor));
//    toggleButton.setFocusable(false);

    ToolListener toolHandler = (ToolListener) toolBar.getClientProperty("toolHandler");
    tool.addToolListener(toolHandler);

    ButtonGroup group = (ButtonGroup) toolBar.getClientProperty("toolButtonGroup");
    group.add(toggleButton);
    toolBar.add(toggleButton);

    return toggleButton;
  }
 
Example #5
Source File: CasAnnotationViewer.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Adds the feature radio buttons.
 */
private void addFeatureRadioButtons() {
  if (this.featureRadioButtonMap.size() == 0) {
    return;
  }

  List<JRadioButton> radioButtons = new ArrayList<>(this.featureRadioButtonMap.values());
  radioButtons.sort(new Comparator<JRadioButton>() {
    @Override
    public int compare(JRadioButton arg0, JRadioButton arg1) {
      return arg0.getText().toLowerCase().compareTo(arg1.getText().toLowerCase());
    }
  });

  ButtonGroup featureRadioButtonGroup = new ButtonGroup();
  for (JRadioButton radioButton : radioButtons) {
    if (radioButton.getParent() != this.featureRadioButtonVerticalScrollPanel) {
      this.featureRadioButtonVerticalScrollPanel.add(radioButton);
    }
    featureRadioButtonGroup.add(radioButton);
  }
}
 
Example #6
Source File: MetalThemeMenu.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
 
Example #7
Source File: MetalThemeMenu.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
 
Example #8
Source File: SplineOverDispersionChooserPanel.java    From ET_Redux with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param sampleSessionDataView
 * @param fitFunctionView
 * @param sessionOfStandardsSplinesWithOD
 * @param bounds
 */
public SplineOverDispersionChooserPanel (//
        JLayeredPane sampleSessionDataView,//
        AbstractFitFunctionView fitFunctionView, //
        SortedMap<Double, AbstractFunctionOfX> sessionOfStandardsSplinesWithOD,//
        Rectangle bounds ) {
    super( bounds );

    this.sampleSessionDataView = sampleSessionDataView;
    this.fitFunctionView = fitFunctionView;
    this.sessionOfStandardsSplinesWithOD = sessionOfStandardsSplinesWithOD;

    this.splineWithOdChoiceButtons = new JButton[sessionOfStandardsSplinesWithOD.size()];

    setOpaque( true );
    setCursor( Cursor.getDefaultCursor() );

    fitFunctionButtonGroup = new ButtonGroup();
}
 
Example #9
Source File: ViewUtils.java    From GIFKR with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static JPanel enumToRadioPanel(Object defValue, Consumer<Object> listener) {
	JPanel setP = new JPanel();

	Object[] types = defValue.getClass().getEnumConstants();
	ButtonGroup bg = new ButtonGroup();
	setP.setLayout(new GridLayout(types.length, 1));

	for (Object o : types) {

		JRadioButton b = new JRadioButton(o.toString());
		if(o.equals(defValue))
			b.setSelected(true);

		setP.add(b);
		bg.add(b);
		b.addChangeListener( ae -> {
			if(b.isSelected())
				listener.accept(o);
		});
	}
	return setP;
}
 
Example #10
Source File: Toggle3DAction.java    From constellation with Apache License 2.0 6 votes vote down vote up
/**
 * Construct a new action.
 *
 * @param context Graph Node.
 * @param buttonGroup The button group to which this action belongs.
 */
public Toggle3DAction(final GraphNode context, final ButtonGroup buttonGroup) {
    this.context = context;
    this.buttonGroup = buttonGroup;
    final ReadableGraph rg = context.getGraph().getReadableGraph();
    final boolean isDisplayMode3D;
    try {
        final int displayMode3DAttribute = VisualConcept.GraphAttribute.DISPLAY_MODE_3D.get(rg);
        isDisplayMode3D = displayMode3DAttribute != Graph.NOT_FOUND ? rg.getBooleanValue(displayMode3DAttribute, 0) : VisualGraphDefaults.DEFAULT_DISPLAY_MODE_3D;
    } finally {
        rg.release();
    }
    putValue(
            Action.SMALL_ICON,
            isDisplayMode3D ? MODE_3D_ICON : MODE_2D_ICON
    );
    putValue(Action.SHORT_DESCRIPTION, Bundle.CTL_Toggle3DAction());
    putValue(Action.SELECTED_KEY, isDisplayMode3D);
}
 
Example #11
Source File: PerspectiveMenu.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
private void updatePerspectives(List<Perspective> perspectives) {
	removeAll();
	perspectiveMap.clear();
	workspaceMenuGroup = new ButtonGroup();
	for (Perspective p : perspectives) {
		ResourceAction action = perspectiveController.createPerspectiveAction(p);

		JMenuItem menuItem = new JRadioButtonMenuItem(action);
		add(menuItem);
		perspectiveMap.put(p.getName(), menuItem);
		workspaceMenuGroup.add(menuItem);
	}
	if (perspectiveMap.containsKey(perspectiveName)) {
		perspectiveMap.get(perspectiveName).setSelected(true);
	}
}
 
Example #12
Source File: OptionsPanel.java    From wpcleaner with Apache License 2.0 6 votes vote down vote up
/**
 * Restore all integer options to their default values.
 */
private void defaultValuesInteger() {
  for (Entry<ConfigurationValueInteger, Object> entry : integerValues.entrySet()) {
    if ((entry.getValue() != null) && (entry.getKey() != null)) {
      if (entry.getValue() instanceof JSpinner) {
        JSpinner spinner = (JSpinner) entry.getValue();
        SpinnerModel model = spinner.getModel();
        model.setValue(Integer.valueOf(entry.getKey().getDefaultValue()));
      }
      if (entry.getValue() instanceof ButtonGroup) {
        ButtonGroup group = (ButtonGroup) entry.getValue();
        setButtonGroupSelection(group, entry.getKey().getDefaultValue());
      }
    }
  }
}
 
Example #13
Source File: GenealogyExample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public GenealogyExample() {
    super(new BorderLayout());

    // Construct the panel with the toggle buttons.
    JRadioButton showDescendant = new JRadioButton("Show descendants", true);
    final JRadioButton showAncestor = new JRadioButton("Show ancestors");
    ButtonGroup bGroup = new ButtonGroup();
    bGroup.add(showDescendant);
    bGroup.add(showAncestor);
    showDescendant.addActionListener(this);
    showAncestor.addActionListener(this);
    showAncestor.setActionCommand(SHOW_ANCESTOR_CMD);
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(showDescendant);
    buttonPanel.add(showAncestor);

    // Construct the tree.
    tree = new GenealogyTree(getGenealogyGraph());
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setPreferredSize(new Dimension(200, 200));

    // Add everything to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(scrollPane, BorderLayout.CENTER);
}
 
Example #14
Source File: ProjectSettingsPage.java    From markdown-image-kit with MIT License 6 votes vote down vote up
/**
 * 处理被选中的单选框
 *
 * @param group  the group
 * @param button the button
 */
private void addChangeTagRadioButton(@NotNull ButtonGroup group, JRadioButton button) {
    group.add(button);
    // 构造一个监听器,响应checkBox事件
    ActionListener actionListener = e -> {
        Object sourceObject = e.getSource();
        if (sourceObject instanceof JRadioButton) {
            JRadioButton sourceButton = (JRadioButton) sourceObject;
            if (ImageMarkEnum.CUSTOM.text.equals(sourceButton.getText())) {
                customHtmlTypeTextField.setEnabled(true);
            } else {
                customHtmlTypeTextField.setEnabled(false);
            }
        }
    };
    button.addActionListener(actionListener);
}
 
Example #15
Source File: MetalThemeMenu.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
 
Example #16
Source File: ProfilerPopup.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public Component getDefaultComponent(Container aContainer) {
    Component c = getFirstComponent(aContainer);
    
    if (c instanceof AbstractButton) {
        ButtonModel bm = ((AbstractButton)c).getModel();
        if (bm instanceof DefaultButtonModel) {
            ButtonGroup bg = ((DefaultButtonModel)bm).getGroup();
            Enumeration<AbstractButton> en = bg == null ? null : bg.getElements();
            while (en != null && en.hasMoreElements()) {
                AbstractButton ab = en.nextElement();
                if (ab.isSelected()) return ab;
            }
        }
    }
    
    return c;
}
 
Example #17
Source File: LanguagePanel.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
private void initGui() {		
	importLanguageRadioDe = new JRadioButton("");
	importLanguageRadioEn = new JRadioButton("");
	ButtonGroup importLanguageRadio = new ButtonGroup();
	importLanguageRadio.add(importLanguageRadioDe);
	importLanguageRadio.add(importLanguageRadioEn);
	
	setLayout(new GridBagLayout());
	{
		language = new JPanel();
		add(language, GuiUtil.setConstraints(0,0,1.0,0.0,GridBagConstraints.BOTH,5,0,5,0));
		language.setBorder(BorderFactory.createTitledBorder(""));
		language.setLayout(new GridBagLayout());
		importLanguageRadioDe.setIconTextGap(10);
		importLanguageRadioEn.setIconTextGap(10);
		{
			language.add(importLanguageRadioDe, GuiUtil.setConstraints(0,0,1.0,1.0,GridBagConstraints.BOTH,0,5,0,5));
			language.add(importLanguageRadioEn, GuiUtil.setConstraints(0,1,1.0,1.0,GridBagConstraints.BOTH,0,5,0,5));
		}
	}
}
 
Example #18
Source File: CommunityDialog.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
private void createToggleButtonPanel(SoundIdReader soundIdReader, int infoPanelWidth, CardLayout cardLayout, JPanel infoPanel) {
	JPanel toggleButtonPanel = JPanelFactory.createBorderlessPanel();
	toggleButtonPanel.setBounds(5, 5, infoPanelWidth, 40);
	toggleButtonPanel.setLayout(new FlowLayout());
	contentPanel.add(toggleButtonPanel);

	ButtonGroup buttonGroup = new ButtonGroup();
	
	JToggleButton familyButton = createToggleButton("Family", FAMILY_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows family members of the player character");

	createToggleButton("Acquaintances", ACQUAINTANCES_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows acquaintances of the player character");
	createToggleButton("Player Character Ranks", RANKS_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows group memberships of the player character");
	createToggleButton("Organizations", ORGANIZATIONS_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows an overview of all organizations and their members");
	createToggleButton("Deities", DEITIES_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows an overview of all deities and their happiness");
	
	buttonGroup.setSelected(familyButton.getModel(), true);
}
 
Example #19
Source File: MetalThemeMenu.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
 
Example #20
Source File: MetalThemeMenu.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
 
Example #21
Source File: DirectionPanel.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A layout direction button
 */
public DirectionButton(Icon icon, Icon downIcon, String direction,
        String description, ActionListener l,
        ButtonGroup group, boolean selected) {
    super();
    this.addActionListener(l);
    setFocusPainted(false);
    setHorizontalTextPosition(CENTER);
    group.add(this);
    setIcon(icon);
    setSelectedIcon(downIcon);
    setActionCommand(direction);
    getAccessibleContext().setAccessibleName(direction);
    getAccessibleContext().setAccessibleDescription(description);
    setSelected(selected);
}
 
Example #22
Source File: CapturingHardwareManager.java    From IrScrutinizer with GNU General Public License v3.0 6 votes vote down vote up
private void createMenu(String selection) {
    menu = new JMenu();
    menu.setText("Capturing Hardware");
    menu.setToolTipText("Allows direct selection of capturing hardware");
    buttonGroup = new ButtonGroup();
    table.entrySet().stream().map((kvp) -> {
        String name = kvp.getKey();
        final ICapturingHardware<?> hardware = kvp.getValue();
        JRadioButton menuItem = new JRadioButton(name);
        menuItem.setSelected(name.equals(selection));
        //portRadioButtons[i] = menuItem;
        menuItem.addActionListener((java.awt.event.ActionEvent evt) -> {
            try {
                select(hardware);
            } catch (IOException | HarcHardwareException ex) {
                guiUtils.error(ex);
            }
        });
        return menuItem;
    }).map((menuItem) -> {
        buttonGroup.add(menuItem);
        return menuItem;
    }).forEachOrdered((menuItem) -> {
        menu.add(menuItem);
    });
}
 
Example #23
Source File: MainFrame.java    From android-screen-monitor with Apache License 2.0 6 votes vote down vote up
private void addRadioButtonMenuItemZoom(
		JMenu menuZoom, ButtonGroup buttonGroup,
		final double zoom, String caption, int nemonic,
		double currentZoom) {
	JRadioButtonMenuItem radioButtonMenuItemZoom = new JRadioButtonMenuItem(caption);
	if (nemonic != -1) {
		radioButtonMenuItemZoom.setMnemonic(nemonic);
	}
	radioButtonMenuItemZoom.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			setZoom(zoom);
		}
	});
	if (currentZoom == zoom) {
		radioButtonMenuItemZoom.setSelected(true);
	}
	buttonGroup.add(radioButtonMenuItemZoom);
	menuZoom.add(radioButtonMenuItemZoom);
}
 
Example #24
Source File: ImagePopUpMenuPlugin.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Nonnull
private JPanel makeSelectPanel(@Nonnull @MustNotContainNull final String[] options, @Nonnull final AtomicInteger selected) {
  final JPanel panel = new JPanel(new GridBagLayout());

  final GridBagConstraints constraint = new GridBagConstraints();
  constraint.gridx = 0;
  constraint.fill = GridBagConstraints.HORIZONTAL;
  constraint.anchor = GridBagConstraints.WEST;

  final ButtonGroup group = UI_COMPO_FACTORY.makeButtonGroup();

  int selectedIndex = lastSelectedImportIndex;

  for (int i = 0; i < options.length; i++) {
    final JRadioButton button = UI_COMPO_FACTORY.makeRadioButton();
    button.setText(options[i]);
    if (selectedIndex == i) {
      button.setSelected(true);
      selected.set(i);
    }
    group.add(button);

    final int currentIndex = i;

    button.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(@Nonnull final ActionEvent e) {
        if (button.isSelected()) {
          selected.set(currentIndex);
        }
      }
    });

    panel.add(button, constraint);
  }

  return panel;
}
 
Example #25
Source File: LayersMenu.java    From amidst with GNU General Public License v3.0 5 votes vote down vote up
@CalledOnlyBy(AmidstThread.EDT)
private void createOverworldAndEndLayers(Dimension dimension) {
	// @formatter:off
	ButtonGroup group = new ButtonGroup();
	Menus.radio(   menu, dimensionSetting, group,     Dimension.OVERWORLD,                                      MenuShortcuts.DISPLAY_DIMENSION_OVERWORLD);
	createOverworldLayers(dimension);
	menu.addSeparator();
	Menus.radio(   menu, dimensionSetting, group,     Dimension.END,                                            MenuShortcuts.DISPLAY_DIMENSION_END);
	endLayer(      settings.showEndCities,            "End City Icons",         getIcon("end_city.png"),        MenuShortcuts.SHOW_END_CITIES, dimension, LayerIds.END_CITY);
	// @formatter:on
}
 
Example #26
Source File: ShapeSelectionPanel.java    From settlers-remake with MIT License 5 votes vote down vote up
/**
 * Constructor
 */
public ShapeSelectionPanel() {
	super(BoxLayout.Y_AXIS);
	JToolBar tb = new JToolBar();
	tb.setFloatable(false);

	ButtonGroup group = new ButtonGroup();

	for (EShapeType type : EShapeType.values()) {
		JToggleButton bt = new JToggleButton(type.getIcon());
		bt.setDisabledIcon(type.getIcon().createDisabledIcon());
		bt.setSelectedIcon(type.getIcon().createSelectedIcon());
		bt.setToolTipText(type.getShape().getName());
		bt.addActionListener(new ShapeActionListener(type.getShape()));
		bt.setEnabled(false);
		tb.add(bt);
		group.add(bt);
		buttons.put(type, bt);
	}

	add(tb);

	for (EShapeProperty p : EShapeProperty.values()) {
		StrokenSlider slider = new StrokenSlider(p);
		properties.put(p, slider);

		add(slider);
	}

	updateStrokeProperties();
}
 
Example #27
Source File: FileRecognitionPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form FileRecognitionPanel
 */
public FileRecognitionPanel(WizardDescriptor setting, NewLoaderIterator.DataModel data) {
    super(setting);
    this.data = data;
    initComponents();
    initAccessibility();
    group = new ButtonGroup();
    group.add(rbByElement);
    group.add(rbByExtension);
    ActionListener list = new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            txtExtension.setEnabled(rbByExtension.isSelected());
            txtNamespace.setEnabled(rbByElement.isSelected());
            checkValidity();
        }
    };
    docList = new UIUtil.DocumentAdapter() {
        public void insertUpdate(DocumentEvent e) {
            checkValidity();
        }
    };
    
    rbByElement.addActionListener(list);
    rbByExtension.addActionListener(list);
    
    putClientProperty("NewFileWizard_Title", getMessage("LBL_LoaderWizardTitle"));
}
 
Example #28
Source File: DrawEdgesAction.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a new action.
 *
 * @param context Graph Node.
 * @param buttonGroup The button group to which this action belongs.
 */
public DrawEdgesAction(final GraphNode context, final ButtonGroup buttonGroup) {
    this.context = context;
    this.buttonGroup = buttonGroup;
    putValue(Action.SMALL_ICON, UserInterfaceIconProvider.EDGES.buildIcon(16));
    putValue(Action.SHORT_DESCRIPTION, NbBundle.getMessage(this.getClass(), "CTL_DrawEdgesAction"));
    putValue(Action.SELECTED_KEY, true);
}
 
Example #29
Source File: SwingSet2.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
 * Create a radio button menu menu item for items that are part of a
 * button group.
 *
 * @param menu the menu
 * @param label the label
 * @param mnemonic the mnemonic
 * @param accessibleDescription the accessible description
 * @param action the action
 * @param buttonGroup the button group
 * @return the j menu item
 */
private JMenuItem createButtonGroupMenuItem(JMenu menu, String label,
		String mnemonic,
		String accessibleDescription,
		Action action,
		ButtonGroup buttonGroup) {
	JRadioButtonMenuItem mi = (JRadioButtonMenuItem)menu.add(
			new JRadioButtonMenuItem(getString(label)));
	buttonGroup.add(mi);
	mi.setMnemonic(getMnemonic(mnemonic));
	mi.getAccessibleContext().setAccessibleDescription(getString(
			accessibleDescription));
	mi.addActionListener(action);
	return mi;
}
 
Example #30
Source File: ProfilesMenuBuilder.java    From raccoon4 with Apache License 2.0 5 votes vote down vote up
@Override
public void onDataSetChange(DatasetEvent event) {
	if (event instanceof PlayProfileEvent) {
		PlayProfileEvent ppe = (PlayProfileEvent) event;
		if (ppe.isConnection()) {
			boolean a = ppe.isActivation();
			edit.setEnabled(a);
			delete.setEnabled(a);
		}
		menu.removeAll();
		PlayProfileDao dao = (PlayProfileDao) event.getSource();
		List<PlayProfile> profiles = dao.list();
		PlayProfile def = dao.get();
		ButtonGroup bg = new ButtonGroup();

		for (PlayProfile profile : profiles) {
			ProfileAction pa = new ProfileAction(globals, profile);
			JRadioButtonMenuItem item = new JRadioButtonMenuItem(pa);
			bg.add(item);
			menu.add(item);
			item.setSelected(def != null
					&& def.getAlias().equals(profile.getAlias()));
		}
		menu.add(new JSeparator());
		menu.add(add);
		menu.add(edit);
		menu.add(delete);
	}
}