Java Code Examples for javax.swing.JRadioButton#setSelected()

The following examples show how to use javax.swing.JRadioButton#setSelected() . 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: SwingRadioButtonListWidget.java    From atdl4j with MIT License 6 votes vote down vote up
@Override
public void processReinit( Object aControlInitValue )
{
	if ( aControlInitValue != null )
	{
		// -- apply initValue if one has been specified --
		setValue( (String) aControlInitValue, true );
	}
	else
	{
		// -- reset each when no initValue exists --
		for ( JRadioButton tempButton : buttons )
		{
			if ( ( tempButton != null ) )
			{
				tempButton.setSelected( false );
			}
		}
	}
}
 
Example 2
Source File: SketchFrame.java    From CQL with 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 3
Source File: JSFTargetPanelProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected int initSyntaxButton(int gridy ,final TargetChooserPanel<FileType> panel ,
        final TargetChooserPanelGUI<FileType> uiPanel) 
{
    myFaceletsSyntaxButton = new JRadioButton();
    
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    myFaceletsSyntaxButton.setSelected(true);
    getSegmentBox().setEnabled(false);
    myFaceletsSyntaxButton.setMnemonic(NbBundle.getMessage(
            JSFTargetPanelProvider.class, "A11Y_Facelets_mnem").charAt(0));
    getButtonGroup().add(myFaceletsSyntaxButton);
    myFaceletsSyntaxButton.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(ItemEvent evt) {
            checkBoxChanged(evt, panel , uiPanel);
        }
    });

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = gridy++;
    gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    getOptionPanel().add(myFaceletsSyntaxButton,gridBagConstraints);
    
    getJspSyntaxButton().setMnemonic(NbBundle.getMessage(
            JSFTargetPanelProvider.class, "A11Y_JspStandard_mnem").charAt(0));
    return gridy;
}
 
Example 4
Source File: HonoReceiverSamplerUI.java    From hono with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void configure(final TestElement element) {
    super.configure(element);
    final HonoReceiverSampler sampler = (HonoReceiverSampler) element;
    sampler.configureServerOptions(honoServerOptions);
    endpoint.setText(sampler.getEndpoint());
    tenant.setText(sampler.getTenant());
    container.setText(sampler.getContainer());
    prefetch.setText(sampler.getPrefetch());
    reconnectAttempts.setText(sampler.getReconnectAttempts());
    useSenderTime.setSelected(sampler.isUseSenderTime());
    final JRadioButton senderTimeButtonToSelect = sampler.isSenderTimeInPayload() ? senderTimeInPayload : senderTimeInProperty;
    senderTimeButtonToSelect.setSelected(true);
    senderTimeVariableName.setText(sampler.getSenderTimeVariableName());
}
 
Example 5
Source File: DeviceLogic.java    From raccoon4 with Apache License 2.0 5 votes vote down vote up
@Override
protected JPanel assemble() {

	HyperTextPane about = new HyperTextPane(
			Messages.getString("DeviceLogic.about")).withWidth(500)
			.withTransparency();
	mock = new JRadioButton(Messages.getString("DeviceLogic.mock"));
	existing = new JRadioButton(Messages.getString("DeviceLogic.existing"));
	ButtonGroup bg = new ButtonGroup();
	bg.add(mock);
	bg.add(existing);
	mock.setSelected(true);

	JPanel ret = new JPanel();
	ret.setLayout(new GridBagLayout());
	GridBagConstraints gbc = new GridBagConstraints();
	gbc.gridx = GridBagConstraints.REMAINDER;
	gbc.gridy = GridBagConstraints.RELATIVE;
	gbc.insets.bottom = 20;
	JPanel choices = new JPanel();
	choices.setLayout(new BoxLayout(choices, BoxLayout.Y_AXIS));
	choices.add(mock, gbc);
	choices.add(existing, gbc);
	ret.add(about, gbc);
	ret.add(choices, gbc);

	return ret;
}
 
