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

The following examples show how to use javax.swing.JRadioButton#setActionCommand() . 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: 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 2
Source File: ToolsInternalFrame.java    From chipster with MIT License 5 votes vote down vote up
/**
 * Creates panel for decimal separator selecting.
 * This panel is used on the first step.
 * 
 * @return panel for decimal separator selecting
 */
private JPanel createDecimalSeparatorPanel() {
	JXTaskPane decimalSeparatorPanel = createTaskPane();
	decimalSeparatorPanel.setLayout(new GridBagLayout());

	ButtonGroup separatorGroup = new ButtonGroup();

	dotAsDecimalSeparatorRadioButton = new JRadioButton("Dot .");
	dotAsDecimalSeparatorRadioButton.setActionCommand(".");
	dotAsDecimalSeparatorRadioButton.addActionListener(this);
	dotAsDecimalSeparatorRadioButton.setOpaque(false);
	separatorGroup.add(dotAsDecimalSeparatorRadioButton);

	commaAsDecimalSeparatorRadioButton = new JRadioButton("Comma ,");
	commaAsDecimalSeparatorRadioButton.setActionCommand(",");
	commaAsDecimalSeparatorRadioButton.addActionListener(this);
	commaAsDecimalSeparatorRadioButton.setOpaque(false);
	separatorGroup.add(commaAsDecimalSeparatorRadioButton);

	dotAsDecimalSeparatorRadioButton.setSelected(true);
	screen.getConversionModel().setDecimalSeparator('.');

	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0; c.gridy = 0;
	c.anchor = GridBagConstraints.WEST;
	c.weightx = 1.0;
	c.fill = GridBagConstraints.HORIZONTAL;

	decimalSeparatorPanel.add(dotAsDecimalSeparatorRadioButton, c);
	c.gridy++;
	decimalSeparatorPanel.add(commaAsDecimalSeparatorRadioButton, c);

	decimalSeparatorPanel.setTitle("Decimal Separator");

	return decimalSeparatorPanel;
}
 
Example 3
Source File: UserConfigs.java    From Pixie with MIT License 5 votes vote down vote up
/**
 * Add a list of radio buttons, representing default, generally used, values
 * for the DPI.
 */
private void addDPIDefaultVals() {
    // set the layout of the panel, based on the amount of elements to be displayed on it
    jPDefaultValues.setLayout(new GridLayout(DPI_VALUES.length, 1));

    for (int index = 0; index < DPI_VALUES.length; index++) {
        String text = DPI_VALUES[index] + " DPI";

        // create a radio button with the given text
        JRadioButton jrbDPIValues = new JRadioButton(text);

        // set its action command to a number for easier usage later (to retrieve the value of the DPI)
        jrbDPIValues.setActionCommand(Integer.toString(DPI_VALUES[index]));

        // add action listener to synchronize the text field with the radio buttons
        jrbDPIValues.addActionListener(e -> jFTFDPIValue.setValue(Integer.parseInt(bgScreenDPIs.getSelection().getActionCommand())));

        // add mouse listener to display the help message when the mouse is on top of the radio buttons
        jrbDPIValues.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jPDefaultValuesMouseEntered(evt);
            }
        });

        jrbDPIValues.setBackground(Color.white);

        // add the radio button to the button group
        bgScreenDPIs.add(jrbDPIValues);

        // add the radio button to the panel displaying it
        jPDefaultValues.add(jrbDPIValues);

        // select the radio button which has the same value as the user preffered one (if any)
        if (DPI_VALUES[index] == userPreferences.getPreferredDPI()) {
            jrbDPIValues.setSelected(true);
            jFTFDPIValue.setValue(DPI_VALUES[index]);
        }
    }
}
 
Example 4
Source File: VideoIO.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Adds a video engine type to the available choices.
  * 
  * @param type the video engine type
  */  
public void addVideoEngine(VideoType type) {
	JRadioButton button = new JRadioButton(type.getDescription());
	button.setActionCommand(type.getClass().getSimpleName());
	videoEngineButtonGroup.add(button);
	buttonMap.put(button, type);
	add(button);  		
}
 
