Java Code Examples for javax.swing.JRadioButton#setOpaque()
The following examples show how to use
javax.swing.JRadioButton#setOpaque() .
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: DataPresentationModeChooserPanel.java From ET_Redux with Apache License 2.0 | 6 votes |
private JRadioButton buttonForFitFunctionFactory(// int pixelsFromTop, // final DataPresentationModeEnum myDataPresentationMode) { JRadioButton dataViewModeButton = new JRadioButton(myDataPresentationMode.getName()); dataViewModeButton.setName(myDataPresentationMode.getName()); dataViewModeButton.setFont(new Font("SansSerif", Font.PLAIN, 10)); dataViewModeButton.setBounds(5, pixelsFromTop, 90, 20); dataViewModeButton.setSelected(myDataPresentationMode.equals(dataPresentationMode)); dataViewModeButton.setBackground(this.getBackground()); dataViewModeButton.setOpaque(true); dataViewModeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ((AbstractRawDataView) sampleSessionDataView).setDataPresentationMode(myDataPresentationMode); ((AbstractRawDataView) sampleSessionDataView).refreshPanel(true, false); } }); dataViewModeButtonGroup.add(dataViewModeButton); return dataViewModeButton; }
Example 2
Source File: SettingsPage.java From xdm with GNU General Public License v2.0 | 5 votes |
private JRadioButton createRadioButton(String name, Font font) { JRadioButton chk = new JRadioButton(StringResource.get(name)); chk.setIcon(ImageResource.getIcon("unchecked.png", 16, 16)); chk.setSelectedIcon(ImageResource.getIcon("checked.png", 16, 16)); chk.setOpaque(false); chk.setFocusPainted(false); chk.setForeground(Color.WHITE); chk.setFont(font); return chk; }
Example 3
Source File: BatchPatternDialog.java From xdm with GNU General Public License v2.0 | 5 votes |
private JRadioButton createRadioButton(String name, Font font) { JRadioButton chk = new JRadioButton(StringResource.get(name)); chk.setIcon(ImageResource.getIcon("unchecked.png", 16, 16)); chk.setSelectedIcon(ImageResource.getIcon("checked.png", 16, 16)); chk.setOpaque(false); chk.setFocusPainted(false); chk.setForeground(Color.WHITE); chk.setFont(font); return chk; }
Example 4
Source File: Query.java From OpenDA with GNU Lesser General Public License v3.0 | 5 votes |
/** Create an on-off check box. * @param name The name used to identify the entry (when calling get). * @param label The label to attach to the entry. * @param defaultValue The default value (true for on). */ public void addCheckBox(String name, String label, boolean defaultValue) { JLabel lbl = new JLabel(label + ": "); lbl.setBackground(_background); JRadioButton checkbox = new JRadioButton(); checkbox.setBackground(_background); checkbox.setOpaque(false); checkbox.setSelected(defaultValue); _addPair(name, lbl, checkbox, checkbox); // Add the listener last so that there is no notification // of the first value. checkbox.addItemListener(new QueryItemListener(name)); }
Example 5
Source File: Query.java From OpenDA with GNU Lesser General Public License v3.0 | 5 votes |
/** Create a bank of radio buttons. A radio button provides a list of * choices, only one of which may be chosen at a time. * @param name The name used to identify the entry (when calling get). * @param label The label to attach to the entry. * @param values The list of possible choices. * @param defaultValue Default value. */ public void addRadioButtons( String name, String label, String[] values, String defaultValue) { JLabel lbl = new JLabel(label + ": "); lbl.setBackground(_background); FlowLayout flow = new FlowLayout(); flow.setAlignment(FlowLayout.LEFT); // This must be a JPanel, not a Panel, or the scroll bars won't work. JPanel buttonPanel = new JPanel(flow); ButtonGroup group = new ButtonGroup(); QueryActionListener listener = new QueryActionListener(name); // Regrettably, ButtonGroup provides no method to find out // which button is selected, so we have to go through a // song and dance here... JRadioButton[] buttons = new JRadioButton[values.length]; for (int i = 0; i < values.length; i++) { JRadioButton checkbox = new JRadioButton(values[i]); buttons[i] = checkbox; checkbox.setBackground(_background); // The following (essentially) undocumented method does nothing... // checkbox.setContentAreaFilled(true); checkbox.setOpaque(false); if (values[i].equals(defaultValue)) { checkbox.setSelected(true); } group.add(checkbox); buttonPanel.add(checkbox); // Add the listener last so that there is no notification // of the first value. checkbox.addActionListener(listener); } _addPair(name, lbl, buttonPanel, buttons); }
Example 6
Source File: bug8041561.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void createAndShowGUI() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBackground(Color.BLUE); radioButton = new JRadioButton(); radioButton.setOpaque(false); JPanel panel = new JPanel(); panel.setBackground(Color.BLUE); panel.add(radioButton); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); }
Example 7
Source File: StartupConfigurator.java From visualvm with GNU General Public License v2.0 | 5 votes |
public IconRadioButton(String text, Icon icon, boolean selected) { renderer = new JRadioButton(text, icon) { public boolean hasFocus() { return IconRadioButton.this.hasFocus(); } }; renderer.setOpaque(false); renderer.setBorderPainted(false); setSelected(selected); setBorderPainted(false); setOpaque(false); }
Example 8
Source File: ControlsDialog.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
private void addMouseControlPanel(KeyBindings keyBindings) { JPanel mouseControlPanel = JPanelFactory.createJPanel("Mouse"); mouseControlPanel.setOpaque(false); mouseControlPanel.setBounds(15, 430, 368, 150); mouseControlPanel.setLayout(null); JRadioButton defaultMouseControl = JRadioButtonFactory.createJRadioButton("<html>left-click: center map<br>right-click: show possible actions</html>"); defaultMouseControl.setSelected(keyBindings.leftMouseClickCentersMap()); defaultMouseControl.setOpaque(false); defaultMouseControl.setBounds(12, 25, 360, 50); mouseControlPanel.add(defaultMouseControl); JRadioButton alternateMouseControl = JRadioButtonFactory.createJRadioButton("<html>right-click: center map<br>left-click: show possible actions</html>"); alternateMouseControl.setSelected(!keyBindings.leftMouseClickCentersMap()); alternateMouseControl.setOpaque(false); alternateMouseControl.setBounds(12, 85, 360, 50); mouseControlPanel.add(alternateMouseControl); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(defaultMouseControl); buttonGroup.add(alternateMouseControl); addComponent(mouseControlPanel); defaultMouseControl.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { keyBindings.setLeftMouseClickCentersMap(defaultMouseControl.isSelected()); } }); }
Example 9
Source File: ToolsInternalFrame.java From chipster with MIT License | 5 votes |
/** * 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 10
Source File: Query.java From opt4j with MIT License | 4 votes |
/** * Create a bank of radio buttons. A radio button provides a list of * choices, only one of which may be chosen at a time. * * @param name * The name used to identify the entry (when calling get). * @param label * The label to attach to the entry. * @param values * The list of possible choices. * @param defaultValue * Default value. */ public void addRadioButtons(String name, String label, String[] values, String defaultValue) { JLabel lbl = new JLabel(label + ": "); lbl.setBackground(_background); FlowLayout flow = new FlowLayout(); flow.setAlignment(FlowLayout.LEFT); // This must be a JPanel, not a Panel, or the scroll bars won't work. JPanel buttonPanel = new JPanel(flow); ButtonGroup group = new ButtonGroup(); QueryActionListener listener = new QueryActionListener(name); // Regrettably, ButtonGroup provides no method to find out // which button is selected, so we have to go through a // song and dance here... JRadioButton[] buttons = new JRadioButton[values.length]; for (int i = 0; i < values.length; i++) { JRadioButton checkbox = new JRadioButton(values[i]); buttons[i] = checkbox; checkbox.setBackground(_background); // The following (essentially) undocumented method does nothing... // checkbox.setContentAreaFilled(true); checkbox.setOpaque(false); if (values[i].equals(defaultValue)) { checkbox.setSelected(true); } group.add(checkbox); buttonPanel.add(checkbox); // Add the listener last so that there is no notification // of the first value. checkbox.addActionListener(listener); } _addPair(name, lbl, buttonPanel, buttons); }
Example 11
Source File: Query.java From opt4j with MIT License | 4 votes |
/** * Create a bank of buttons that provides a list of choices, any subset of * which may be chosen at a time. * * @param name * The name used to identify the entry (when calling get). * @param label * The label to attach to the entry. * @param values * The list of possible choices. * @param initiallySelected * The initially selected choices, or null to indicate that none * are selected. */ public void addSelectButtons(String name, String label, String[] values, Set<String> initiallySelected) { JLabel lbl = new JLabel(label + ": "); lbl.setBackground(_background); FlowLayout flow = new FlowLayout(); flow.setAlignment(FlowLayout.LEFT); // This must be a JPanel, not a Panel, or the scroll bars won't work. JPanel buttonPanel = new JPanel(flow); QueryActionListener listener = new QueryActionListener(name); if (initiallySelected == null) { initiallySelected = new HashSet<String>(); } JRadioButton[] buttons = new JRadioButton[values.length]; for (int i = 0; i < values.length; i++) { JRadioButton checkbox = new JRadioButton(values[i]); buttons[i] = checkbox; checkbox.setBackground(_background); // The following (essentially) undocumented method does nothing... // checkbox.setContentAreaFilled(true); checkbox.setOpaque(false); if (initiallySelected.contains(values[i])) { checkbox.setSelected(true); } buttonPanel.add(checkbox); // Add the listener last so that there is no notification // of the first value. checkbox.addActionListener(listener); } _addPair(name, lbl, buttonPanel, buttons); }
Example 12
Source File: KwikiDateModesSelectorPanel.java From ET_Redux with Apache License 2.0 | 4 votes |
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 13
Source File: KwikiPDFToolBar.java From ET_Redux with Apache License 2.0 | 4 votes |
private void SetupDateChooserButtons() { dateChooserButtonGroup = new ButtonGroup(); date206_238_radioButton = new JRadioButton("206/238"); dateChooserButtonGroup.add(date206_238_radioButton); date206_238_radioButton.setFont(new java.awt.Font("Arial", 1, 10)); date206_238_radioButton.setText("206/238"); date206_238_radioButton.setName("age206_238r"); date206_238_radioButton.setBounds(40, 1, 70, 17); date206_238_radioButton.setSelected(true); date206_238_radioButton.setOpaque(true); date206_238_radioButton.setBackground(Color.white); add(date206_238_radioButton); date207_206_radioButton = new JRadioButton("207/206"); dateChooserButtonGroup.add(date207_206_radioButton); date207_206_radioButton.setFont(new java.awt.Font("Arial", 1, 10)); date207_206_radioButton.setText("207/206"); date207_206_radioButton.setName("age207_206r"); date207_206_radioButton.setBounds(40, 19, 70, 17); date207_206_radioButton.setOpaque(true); date207_206_radioButton.setBackground(Color.white); add(date207_206_radioButton); dateBest_radioButton = new JRadioButton("best"); dateChooserButtonGroup.add(dateBest_radioButton); dateBest_radioButton.setFont(new java.awt.Font("Arial", 1, 10)); dateBest_radioButton.setText("best"); dateBest_radioButton.setName("bestAge"); dateBest_radioButton.setOpaque(true); dateBest_radioButton.setBackground(Color.white); dateBest_radioButton.setBounds(40, 37, 70, 17); add(dateBest_radioButton); // choose date for (Enumeration e = dateChooserButtonGroup.getElements(); e.hasMoreElements();) { final JRadioButton jrb = (JRadioButton) e.nextElement(); jrb.addActionListener((ActionEvent arg0) -> { // oct 2014 handle new Pbc corrections String chosenDateName = jrb.getName(); ((DateProbabilityDensityPanel) probabilityPanel).setChosenDateName(chosenDateName); ((DateProbabilityDensityPanel) probabilityPanel).// setSelectedFractions(sample.getUpbFractionsUnknown()); ((DateProbabilityDensityPanel) probabilityPanel).prepareAndPaintPanel(); }); } }
Example 14
Source File: AbstractFitFunctionPresentationView.java From ET_Redux with Apache License 2.0 | 4 votes |
private JRadioButton radioButtonForFitFunctionFactory(// final DataModelFitFunctionInterface rawRatioDataModel, final FitFunctionTypeEnum fitFunctionType) { // feb 2013 String overDispersion = ""; DecimalFormat f = new DecimalFormat("0.000"); if (fitFunctionType.compareTo(FitFunctionTypeEnum.MEAN_DH) == 0) { if (((RawRatioDataModel)rawRatioDataModel).isOverDispersionSelectedDownHole()&& rawRatioDataModel.doesFitFunctionTypeHaveOD(fitFunctionType)) { overDispersion = "-OD \u03BE = " + f.format(rawRatioDataModel.getXIforFitFunction(fitFunctionType)); } } else { if (rawRatioDataModel.isOverDispersionSelected() && rawRatioDataModel.doesFitFunctionTypeHaveOD(fitFunctionType)) { if (fitFunctionType.compareTo(FitFunctionTypeEnum.SMOOTHING_SPLINE) == 0) { overDispersion = "-OD"; } else { overDispersion = "-OD \u03BE = " + f.format(rawRatioDataModel.getXIforFitFunction(fitFunctionType)); } } } JRadioButton functionChoiceRadioButton = new JRadioButton(fitFunctionType.getPrettyName() + overDispersion); functionChoiceRadioButton.setName(fitFunctionType.getName()); functionChoiceRadioButton.setFont(ReduxConstants.sansSerif_10_Plain);// new Font("SansSerif", Font.PLAIN, 10)); functionChoiceRadioButton.setBounds(1, 1, 160, 17); functionChoiceRadioButton.setOpaque(false); if (fitFunctionType.compareTo(FitFunctionTypeEnum.MEAN_DH) == 0) { // only one available for downhole functionChoiceRadioButton.setSelected(true); } else { functionChoiceRadioButton.setSelected( // rawRatioDataModel.getSelectedFitFunctionType().compareTo(fitFunctionType) == 0); } functionChoiceRadioButton.addActionListener((ActionEvent e) -> { // on click, take control // check if fit function exists (could be calculated) if (rawRatioDataModel.containsFitFunction(fitFunctionType)) { rawRatioDataModel.setSelectedFitFunctionType(fitFunctionType); if (targetDataModelView instanceof DataViewsOverlay) { ((DataViewsOverlay) targetDataModelView).getDownholeFractionationDataModel()// .calculateWeightedMeanForEachStandard(rawRatioDataModel.getRawRatioModelName(), rawRatioDataModel.getSelectedFitFunction()); } layoutFitFunctionViews(atleastOneFit, ((AbstractRawDataView) ((Component) e.getSource()).getParent().getParent())); updatePlotsWithChanges(targetDataModelView); updateReportTable(); } // do nothing updatePlotsWithChanges(targetDataModelView); }); fitFunctionButtonGroup.add(functionChoiceRadioButton); return functionChoiceRadioButton; }
Example 15
Source File: ToolsInternalFrame.java From chipster with MIT License | 4 votes |
/** * Creates panel for delimeter selection. * This panel is used on the first step * * @return JPanel delimeter selection panel */ private JPanel createDelimSelectorPanel() { JXTaskPane delimPanel = createTaskPane(); delimPanel.setLayout(new GridBagLayout()); delimRadioButtons = new ArrayList<JRadioButton>(); Map<String, JRadioButton>delimRadioButtonsByDelims = new HashMap<String, JRadioButton>(); ButtonGroup delimGroup = new ButtonGroup(); String[] selectorLabels = new String[Delimiter.values().length]; String[] delimiters = new String[Delimiter.values().length]; for(int i = 0; i < Delimiter.values().length; i++){ selectorLabels[i] = Delimiter.values()[i].getName(); delimiters[i] = Delimiter.values()[i].toString(); } for (int i = 0; i < selectorLabels.length; i++) { JRadioButton selector = new JRadioButton(selectorLabels[i]); selector.setActionCommand(delimiters[i]); selector.addActionListener(this); selector.setOpaque(false); delimGroup.add(selector); delimRadioButtons.add(selector); delimRadioButtonsByDelims.put(delimiters[i], selector); } customDelimRadioButton = new JRadioButton("Other:"); customDelimRadioButton.addActionListener(this); customDelimRadioButton.setOpaque(false); delimGroup.add(customDelimRadioButton); delimRadioButtons.add(customDelimRadioButton); delimRadioButtons.get(0).setSelected(true); customDelimField = new JTextField(3); customDelimField.addCaretListener(this); //customDelimField.setPreferredSize(new Dimension(25, 20)); customDelimField.setMargin(new Insets(2, 2, 2, 2)); useCustomDelimButton = new JButton("Use"); useCustomDelimButton.addActionListener(this); useCustomDelimButton.setEnabled(false); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; for (int i = 0; i < delimRadioButtons.size()-1; i++) { delimPanel.add(delimRadioButtons.get(i), c); c.gridy++; } c.gridx = 0; c.gridwidth = 1; c.weightx = 0.0; c.fill = GridBagConstraints.NONE; delimPanel.add(customDelimRadioButton, c); c.gridx = 1; delimPanel.add(customDelimField, c); c.gridx++; delimPanel.add(useCustomDelimButton, c); delimPanel.setTitle("Column Delimiter"); return delimPanel; }