Example 6
Source File: BinningFilterPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void init() {
    ButtonGroup buttonGroup = new ButtonGroup();

    final JRadioButton computeOption = new JRadioButton("Compute the geographical region according to extents of input products");
    final JRadioButton globalOption = new JRadioButton("Use the whole globe as region");
    final JRadioButton regionOption = new JRadioButton("Specify region:");
    final JRadioButton wktOption = new JRadioButton("Enter WKT:");

    bindingContext.bind(BinningFormModel.PROPERTY_KEY_COMPUTE_REGION, new RadioButtonAdapter(computeOption));
    bindingContext.bind(BinningFormModel.PROPERTY_KEY_GLOBAL, new RadioButtonAdapter(globalOption));
    bindingContext.bind(BinningFormModel.PROPERTY_KEY_MANUAL_WKT, new RadioButtonAdapter(wktOption));
    bindingContext.bind(BinningFormModel.PROPERTY_KEY_BOUNDS, new RadioButtonAdapter(regionOption));

    buttonGroup.add(computeOption);
    buttonGroup.add(globalOption);
    buttonGroup.add(wktOption);
    buttonGroup.add(regionOption);

    computeOption.setSelected(true);

    final TableLayout layout = new TableLayout(1);
    layout.setTableAnchor(TableLayout.Anchor.NORTHEAST);
    layout.setTableFill(TableLayout.Fill.HORIZONTAL);
    layout.setTableWeightX(1.0);
    layout.setTablePadding(4, 3);
    setLayout(layout);

    add(new TitledSeparator("Spatial Filter / Region", SwingConstants.CENTER));
    add(computeOption);
    add(globalOption);
    add(wktOption);
    add(createWktInputPanel());
    add(regionOption);
    add(createAndInitBoundsUI());

    add(new TitledSeparator("Temporal Filter", SwingConstants.CENTER));
    add(createTemporalFilterPanel());
    add(layout.createVerticalSpacer());
}
 
Example 7
Source File: HonoReceiverSamplerUI.java    From hono with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates a new UI that provides means to configure
 * the northbound Telemetry &amp; Event API endpoint to connect to
 * for receiving messages.
 */
public HonoReceiverSamplerUI() {

    honoServerOptions = new ServerOptionsPanel("Telemetry & Event Endpoint");
    tenant = new JLabeledTextField("Tenant");
    container = new JLabeledTextField("Name");
    endpoint = new JLabeledChoice("Endpoint",
            Stream.of(HonoSampler.Endpoint.values()).map(HonoSampler.Endpoint::name).toArray(String[]::new));
    endpoint.setToolTipText("<html>The name of the endpoint to send the AMQP message to.</html>");
    useSenderTime = new JCheckBox("Use sender time");
    senderTimeInProperty = new JRadioButton("Sender time in property");
    senderTimeInProperty.setToolTipText("<html>If set, the sending time is retrieved from the message's application property <em>timeStamp</em>.</html>");
    senderTimeInPayload = new JRadioButton("Sender time in JSON payload");
    final ButtonGroup group = new ButtonGroup();
    group.add(senderTimeInProperty);
    group.add(senderTimeInPayload);
    senderTimeInProperty.setSelected(true);
    senderTimeVariableName = new JLabeledTextField("JSON value key");
    senderTimeVariableName.setEnabled(false);
    prefetch = new JLabeledTextField("Prefetch");
    reconnectAttempts = new JLabeledTextField("Max reconnect attempts");

    addOption(honoServerOptions);
    addOption(tenant);
    addOption(container);
    addOption(getWrapperPanelToFixAlignment(endpoint));
    addOption(prefetch);
    addOption(reconnectAttempts);
    addOption(createTimeStampPanel());
}
 
Example 8
Source File: HttpFuzzerMessageProcessorTagUIPanel.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
private void addRadioButton(JRadioButton radio, String name, boolean selected) {
    radio.setText(name);
    radio.setSelected(selected);
    fieldsPanel.add(radio);
    fieldsPanel.add(new Panel());
    radioGroup.add(radio);
}
 
