Java Code Examples for javax.swing.ButtonGroup

The following examples show how to use javax.swing.ButtonGroup. These examples are extracted from open source projects. 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 Project: constellation   Source File: Toggle3DAction.java    License: 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 2
Source Project: constellation   Source File: ToggleDrawDirectedAction.java    License: 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 3
Source Project: openAGV   Source File: ToolBarManager.java    License: 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 4
Source Project: uima-uimaj   Source File: CasAnnotationViewer.java    License: 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 5
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 6
Source Project: wpcleaner   Source File: OptionsPanel.java    License: 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 7
Source Project: markdown-image-kit   Source File: ProjectSettingsPage.java    License: 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 8
Source Project: openjdk-8   Source File: MetalThemeMenu.java    License: 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 9
Source Project: visualvm   Source File: ProfilerPopup.java    License: 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 10
Source Project: WorldGrower   Source File: CommunityDialog.java    License: 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 11
Source Project: TencentKona-8   Source File: MetalThemeMenu.java    License: 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 12
Source Project: jdk8u-dev-jdk   Source File: MetalThemeMenu.java    License: 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 13
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 14
Source Project: javamoney-examples   Source File: ButtonHelper.java    License: 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 15
Source Project: android-screen-monitor   Source File: MainFrame.java    License: 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 16
Source Project: openjdk-jdk9   Source File: DirectionPanel.java    License: 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 17
Source Project: importer-exporter   Source File: LanguagePanel.java    License: 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 Project: marathonv5   Source File: GenealogyExample.java    License: 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 19
Source Project: ET_Redux   Source File: SplineOverDispersionChooserPanel.java    License: 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 20
Source Project: netbeans   Source File: JWSProjectProperties.java    License: 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 21
Source Project: GIFKR   Source File: ViewUtils.java    License: 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 22
Source Project: hottub   Source File: MetalThemeMenu.java    License: 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 23
@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 24
Source Project: constellation   Source File: DrawEdgesAction.java    License: 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 25
Source Project: constellation   Source File: DrawTransactionsAction.java    License: 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 DrawTransactionsAction(final GraphNode context, final ButtonGroup buttonGroup) {
    this.context = context;
    this.buttonGroup = buttonGroup;
    putValue(Action.SMALL_ICON, UserInterfaceIconProvider.TRANSACTIONS.buildIcon(16));
    putValue(Action.SHORT_DESCRIPTION, NbBundle.getMessage(this.getClass(), "CTL_DrawTransactionsAction"));
}
 
Example 26
Source Project: CQL   Source File: SketchFrame.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 *
 */
public MaintainConnectionDialog() {
	super(SketchFrame.this, "Cannot Edit Sketch With Active Connection");

	final ButtonGroup bg = new ButtonGroup();

	keepConnection = new JRadioButton("Keep connection and edit with subset of tools");
	throwConnection = new JRadioButton("Disconnect to have all tools");

	throwConnection.setSelected(true);
	bg.add(keepConnection);
	bg.add(throwConnection);
	setSize(435, 160);
	showDialog();
}
 
Example 27
private String getSelectedButton(ButtonGroup bGroup) {
    for (Enumeration<AbstractButton> buttons = bGroup.getElements(); buttons.hasMoreElements();) {
        AbstractButton button = buttons.nextElement();
        if (button.isSelected()) {
            return button.getText();
        }
    }
    return "None";
}
 
Example 28
private void createButtonsAndLabels() {
    copyAllRButton = new JRadioButton("Copy");
    geocodingRButton = new JRadioButton("Use Geocoding Only");
    subsetRButton = new JRadioButton("Use Subset");

    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(copyAllRButton);
    buttonGroup.add(geocodingRButton);
    buttonGroup.add(subsetRButton);

    copyAllRButton.setActionCommand(COPY_ALL_COMMAND);
    geocodingRButton.setActionCommand(COPY_GEOCODING_COMMAND);
    subsetRButton.setActionCommand(COPY_SUBSET_COMMAND);

    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateUI();
        }
    };
    copyAllRButton.addActionListener(listener);
    geocodingRButton.addActionListener(listener);
    subsetRButton.addActionListener(listener);

    if (subsetDef != null) {
        subsetRButton.setSelected(true);
    } else {
        geocodingRButton.setSelected(true);
    }

    subsetButton = new JButton("Subset...");
    subsetButton.addActionListener(createSubsetButtonListener());

    labelWidthInfo = new JLabel(DEFAULT_NUMBER_TEXT);
    labelHeightInfo = new JLabel(DEFAULT_NUMBER_TEXT);
    labelCenterLatInfo = new JLabel(DEFAULT_LATLON_TEXT);
    labelCenterLonInfo = new JLabel(DEFAULT_LATLON_TEXT);
}
 
Example 29
Source Project: iBioSim   Source File: Schematic.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * toolbar for when you're looking at a grid
 * @return
 */
private JToolBar buildGridToolbar() {
	
	JToolBar toolBar = new JToolBar();
	
	ButtonGroup modeButtonGroup = new ButtonGroup();
	selectButton = makeRadioToolButton("select_mode.png", "", "Select (" +
			KeyEvent.getKeyText(KeyEvent.VK_ESCAPE) + ")", this, modeButtonGroup); 
	toolBar.add(selectButton);
	selectButton.setSelected(true);
	addComponentButton = makeRadioToolButton("add_component.png", "", "Add Modules (M)", this, modeButtonGroup);
	toolBar.add(addComponentButton);
	toolBar.add(makeToolButton("", "editGridSize", "Edit Grid Size", this));
	
	toolBar.addSeparator();
	
	zoomButton = new JToggleButton();
	zoomButton.setText("Zoom");
	
	panButton = new JToggleButton();
	panButton.setText("Pan");
	
	toolBar.add(zoomButton);
	toolBar.add(makeToolButton("", "unZoom", "Un-Zoom", this));
	toolBar.add(panButton);
	
	toolBar.addSeparator();

	modelPanel = new ModelPanel(bioModel, modelEditor);
	toolBar.add(modelPanel);
	toolBar.setFloatable(false);
	
	/*
	compartmentList.setSelectedItem(bioModel.getDefaultCompartment());
	compartmentList.addActionListener(this);
	*/
	
	return toolBar;
}
 
Example 30
Source Project: DominionSim   Source File: DomGui.java    License: MIT License 5 votes vote down vote up
private ButtonGroup getRadioBTNsForStartState() {
  ButtonGroup theStartStateRBTNGroup = new ButtonGroup();
  JRadioButton theBTN = new JRadioButton("random start");
  theBTN.setSelected( true );
  theStartStateRBTNGroup.add(theBTN);
  theStartStateRBTNGroup.add(new JRadioButton("4/3 start"));
  theStartStateRBTNGroup.add(new JRadioButton("5/2 start"));
  return theStartStateRBTNGroup;
}