Example 5
Source File: ExpressionSubPanel.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/** Sets the up env var panel. */
protected void setUpEnvVarPanel() {
    if (VendorOptionManager.getInstance()
            .isAllowed(
                    this.parentObj.getVendorOptionList(),
                    EnvironmentVariableField.getVendorOption())) {
        JPanel panelEnvVar = new JPanel();
        panelEnvVar.setBorder(null);
        panelEnvVar.setLayout(new BoxLayout(panelEnvVar, BoxLayout.X_AXIS));

        rdbtnEnvVar = new JRadioButton(ENVVAR);
        rdbtnEnvVar.setMinimumSize(new Dimension(100, 20));
        rdbtnEnvVar.setPreferredSize(new Dimension(100, 20));
        panelEnvVar.add(rdbtnEnvVar);
        rdbtnEnvVar.setActionCommand(ENVVAR);
        buttonGroup.add(rdbtnEnvVar);

        envVarField =
                new EnvironmentVariableField(
                        new SubPanelUpdatedInterface() {
                            @Override
                            public void updateSymbol() {
                                buttonGroup.setSelected(rdbtnEnvVar.getModel(), true);
                                updateButtonState(true);
                            }

                            @Override
                            public void parameterAdded() {
                                // Do nothing
                            }
                        },
                        EnvironmentVariableManager.getInstance());

        panelEnvVar.add(envVarField);
        box.add(panelEnvVar);
    }
}
 
Example 6
Source File: ExpressionSubPanel.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/** Sets the up function panel. */
protected void setUpFunctionPanel() {
    JPanel panelFunction = new JPanel();
    panelFunction.setBorder(null);
    panelFunction.setLayout(new BoxLayout(panelFunction, BoxLayout.X_AXIS));

    rdbtnFunction =
            new JRadioButton(
                    Localisation.getString(
                            ExpressionPanelv2.class, "ExpressionPanelv2.function"));
    rdbtnFunction.setMinimumSize(new Dimension(100, 20));
    rdbtnFunction.setPreferredSize(new Dimension(100, 20));
    panelFunction.add(rdbtnFunction);
    rdbtnFunction.setActionCommand(FUNCTION);
    buttonGroup.add(rdbtnFunction);

    functionPanel =
            new FunctionField(
                    new SubPanelUpdatedInterface() {
                        @Override
                        public void updateSymbol() {
                            buttonGroup.setSelected(rdbtnFunction.getModel(), true);
                            updateButtonState(true);
                        }

                        @Override
                        public void parameterAdded() {
                            if (parentObj != null) {
                                parentObj.dataApplied();
                            }
                        }
                    },
                    FunctionManager.getInstance());

    panelFunction.add(functionPanel);
    box.add(panelFunction);
}
 
Example 7
Source File: ExpressionSubPanel.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/** Sets the up maths panel. */
protected void setUpMathsPanel() {
    JPanel panelMaths = new JPanel();
    panelMaths.setBorder(null);
    panelMaths.setLayout(new BoxLayout(panelMaths, BoxLayout.X_AXIS));
    rdbtnMaths =
            new JRadioButton(
                    Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.maths"));
    panelMaths.add(rdbtnMaths);
    rdbtnMaths.setMinimumSize(new Dimension(100, 20));
    rdbtnMaths.setPreferredSize(new Dimension(100, 20));
    rdbtnMaths.setActionCommand(MATHS);
    buttonGroup.add(rdbtnMaths);

    mathsExpressionPanel =
            new MathsExpressionPanel(
                    new SubPanelUpdatedInterface() {
                        @Override
                        public void updateSymbol() {
                            buttonGroup.setSelected(rdbtnMaths.getModel(), true);
                            updateButtonState(true);
                        }

                        @Override
                        public void parameterAdded() {
                            // Do nothing
                        }
                    });

    panelMaths.add(mathsExpressionPanel);
    box.add(panelMaths);
}
 
Example 8
Source File: ChartTableToggle.java    From nmonvisualizer with Apache License 2.0 5 votes vote down vote up
public ChartTableToggle(NMONVisualizerGui gui) {
    // border layout pads differently than the default flow layout
    // use it so the text for the radio buttons lines up with other text in the parent
    super(new BorderLayout());

    this.gui = gui;

    charts = new JRadioButton("Charts");
    table = new JRadioButton("Table");

    charts.setFont(Styles.LABEL);
    table.setFont(Styles.LABEL);

    charts.setBorder(Styles.CONTENT_BORDER);
    table.setBorder(Styles.CONTENT_BORDER);

    charts.setActionCommand("Charts");
    table.setActionCommand("Table");

    ActionListener toggle = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ChartTableToggle.this.gui.setProperty("chartsDisplayed", !e.getActionCommand().equals("Table"));
        }
    };

    charts.addActionListener(toggle);
    table.addActionListener(toggle);

    ButtonGroup group = new ButtonGroup();
    group.add(charts);
    group.add(table);

    charts.setSelected(true);
    table.setSelected(false);

    add(charts, BorderLayout.LINE_START);
    add(table, BorderLayout.LINE_END);

    gui.addPropertyChangeListener("chartsDisplayed", this);
}
 