Example 9
Source File: ReplaceTraceDialog.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public ReplaceTraceDialog(String defaultVal) {
    setTitle(translate("dialog.title"));
    Container cnt = getContentPane();
    cnt.setLayout(new BoxLayout(cnt, BoxLayout.Y_AXIS));
    debugAlertRadio = new JRadioButton(translate("function.debugAlert"));
    debugAlertRadio.setAlignmentX(0);
    debugConsoleRadio = new JRadioButton(translate("function.debugConsole"));
    debugConsoleRadio.setAlignmentX(0);
    debugSocketRadio = new JRadioButton(translate("function.debugSocket"));
    debugSocketRadio.setAlignmentX(0);

    debugAlertRadio.setSelected(true);

    ButtonGroup bg = new ButtonGroup();
    bg.add(debugAlertRadio);
    bg.add(debugConsoleRadio);
    bg.add(debugSocketRadio);

    cnt.add(debugAlertRadio);
    cnt.add(debugConsoleRadio);
    cnt.add(debugSocketRadio);

    JPanel buttonsPanel = new JPanel(new FlowLayout());
    JButton okButton = new JButton(AppStrings.translate("button.ok"));
    okButton.addActionListener(this::okButtonActionPerformed);
    JButton cancelButton = new JButton(AppStrings.translate("button.cancel"));
    cancelButton.addActionListener(this::cancelButtonActionPerformed);
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    buttonsPanel.setAlignmentX(0);
    add(buttonsPanel);
    setModalityType(DEFAULT_MODALITY_TYPE);
    pack();
    View.setWindowIcon(this);
    View.centerScreen(this);
    setValue(defaultVal);
}
 
Example 10
Source File: MetalworksPrefs.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public JPanel buildFilterPanel() {
    JPanel filters = new JPanel();
    filters.setLayout(new GridLayout(1, 0));

    JPanel spamPanel = new JPanel();

    spamPanel.setLayout(new ColumnLayout());
    spamPanel.setBorder(new TitledBorder("Spam"));
    ButtonGroup spamGroup = new ButtonGroup();
    JRadioButton file = new JRadioButton("File in Spam Folder");
    JRadioButton delete = new JRadioButton("Auto Delete");
    JRadioButton bomb = new JRadioButton("Reverse Mail-Bomb");
    spamGroup.add(file);
    spamGroup.add(delete);
    spamGroup.add(bomb);
    spamPanel.add(file);
    spamPanel.add(delete);
    spamPanel.add(bomb);
    file.setSelected(true);
    filters.add(spamPanel);

    JPanel autoRespond = new JPanel();
    autoRespond.setLayout(new ColumnLayout());
    autoRespond.setBorder(new TitledBorder("Auto Response"));

    ButtonGroup respondGroup = new ButtonGroup();
    JRadioButton none = new JRadioButton("None");
    JRadioButton vaca = new JRadioButton("Send Vacation Message");
    JRadioButton thx = new JRadioButton("Send Thank You Message");

    respondGroup.add(none);
    respondGroup.add(vaca);
    respondGroup.add(thx);

    autoRespond.add(none);
    autoRespond.add(vaca);
    autoRespond.add(thx);

    none.setSelected(true);
    filters.add(autoRespond);

    return filters;
}
 
Example 11
Source File: MetalworksPrefs.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public JPanel buildFilterPanel() {
    JPanel filters = new JPanel();
    filters.setLayout(new GridLayout(1, 0));

    JPanel spamPanel = new JPanel();

    spamPanel.setLayout(new ColumnLayout());
    spamPanel.setBorder(new TitledBorder("Spam"));
    ButtonGroup spamGroup = new ButtonGroup();
    JRadioButton file = new JRadioButton("File in Spam Folder");
    JRadioButton delete = new JRadioButton("Auto Delete");
    JRadioButton bomb = new JRadioButton("Reverse Mail-Bomb");
    spamGroup.add(file);
    spamGroup.add(delete);
    spamGroup.add(bomb);
    spamPanel.add(file);
    spamPanel.add(delete);
    spamPanel.add(bomb);
    file.setSelected(true);
    filters.add(spamPanel);

    JPanel autoRespond = new JPanel();
    autoRespond.setLayout(new ColumnLayout());
    autoRespond.setBorder(new TitledBorder("Auto Response"));

    ButtonGroup respondGroup = new ButtonGroup();
    JRadioButton none = new JRadioButton("None");
    JRadioButton vaca = new JRadioButton("Send Vacation Message");
    JRadioButton thx = new JRadioButton("Send Thank You Message");

    respondGroup.add(none);
    respondGroup.add(vaca);
    respondGroup.add(thx);

    autoRespond.add(none);
    autoRespond.add(vaca);
    autoRespond.add(thx);

    none.setSelected(true);
    filters.add(autoRespond);

    return filters;
}
 
Example 12
Source File: MetalworksPrefs.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public JPanel buildFilterPanel() {
    JPanel filters = new JPanel();
    filters.setLayout(new GridLayout(1, 0));

    JPanel spamPanel = new JPanel();

    spamPanel.setLayout(new ColumnLayout());
    spamPanel.setBorder(new TitledBorder("Spam"));
    ButtonGroup spamGroup = new ButtonGroup();
    JRadioButton file = new JRadioButton("File in Spam Folder");
    JRadioButton delete = new JRadioButton("Auto Delete");
    JRadioButton bomb = new JRadioButton("Reverse Mail-Bomb");
    spamGroup.add(file);
    spamGroup.add(delete);
    spamGroup.add(bomb);
    spamPanel.add(file);
    spamPanel.add(delete);
    spamPanel.add(bomb);
    file.setSelected(true);
    filters.add(spamPanel);

    JPanel autoRespond = new JPanel();
    autoRespond.setLayout(new ColumnLayout());
    autoRespond.setBorder(new TitledBorder("Auto Response"));

    ButtonGroup respondGroup = new ButtonGroup();
    JRadioButton none = new JRadioButton("None");
    JRadioButton vaca = new JRadioButton("Send Vacation Message");
    JRadioButton thx = new JRadioButton("Send Thank You Message");

    respondGroup.add(none);
    respondGroup.add(vaca);
    respondGroup.add(thx);

    autoRespond.add(none);
    autoRespond.add(vaca);
    autoRespond.add(thx);

    none.setSelected(true);
    filters.add(autoRespond);

    return filters;
}
 
Example 13
Source File: EditTrafficModelControlPanel.java    From VanetSim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor, creating GUI items.
 */
public EditTrafficModelControlPanel() {
	setLayout(new GridBagLayout());
	
	// global layout settings
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	c.anchor = GridBagConstraints.PAGE_START;
	c.weightx = 0.5;
	c.gridx = 0;
	c.gridy = 0;
	c.gridheight = 1;
	
	c.gridwidth = 1;

	c.insets = new Insets(5,5,5,5);
	
	c.gridx = 0;
	
	// Radio buttons to select add, edit or delete mode
	ButtonGroup group = new ButtonGroup();
	selectModel_ = new JRadioButton(Messages.getString("EditTrafficControlPanel.model")); //$NON-NLS-1$
	selectModel_.setActionCommand("model"); //$NON-NLS-1$
	selectModel_.addActionListener(this);
	selectModel_.setSelected(true);
	group.add(selectModel_);
	++c.gridy;
	add(selectModel_,c);
			
	selectTraces_ = new JRadioButton(Messages.getString("EditTrafficControlPanel.traces")); //$NON-NLS-1$
	selectTraces_.setActionCommand("traces"); //$NON-NLS-1$
	selectTraces_.addActionListener(this);
	group.add(selectTraces_);
	++c.gridy;
	add(selectTraces_,c);
		
	
	c.gridx = 0;
	chooseTrafficModelLabel_ = new JLabel(Messages.getString("EditTrafficControlPanel.comboBoxModel")); //$NON-NLS-1$
	++c.gridy;
	add(chooseTrafficModelLabel_,c);
	chooseTrafficModel_ = new JComboBox<String>();
	chooseTrafficModel_.setActionCommand("chooseTrafficModel");
	chooseTrafficModel_.addItem("VANETSim classic");
	chooseTrafficModel_.addItem("IDM/MOBIL");
	chooseTrafficModel_.addActionListener(this);
	c.gridx = 1;
	add(chooseTrafficModel_, c);
	
	
	c.gridx = 0;
	chooseTracesLabel_ = new JLabel(Messages.getString("EditTrafficControlPanel.comboBoxTraces")); //$NON-NLS-1$
	++c.gridy;
	add(chooseTracesLabel_,c);
	chooseTraces_ = new JComboBox<String>();
	chooseTraces_.setActionCommand("chooseTraces");
	chooseTraces_.addItem("sjtu taxi traces");
	chooseTraces_.addItem("San Francisco traces");
	chooseTraces_.addActionListener(this);
	c.gridx = 1;
	add(chooseTraces_, c);
	chooseTraces_.setVisible(false);
	chooseTracesLabel_.setVisible(false);
	
	
	
	//to consume the rest of the space
	c.weighty = 1.0;
	++c.gridy;
	JPanel space = new JPanel();
	space.setOpaque(false);
	add(space, c);
}
 