Example 9
Source File: NewProductDialog.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
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 10
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 11
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 12
Source File: ExportImageAction.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
protected void configureFileChooser(final SnapFileChooser fileChooser, final ProductSceneView view,
                                    String imageBaseName) {
    fileChooser.setDialogTitle(SnapApp.getDefault().getInstanceName() + " - " + "Export Image"); /*I18N*/
    if (view.isRGB()) {
        fileChooser.setCurrentFilename(imageBaseName + "_RGB");
    } else {
        fileChooser.setCurrentFilename(imageBaseName + "_" + view.getRaster().getName());
    }

    final JPanel regionPanel = new JPanel(new GridLayout(2, 1));
    regionPanel.setBorder(BorderFactory.createTitledBorder("Image Region"));
    buttonFullRegion = new JRadioButton("Full scene");
    buttonFullRegion.setToolTipText("Use the image boundaries of the source data");
    buttonFullRegion.setActionCommand(AC_FULL_REGION);
    buttonVisibleRegion = new JRadioButton("View region");
    buttonVisibleRegion.setToolTipText("Use the image boundaries of the view window");
    buttonVisibleRegion.setActionCommand(AC_VIEW_REGION);
    regionPanel.add(buttonVisibleRegion);
    regionPanel.add(buttonFullRegion);

    buttonGroupRegion = new ButtonGroup();
    buttonGroupRegion.add(buttonVisibleRegion);
    buttonGroupRegion.add(buttonFullRegion);

    final JPanel resolutionPanel = new JPanel(new GridLayout(3, 1));
    resolutionPanel.setBorder(BorderFactory.createTitledBorder("Image Resolution"));
    buttonViewResolution = new JRadioButton("View resolution");
    buttonViewResolution.setToolTipText("Use the resolution of the view window as it is on the computer screen");
    buttonViewResolution.setActionCommand(AC_VIEW_RES);
    buttonFullResolution = new JRadioButton("Full resolution");
    buttonFullResolution.setToolTipText("Use the resolution of the source data");
    buttonFullResolution.setActionCommand(AC_FULL_RES);
    buttonUserResolution = new JRadioButton("User resolution");
    buttonUserResolution.setToolTipText("Use a custom resolution set by the user");
    buttonUserResolution.setActionCommand(AC_USER_RES);
    resolutionPanel.add(buttonViewResolution);
    resolutionPanel.add(buttonFullResolution);
    resolutionPanel.add(buttonUserResolution);

    buttonGroupResolution = new ButtonGroup();
    buttonGroupResolution.add(buttonViewResolution);
    buttonGroupResolution.add(buttonFullResolution);
    buttonGroupResolution.add(buttonUserResolution);

    sizeComponent = new SizeComponent(view);
    JComponent sizePanel = sizeComponent.createComponent();
    sizePanel.setBorder(BorderFactory.createTitledBorder("Image Dimension")); /*I18N*/
    sizePanel.setToolTipText("Fixed ratio is automatically applied to width and height");

    final JPanel accessory = new JPanel();
    accessory.setLayout(new BoxLayout(accessory, BoxLayout.Y_AXIS));
    accessory.add(regionPanel);
    accessory.add(resolutionPanel);
    accessory.add(sizePanel);

    fileChooser.setAccessory(accessory);
    buttonVisibleRegion.addActionListener(e -> updateComponents(e.getActionCommand()));
    buttonFullRegion.addActionListener(e -> updateComponents(e.getActionCommand()));
    buttonViewResolution.addActionListener(e -> updateComponents(e.getActionCommand()));
    buttonFullResolution.addActionListener(e -> updateComponents(e.getActionCommand()));
    buttonUserResolution.addActionListener(e -> updateComponents(e.getActionCommand()));
    updateComponents(PSEUDO_AC_INIT);

}
 