Example 14
Source File: CrewEditor.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Set up personality radio buttons
 * 
 * @param col
 */
public void setUpCrewPersonality() {
	for (int col = 0; col < crewNum; col++) {
		ppane = new JPanel(new GridLayout(4, 1));

		String quadrant1A = "Extravert", quadrant1B = "Introvert";
		String quadrant2A = "Intuition", quadrant2B = "Sensing";
		String quadrant3A = "Feeling", quadrant3B = "Thinking";
		String quadrant4A = "Judging", quadrant4B = "Perceiving";
		String cat1 = "World", cat2 = "Information", cat3 = "Decision", cat4 = "Structure";
		String a = null, b = null, c = null;

		for (int row = 0; row < 4; row++) {
			qpane = new JPanel(new FlowLayout());
			if (row == 0) {
				a = quadrant1A;
				b = quadrant1B;
				c = cat1;
			} else if (row == 1) {
				a = quadrant2A;
				b = quadrant2B;
				c = cat2;
			} else if (row == 2) {
				a = quadrant3A;
				b = quadrant3B;
				c = cat3;
			} else if (row == 3) {
				a = quadrant4A;
				b = quadrant4B;
				c = cat4;
			}

			JRadioButton ra = new JRadioButton(a);
			ra.addActionListener(this);
			ra.setActionCommand("a" + row + col);
			JRadioButton rb = new JRadioButton(b);
			rb.setActionCommand("b" + row + col);
			rb.addActionListener(this);
			
			if (retrieveCrewMBTI(row, col))
				ra.setSelected(true);
			else
				rb.setSelected(true);
			
			ButtonGroup bg1 = new ButtonGroup();
			bg1.add(ra);
			bg1.add(rb);
			qpane.setBorder(BorderFactory.createTitledBorder(c));
			qpane.add(ra);
			qpane.add(rb);
			ppane.add(qpane);
		}
		radioPane.add(ppane);

	}
}
 
Example 15
Source File: VerifierSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * This is the control panel of the Verifier GUI
 */
private void createControlPanel() {
    allButton = new JRadioButton();
    org.openide.awt.Mnemonics.setLocalizedText(allButton, allString); // NOI18N
    failButton = new JRadioButton();
    org.openide.awt.Mnemonics.setLocalizedText(failButton, failString); // NOI18N
    warnButton = new JRadioButton();
    org.openide.awt.Mnemonics.setLocalizedText(warnButton, warnString); // NOI18N
    controlPanel = new JPanel();
    
    // 508 for this panel
    controlPanel.getAccessibleContext().setAccessibleName(panelName);
    controlPanel.getAccessibleContext().setAccessibleDescription(panelDesc);
    allButton.getAccessibleContext().setAccessibleName(radioButtonName);
    allButton.getAccessibleContext().setAccessibleDescription(radioButtonDesc);
    failButton.getAccessibleContext().setAccessibleName(radioButtonName);
    failButton.getAccessibleContext().setAccessibleDescription(radioButtonDesc);
    warnButton.getAccessibleContext().setAccessibleName(radioButtonName);
    warnButton.getAccessibleContext().setAccessibleDescription(radioButtonDesc);
    
    controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.Y_AXIS));
    
    // set-up the radio buttons.
    allButton.setActionCommand(allString);
    allButton.setSelected(true);
    failButton.setActionCommand(failString);
    warnButton.setActionCommand(warnString);
    
    // Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(allButton);
    group.add(failButton);
    group.add(warnButton);
    
    // Put the radio buttons in a column in a panel
    JPanel radioPanel = new JPanel();
    // 508 for this panel
    radioPanel.getAccessibleContext().setAccessibleName(panelName);
    radioPanel.getAccessibleContext().setAccessibleDescription(panelDesc);
    radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.X_AXIS));
    JLabel d = new JLabel(
            NbBundle.getMessage(VerifierSupport.class,"DisplayLabel")); // NOI18N
    d.setVerticalAlignment(SwingConstants.BOTTOM);
    // 508 compliance for the JLabel
    d.getAccessibleContext().setAccessibleName(
            NbBundle.getMessage(VerifierSupport.class,"Label"));    // NOI18N
    d.getAccessibleContext().setAccessibleDescription(
            NbBundle.getMessage(VerifierSupport.class,"This_is_a_label"));  // NOI18N
    radioPanel.add(d);
    radioPanel.add(allButton);
    radioPanel.add(failButton);
    radioPanel.add(warnButton);
    
    // Add the controls to the Panel
    controlPanel.add(radioPanel);
    
    // Register a listener for the report level radio buttons.
    myListener = new RadioListener();
    allButton.addActionListener(myListener);
    failButton.addActionListener(myListener);
    warnButton.addActionListener(myListener);
}
 
Example 16
Source File: RSUPanel.java    From VanetSim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor. Creating GUI items.
 */
public RSUPanel(){
	setLayout(new GridBagLayout());
	
	// global layout settings
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	c.anchor = GridBagConstraints.PAGE_START;
	c.weightx = 0.5;
	c.gridx = 0;
	c.gridy = 0;
	c.gridheight = 1;
	c.gridwidth = 2;
	
	// Radio buttons to select mode
	ButtonGroup group = new ButtonGroup();
	addRSU_ = new JRadioButton(Messages.getString("RSUPanel.addRSU")); //$NON-NLS-1$
	addRSU_.setActionCommand("addRSU"); //$NON-NLS-1$;
	addRSU_.setSelected(true);
	group.add(addRSU_);
	++c.gridy;
	add(addRSU_,c);
	addRSU_.addActionListener(this);
	
	deleteRSU_ = new JRadioButton(Messages.getString("RSUPanel.deleteRSU")); //$NON-NLS-1$
	deleteRSU_.setActionCommand("deleteRSU"); //$NON-NLS-1$
	group.add(deleteRSU_);
	++c.gridy;
	add(deleteRSU_,c);
	deleteRSU_.addActionListener(this);
	
	c.gridwidth = 1;
	c.insets = new Insets(5,5,5,5);
	
	//textfields
	c.gridx = 0;
	rsuLabel_ = new JLabel(Messages.getString("RSUPanel.radius")); //$NON-NLS-1$
	++c.gridy;
	add(rsuLabel_,c);		
	rsuRadius_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
	rsuRadius_.setValue(500);

	rsuRadius_.setPreferredSize(new Dimension(60,20));
	c.gridx = 1;
	add(rsuRadius_,c);
	
	c.gridx = 0;
	c.gridwidth = 2;
	++c.gridy;
	add(ButtonCreator.getJButton("deleteAll.png", "clearRSUs", Messages.getString("RSUPanel.btnClearRSUs"), this),c);
	
	deleteNote_ = new TextAreaLabel(Messages.getString("RSUPanel.noteDelete")); //$NON-NLS-1$
	++c.gridy;
	c.gridx = 0;
	add(deleteNote_, c);
	deleteNote_.setVisible(false);
	
	addNote_ = new TextAreaLabel(Messages.getString("RSUPanel.noteAdd")); //$NON-NLS-1$
	++c.gridy;
	c.gridx = 0;
	add(addNote_, c);
	addNote_.setVisible(true);
	
	
	//to consume the rest of the space
	c.weighty = 1.0;
	++c.gridy;
	JPanel space = new JPanel();
	space.setOpaque(false);
	add(space, c);
}
 