Example 13
Source File: KwikiDateModesSelectorPanel.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
private void SetupUncertaintyModeButtonGroup () {
    uncertaintyModeGroup = new ButtonGroup();

    ActionListener uncertaintyModeActionListener = new ActionListener() {

        public void actionPerformed ( ActionEvent e ) {
            propertySupport.firePropertyChange(//
                    UNCERTAINTY_MODE_PROPERTY,
                    "",
                    ((JRadioButton) e.getSource()).getActionCommand() );
        }
    };


    JRadioButton analyticalRB = new JRadioButton( "Analytical", true );
    analyticalRB.setActionCommand( "Analytical" );
    uncertaintyModeGroup.add( analyticalRB );
    analyticalRB.setOpaque( false );
    analyticalRB.setForeground( new java.awt.Color( 204, 0, 0 ) );
    analyticalRB.setFont( new Font( "SansSerif", Font.BOLD, 9 ) );
    analyticalRB.setBounds( 1, 2, 130, 16 );
    analyticalRB.addActionListener( uncertaintyModeActionListener );
    add( analyticalRB, javax.swing.JLayeredPane.DEFAULT_LAYER );

    JRadioButton tracerRB = new JRadioButton( "+ Tracer", false );
    tracerRB.setActionCommand( "Tracer" );
    uncertaintyModeGroup.add( tracerRB );
    tracerRB.setOpaque( false );
    tracerRB.setForeground( new java.awt.Color( 204, 0, 0 ) );
    tracerRB.setFont( new Font( "SansSerif", Font.BOLD, 9 ) );
    tracerRB.setBounds( 1, 21, 130, 16 );
    tracerRB.addActionListener( uncertaintyModeActionListener );
    add( tracerRB, javax.swing.JLayeredPane.DEFAULT_LAYER );

    JRadioButton lambdaRB = new JRadioButton( "+ decay constants", false );
    lambdaRB.setActionCommand( "Lambda" );
    uncertaintyModeGroup.add( lambdaRB );
    lambdaRB.setOpaque( false );
    lambdaRB.setForeground( new java.awt.Color( 204, 0, 0 ) );
    lambdaRB.setFont( new Font( "SansSerif", Font.BOLD, 9 ) );
    lambdaRB.setBounds( 1, 40, 130, 16 );
    lambdaRB.addActionListener( uncertaintyModeActionListener );
    add( lambdaRB, javax.swing.JLayeredPane.DEFAULT_LAYER );

}
 
Example 14
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 15
Source File: EditStreetControlPanel.java    From VanetSim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 */
public EditStreetControlPanel(){
	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 what to do
	ButtonGroup group = new ButtonGroup();
	JRadioButton addItem = new JRadioButton(Messages.getString("EditStreetControlPanel.add")); //$NON-NLS-1$
	addItem.setActionCommand("add"); //$NON-NLS-1$
	addItem.addActionListener(this);
	addItem.setSelected(true);
	group.add(addItem);
	++c.gridy;
	add(addItem,c);
	
	JRadioButton editItem = new JRadioButton(Messages.getString("EditStreetControlPanel.edit")); //$NON-NLS-1$
	editItem.setActionCommand("edit"); //$NON-NLS-1$
	editItem.addActionListener(this);
	group.add(editItem);
	++c.gridy;
	add(editItem,c);
	
	JRadioButton deleteItem = new JRadioButton(Messages.getString("EditStreetControlPanel.delete")); //$NON-NLS-1$
	deleteItem.setActionCommand("delete"); //$NON-NLS-1$
	deleteItem.setSelected(true);
	deleteItem.addActionListener(this);
	group.add(deleteItem);
	++c.gridy;
	add(deleteItem,c);
	
	c.gridwidth = 1;
	c.insets = new Insets(5,5,5,5);

	// all controls for creating a new street
	JPanel newPanel = createNewPanel();
	JPanel editPanel = createEditPanel();
	JPanel deletePanel = createDeletePanel();
	
	cardPanel_ = new JPanel(new CardLayout());
	cardPanel_.add(newPanel, "add"); //$NON-NLS-1$
	cardPanel_.add(editPanel, "edit"); //$NON-NLS-1$
	cardPanel_.add(deletePanel, "delete"); //$NON-NLS-1$
	++c.gridy;
	add(cardPanel_,c);
	
	TextAreaLabel jlabel1 = new TextAreaLabel(Messages.getString("EditStreetControlPanel.note")); //$NON-NLS-1$
	++c.gridy;
	add(jlabel1, c);
	
	//to consume the rest of the space
	c.gridwidth = 2;
	c.weighty = 1.0;
	++c.gridy;
	JPanel space = new JPanel();
	space.setOpaque(false);
	add(space, c);
}
 
Example 16
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 17
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 18
Source File: LinearClassifierDemo.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);
}
 
Example 19
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);
}
 
Example 20
Source File: ColourSpacesDemo.java    From COMP3204 with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Create a radio button
 *
 * @param controlsPanel
 *            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 controlsPanel, final ButtonGroup group, final ColourSpace cs) {
	final String name = cs.name();
	final JRadioButton button = new JRadioButton(name);
	button.setActionCommand(name);
	controlsPanel.add(button);
	group.add(button);
	button.setSelected(cs == ColourSpace.RGB);
	button.addActionListener(this);
}