Example 17
Source File: ImportDiffAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void importDiff(VCSContext ctx) {
    final File roots[] = HgUtils.getActionRoots(ctx);
    if (roots == null || roots.length == 0) return;
    final File root = Mercurial.getInstance().getRepositoryRoot(roots[0]);

    final JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(ImportDiffAction.class, "ACSD_ImportBrowseFolder"), null);   // NO I18N
    fileChooser.setDialogTitle(NbBundle.getMessage(ImportDiffAction.class, "ImportBrowse_title"));                                            // NO I18N
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    fileChooser.setApproveButtonMnemonic(NbBundle.getMessage(ImportDiffAction.class, "Import").charAt(0));                      // NO I18N
    fileChooser.setApproveButtonText(NbBundle.getMessage(ImportDiffAction.class, "Import"));                                        // NO I18N
    fileChooser.setCurrentDirectory(new File(HgModuleConfig.getDefault().getImportFolder()));
    JPanel panel = new JPanel();
    final JRadioButton asPatch = new JRadioButton(NbBundle.getMessage(ImportDiffAction.class, "CTL_Import_PatchOption")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(asPatch, asPatch.getText()); // NOI18N
    final JRadioButton asBundle = new JRadioButton(NbBundle.getMessage(ImportDiffAction.class, "CTL_Import_BundleOption")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(asBundle, asBundle.getText()); // NOI18N
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(asBundle);
    buttonGroup.add(asPatch);
    asPatch.setSelected(true);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(asPatch);
    panel.add(asBundle);
    fileChooser.setAccessory(panel);

    DialogDescriptor dd = new DialogDescriptor(fileChooser, NbBundle.getMessage(ImportDiffAction.class, "ImportBrowse_title"));              // NO I18N
    dd.setOptions(new Object[0]);
    final Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    fileChooser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String state = e.getActionCommand();
            if (state.equals(JFileChooser.APPROVE_SELECTION)) {
                final File patchFile = fileChooser.getSelectedFile();

                HgModuleConfig.getDefault().setImportFolder(patchFile.getParent());
                RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root);
                ImportDiffProgressSupport.Kind kind;
                if (asBundle.isSelected()) {
                    kind = ImportDiffProgressSupport.Kind.BUNDLE;
                } else if (asPatch.isSelected()) {
                    kind = ImportDiffProgressSupport.Kind.PATCH;
                } else {
                    kind = null;
                }
                HgProgressSupport support = new ImportDiffProgressSupport(root, patchFile, true, kind);
                support.start(rp, root, org.openide.util.NbBundle.getMessage(ImportDiffAction.class, "LBL_ImportDiff_Progress")); // NOI18N
            }
            dialog.dispose();
        }
    });
    dialog.setVisible(true);
}
 
Example 18
Source File: SelectionDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/** Constructs panel containing the main GUI components. */
private JPanel constructJComponent() {

	// Selection panel

	BoxLayout selectionPanelLayout = new BoxLayout(selectionPanel, BoxLayout.Y_AXIS);
	selectionPanel.setLayout(selectionPanelLayout);
	ButtonGroup radioButtons = new ButtonGroup();
	if (optionsToSelect != null) {
		for (int i = 0; i < optionsToSelect.size(); i++) {
			JRadioButton radioButton = new JRadioButton(getI18n(optionsToSelect.get(i)));
			radioButton.setHorizontalAlignment(JRadioButton.LEFT);
			if (i == 0) {
				radioButton.setSelected(true);
			}
			radioButtons.add(radioButton);
			selectionPanel.add(radioButton);
		}
	}

	// Checkbox panel

	BoxLayout checkboxPanelLayout = new BoxLayout(checkboxPanel, BoxLayout.Y_AXIS);
	checkboxPanel.setLayout(checkboxPanelLayout);
	if (optionsToCheck != null) {
		for (int i = 0; i < optionsToCheck.size(); i++) {
			JCheckBox jCheckBox = new JCheckBox(getI18n(optionsToCheck.get(i)));
			jCheckBox.setHorizontalAlignment(JCheckBox.LEFT);
			checkboxPanel.add(jCheckBox);
		}
	}

	// Overall panel

	JPanel panel = new JPanel();
	BoxLayout panelLayout = new BoxLayout(panel, BoxLayout.Y_AXIS);
	panel.setLayout(panelLayout);
	panel.add(selectionPanel);
	if (optionsToSelect != null && !optionsToSelect.isEmpty() && optionsToCheck != null && !optionsToCheck.isEmpty()) {
		panel.add(Box.createRigidArea(new Dimension(0, GAP_BETWEEN_SELECTIONS)));
	}
	panel.add(checkboxPanel);

	JPanel leftMarginPanel = new JPanel();
	BoxLayout leftMarginPanelLayout = new BoxLayout(leftMarginPanel, BoxLayout.X_AXIS);
	leftMarginPanel.setLayout(leftMarginPanelLayout);
	leftMarginPanel.add(Box.createRigidArea(new Dimension(getInfoIcon().getIconWidth() + BUTTON_DIALOG_LEFT_GAP, 0)));
	leftMarginPanel.add(panel);

	return leftMarginPanel;
}
 
Example 19
Source File: CommanderWindow.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void createMissionPanel() {
		WebPanel panel = new WebPanel(new BorderLayout());
		tabPane.add(MISSION_TAB, panel);
	     
		policyMainPanel = new WebPanel(new BorderLayout());
		panel.add(policyMainPanel, BorderLayout.NORTH);
		policyMainPanel.setPreferredSize(new Dimension(200, 125));
		policyMainPanel.setMaximumSize(new Dimension(200, 125));
		
		// Create a button panel
		WebPanel buttonPanel = new WebPanel(new GridLayout(4,1));
//		buttonPanel.setPreferredSize(new Dimension(250, 120));
		policyMainPanel.add(buttonPanel, BorderLayout.CENTER);
		
		buttonPanel.setBorder(BorderFactory.createTitledBorder("Trade With Other Settlements"));
		buttonPanel.setToolTipText("Select the trade policy with other settlements");
		
		ButtonGroup group0 = new ButtonGroup();
		ButtonGroup group1 = new ButtonGroup();
	
		r0 = new JRadioButton("Can initiate Trading Mission", true);
		r1 = new JRadioButton("Cannot initiate Trading Mission");

		// Set up initial conditions
		if (settlement.isMissionDisable(Trade.DEFAULT_DESCRIPTION)) {
			r0.setSelected(false);
			r1.setSelected(true);
		}
		else {
			r0.setSelected(true);
			r1.setSelected(false);
		}
			
		r2 = new JRadioButton("No Trading Missions from all settlements");
		r3 = new JRadioButton(ALLOW);

		// Set up initial conditions
		boolean noTrading = true;
		if (settlement.isTradeMissionAllowedFromASettlement(settlement)) {
			List<Settlement> list = getOtherSettlements();
//			List<Settlement> allowedSettlements = settlementMissionList.getCheckedValues();
			for (Settlement s: list) {
				if (!settlement.isTradeMissionAllowedFromASettlement(s)) {
					noTrading = false;
					break;
				}
			}
		}
		
		WebLabel selectLabel = new WebLabel(" Choose :");
		selectLabel.setMinimumSize(new Dimension(150, 25));
		selectLabel.setPreferredSize(150, 25);
		
		innerPanel = new WebPanel(new BorderLayout());
		innerPanel.add(selectLabel, BorderLayout.NORTH);
		
		// Set settlement check boxes
		settlementMissionList = new WebCheckBoxList<>(StyleId.checkboxlist, createModel(getOtherSettlements()));
		settlementMissionList.setVisibleRowCount(3);
		innerPanel.add(settlementMissionList, BorderLayout.CENTER);
		
		WebScrollPane = new WebScrollPane(innerPanel);
		WebScrollPane.setMaximumWidth(250);

		
//		mainPanel.add(WebScrollPane, BorderLayout.EAST);
		
		if (noTrading) {			
			r2.setSelected(true);
			r3.setSelected(false);
			policyMainPanel.remove(WebScrollPane);
			policyMainPanel.add(emptyPanel, BorderLayout.EAST);
//			settlementMissionList.setEnabled(false);
		}
		else {
			r2.setSelected(false);
			r3.setSelected(true);
			r3.setText(ALLOW + SEE_RIGHT);
			policyMainPanel.remove(emptyPanel);
			policyMainPanel.add(WebScrollPane, BorderLayout.EAST);
//			settlementMissionList.setEnabled(true);
		}
		
		group0.add(r0);
		group0.add(r1);
		group1.add(r2);
		group1.add(r3);
		
		buttonPanel.add(r0);
		buttonPanel.add(r1);
		buttonPanel.add(r2);
		buttonPanel.add(r3);
		
		PolicyRadioActionListener actionListener = new PolicyRadioActionListener();
		r0.addActionListener(actionListener);
		r1.addActionListener(actionListener);
		r2.addActionListener(actionListener);
		r3.addActionListener(actionListener);

	}
 
Example 20
Source File: KNNDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Create a radio button
 *
 * @param colourspacesPanel
 *            the panel to add the button too
 * @param group
 *            the radio button group
 * @param cs
 *            the colourSpace that the button represents
 */
private void createRadioButton(final JPanel colourspacesPanel, final ButtonGroup group, final ColourSpace cs) {
	final String name = cs.name();
	final JRadioButton button = new JRadioButton(name);
	button.setActionCommand("ColourSpace." + name);
	colourspacesPanel.add(button);
	group.add(button);
	button.setSelected(cs == ColourSpace.HS);
	button.addActionListener(this);
}