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

The following examples show how to use javax.swing.JCheckBox#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: GUIUtils.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * Add a new checkbox to given component
 *
 * @param container Component to add the checkbox to
 * @param text Checkbox' text
 * @param icon Checkbox' icon or null
 * @param listener Checkbox' listener or null
 * @param actionCommand Checkbox' action command or null
 * @param mnemonic Checkbox' mnemonic (virtual key code) or 0
 * @param toolTip Checkbox' tool tip or null
 * @param state Checkbox' state
 * @return Created checkbox
 */
public static JCheckBox addCheckbox(Container component, String text, Icon icon,
    ActionListener listener, String actionCommand, int mnemonic, String toolTip, boolean state) {
  JCheckBox checkbox = new JCheckBox(text, icon, state);
  if (listener != null)
    checkbox.addActionListener(listener);
  if (actionCommand != null)
    checkbox.setActionCommand(actionCommand);
  if (mnemonic > 0)
    checkbox.setMnemonic(mnemonic);
  if (toolTip != null)
    checkbox.setToolTipText(toolTip);
  if (component != null)
    component.add(checkbox);
  return checkbox;
}
 
Example 2
Source File: GUIUtils.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 
 * Add a new checkbox to given component
 * 
 * @param container Component to add the checkbox to
 * @param text Checkbox' text
 * @param icon Checkbox' icon or null
 * @param listener Checkbox' listener or null
 * @param actionCommand Checkbox' action command or null
 * @param mnemonic Checkbox' mnemonic (virtual key code) or 0
 * @param toolTip Checkbox' tool tip or null
 * @param state Checkbox' state
 * @return Created checkbox
 */
public static JCheckBox addCheckbox(Container component, String text, Icon icon,
    ActionListener listener, String actionCommand, int mnemonic, String toolTip, boolean state) {
  JCheckBox checkbox = new JCheckBox(text, icon, state);
  if (listener != null)
    checkbox.addActionListener(listener);
  if (actionCommand != null)
    checkbox.setActionCommand(actionCommand);
  if (mnemonic > 0)
    checkbox.setMnemonic(mnemonic);
  if (toolTip != null)
    checkbox.setToolTipText(toolTip);
  if (component != null)
    component.add(checkbox);
  return checkbox;
}
 
Example 3
Source File: UnitEditorDialog.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
public CheckCritPanel(int crits, int current) {
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    for (int i = 0; i < crits; i++) {
        JCheckBox check = new JCheckBox("");
        check.setActionCommand(Integer.toString(i));
        check.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                checkBoxes(evt);
            }
        });
        checks.add(check);
        add(check);
    }

    if (current > 0) {
        for (int i = 0; i < current; i++) {
            checks.get(i).setSelected(true);
        }
    }
}
 
Example 4
Source File: DefaultNumberAxisEditor.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JPanel createTickUnitPanel()
{
    JPanel tickUnitPanel = new JPanel(new LCBLayout(3));
    tickUnitPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    tickUnitPanel.add(new JPanel());
    JCheckBox autoTickUnitSelectionCheckBox = new JCheckBox(
            localizationResources.getString("Auto-TickUnit_Selection"),
            isAutoTickUnitSelection());
    autoTickUnitSelectionCheckBox.setActionCommand("AutoTickOnOff");
    autoTickUnitSelectionCheckBox.addActionListener(this);
    setAutoTickUnitSelectionCheckBox(autoTickUnitSelectionCheckBox);
    tickUnitPanel.add(getAutoTickUnitSelectionCheckBox());
    tickUnitPanel.add(new JPanel());

    tickUnitPanel.add(new JLabel(localizationResources.getString(
            "Manual_TickUnit_value")));
    this.manualTickUnit = new JTextField(Double.toString(
            this.manualTickUnitValue));
    this.manualTickUnit.setEnabled(!isAutoTickUnitSelection());
    this.manualTickUnit.setActionCommand("TickUnitValue");
    this.manualTickUnit.addActionListener(this);
    this.manualTickUnit.addFocusListener(this);
    tickUnitPanel.add(this.manualTickUnit);
    tickUnitPanel.add(new JPanel());

    return tickUnitPanel;
}
 
Example 5
Source File: DefaultNumberAxisEditor.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JPanel createTickUnitPanel()
{
    JPanel tickUnitPanel = new JPanel(new LCBLayout(3));
    tickUnitPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    tickUnitPanel.add(new JPanel());
    JCheckBox autoTickUnitSelectionCheckBox = new JCheckBox(
            localizationResources.getString("Auto-TickUnit_Selection"),
            isAutoTickUnitSelection());
    autoTickUnitSelectionCheckBox.setActionCommand("AutoTickOnOff");
    autoTickUnitSelectionCheckBox.addActionListener(this);
    setAutoTickUnitSelectionCheckBox(autoTickUnitSelectionCheckBox);
    tickUnitPanel.add(getAutoTickUnitSelectionCheckBox());
    tickUnitPanel.add(new JPanel());

    tickUnitPanel.add(new JLabel(localizationResources.getString(
            "Manual_TickUnit_value")));
    this.manualTickUnit = new JTextField(Double.toString(
            this.manualTickUnitValue));
    this.manualTickUnit.setEnabled(!isAutoTickUnitSelection());
    this.manualTickUnit.setActionCommand("TickUnitValue");
    this.manualTickUnit.addActionListener(this);
    this.manualTickUnit.addFocusListener(this);
    tickUnitPanel.add(this.manualTickUnit);
    tickUnitPanel.add(new JPanel());

    return tickUnitPanel;
}
 
Example 6
Source File: DefaultNumberAxisEditor.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JPanel createTickUnitPanel()
{
    JPanel tickUnitPanel = new JPanel(new LCBLayout(3));
    tickUnitPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    tickUnitPanel.add(new JPanel());
    JCheckBox autoTickUnitSelectionCheckBox = new JCheckBox(
            localizationResources.getString("Auto-TickUnit_Selection"),
            isAutoTickUnitSelection());
    autoTickUnitSelectionCheckBox.setActionCommand("AutoTickOnOff");
    autoTickUnitSelectionCheckBox.addActionListener(this);
    setAutoTickUnitSelectionCheckBox(autoTickUnitSelectionCheckBox);
    tickUnitPanel.add(getAutoTickUnitSelectionCheckBox());
    tickUnitPanel.add(new JPanel());

    tickUnitPanel.add(new JLabel(localizationResources.getString(
            "Manual_TickUnit_value")));
    this.manualTickUnit = new JTextField(Double.toString(
            this.manualTickUnitValue));
    this.manualTickUnit.setEnabled(!isAutoTickUnitSelection());
    this.manualTickUnit.setActionCommand("TickUnitValue");
    this.manualTickUnit.addActionListener(this);
    this.manualTickUnit.addFocusListener(this);
    tickUnitPanel.add(this.manualTickUnit);
    tickUnitPanel.add(new JPanel());

    return tickUnitPanel;
}
 
Example 7
Source File: DefaultNumberAxisEditor.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected JPanel createTickUnitPanel()
{
    JPanel tickUnitPanel = new JPanel(new LCBLayout(3));
    tickUnitPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    tickUnitPanel.add(new JPanel());
    JCheckBox autoTickUnitSelectionCheckBox = new JCheckBox(
            localizationResources.getString("Auto-TickUnit_Selection"),
            isAutoTickUnitSelection());
    autoTickUnitSelectionCheckBox.setActionCommand("AutoTickOnOff");
    autoTickUnitSelectionCheckBox.addActionListener(this);
    setAutoTickUnitSelectionCheckBox(autoTickUnitSelectionCheckBox);
    tickUnitPanel.add(getAutoTickUnitSelectionCheckBox());
    tickUnitPanel.add(new JPanel());

    tickUnitPanel.add(new JLabel(localizationResources.getString(
            "Manual_TickUnit_value")));
    this.manualTickUnit = new JTextField(Double.toString(
            this.manualTickUnitValue));
    this.manualTickUnit.setEnabled(!isAutoTickUnitSelection());
    this.manualTickUnit.setActionCommand("TickUnitValue");
    this.manualTickUnit.addActionListener(this);
    this.manualTickUnit.addFocusListener(this);
    tickUnitPanel.add(this.manualTickUnit);
    tickUnitPanel.add(new JPanel());

    return tickUnitPanel;
}
 
Example 8
Source File: KwikiDateModesSelectorPanel.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param enableThPa
 */
public void SetupDateCorrectionCheckBoxes ( boolean enableThPa ) {

    ActionListener dateCorrectionChkBoxActionListener = new ActionListener() {

        public void actionPerformed ( ActionEvent e ) {
            AbstractButton abstractButton =
                    (AbstractButton) e.getSource();
            String choice = abstractButton.getActionCommand();
            CalculateDateCorrectionMode( choice );
        }
    };

    correctTh = new JCheckBox( "Th" );
    correctTh.setActionCommand( "Th" );
    correctTh.setOpaque( false );
    correctTh.setForeground( new java.awt.Color( 204, 0, 0 ) );
    correctTh.setFont( new Font( "SansSerif", Font.BOLD, 9 ) );
    correctTh.setBounds( 125, 20, 45, 15 );
    correctTh.setEnabled( enableThPa );
    correctTh.addActionListener( dateCorrectionChkBoxActionListener );
    add( correctTh, javax.swing.JLayeredPane.DEFAULT_LAYER );

    correctPa = new JCheckBox( "Pa" );
    correctPa.setActionCommand( "Pa" );
    correctPa.setOpaque( false );
    correctPa.setForeground( new java.awt.Color( 204, 0, 0 ) );
    correctPa.setFont( new Font( "SansSerif", Font.BOLD, 9 ) );
    correctPa.setBounds( 125, 40, 45, 15 );
    correctPa.setEnabled( enableThPa );
    correctPa.addActionListener( dateCorrectionChkBoxActionListener );
    add( correctPa, javax.swing.JLayeredPane.DEFAULT_LAYER );
}
 
Example 9
Source File: PNGImageExporter.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public JComponent makeOptions(@Nonnull final PluginContext context) {
  final Options options = new Options(flagExpandAllNodes, flagDrawBackground);

  final JPanel panel = UI_FACTORY.makePanelWithOptions(options);
  final JCheckBox checkBoxExpandAll = UI_FACTORY.makeCheckBox();
  checkBoxExpandAll.setSelected(flagExpandAllNodes);
  checkBoxExpandAll.setText(Texts.getString("PNGImageExporter.optionUnfoldAll"));
  checkBoxExpandAll.setActionCommand("unfold");

  final JCheckBox checkBoxDrawBackground = UI_FACTORY.makeCheckBox();
  checkBoxDrawBackground.setSelected(flagDrawBackground);
  checkBoxDrawBackground.setText(Texts.getString("PNGImageExporter.optionDrawBackground"));
  checkBoxDrawBackground.setActionCommand("back");

  panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

  panel.add(checkBoxExpandAll);
  panel.add(checkBoxDrawBackground);

  panel.setBorder(BorderFactory.createEmptyBorder(16, 32, 16, 32));

  final ActionListener actionListener = new ActionListener() {
    @Override
    public void actionPerformed(@Nonnull final ActionEvent e) {
      if (e.getSource() == checkBoxExpandAll) {
        options.setOption(Options.KEY_EXPAND_ALL, Boolean.toString(checkBoxExpandAll.isSelected()));
      }
      if (e.getSource() == checkBoxDrawBackground) {
        options.setOption(Options.KEY_DRAW_BACK, Boolean.toString(checkBoxDrawBackground.isSelected()));
      }
    }
  };

  checkBoxExpandAll.addActionListener(actionListener);
  checkBoxDrawBackground.addActionListener(actionListener);

  return panel;
}
 
Example 10
Source File: SVGImageExporter.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public JComponent makeOptions(@Nonnull final PluginContext context) {
  final Options options = new Options(flagExpandAllNodes, flagDrawBackground);
  final JPanel panel = UI_FACTORY.makePanelWithOptions(options);
  final JCheckBox checkBoxExpandAll = UI_FACTORY.makeCheckBox();
  checkBoxExpandAll.setSelected(flagExpandAllNodes);
  checkBoxExpandAll.setText(Texts.getString("SvgExporter.optionUnfoldAll"));
  checkBoxExpandAll.setActionCommand("unfold");

  final JCheckBox checkBoxDrawBackground = UI_FACTORY.makeCheckBox();
  checkBoxDrawBackground.setSelected(flagDrawBackground);
  checkBoxDrawBackground.setText(Texts.getString("SvgExporter.optionDrawBackground"));
  checkBoxDrawBackground.setActionCommand("back");

  panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

  panel.add(checkBoxExpandAll);
  panel.add(checkBoxDrawBackground);

  panel.setBorder(BorderFactory.createEmptyBorder(16, 32, 16, 32));

  final ActionListener actionListener = new ActionListener() {
    @Override
    public void actionPerformed(@Nonnull final ActionEvent e) {
      if (e.getSource() == checkBoxExpandAll) {
        options.setOption(Options.KEY_EXPAND_ALL, Boolean.toString(checkBoxExpandAll.isSelected()));
      }
      if (e.getSource() == checkBoxDrawBackground) {
        options.setOption(Options.KEY_DRAW_BACK, Boolean.toString(checkBoxDrawBackground.isSelected()));
      }
    }
  };

  checkBoxExpandAll.addActionListener(actionListener);
  checkBoxDrawBackground.addActionListener(actionListener);

  return panel;
}
 
Example 11
Source File: DefaultNumberAxisEditor.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JPanel createTickUnitPanel()
{
    JPanel tickUnitPanel = new JPanel(new LCBLayout(3));
    tickUnitPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    tickUnitPanel.add(new JPanel());
    JCheckBox autoTickUnitSelectionCheckBox = new JCheckBox(
            localizationResources.getString("Auto-TickUnit_Selection"),
            isAutoTickUnitSelection());
    autoTickUnitSelectionCheckBox.setActionCommand("AutoTickOnOff");
    autoTickUnitSelectionCheckBox.addActionListener(this);
    setAutoTickUnitSelectionCheckBox(autoTickUnitSelectionCheckBox);
    tickUnitPanel.add(getAutoTickUnitSelectionCheckBox());
    tickUnitPanel.add(new JPanel());

    tickUnitPanel.add(new JLabel(localizationResources.getString(
            "Manual_TickUnit_value")));
    this.manualTickUnit = new JTextField(Double.toString(
            this.manualTickUnitValue));
    this.manualTickUnit.setEnabled(!isAutoTickUnitSelection());
    this.manualTickUnit.setActionCommand("TickUnitValue");
    this.manualTickUnit.addActionListener(this);
    this.manualTickUnit.addFocusListener(this);
    tickUnitPanel.add(this.manualTickUnit);
    tickUnitPanel.add(new JPanel());

    return tickUnitPanel;
}
 
Example 12
Source File: CreateBranchForm.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL
 */
private void $$$setupUI$$$() {
    contentPane = new JPanel();
    contentPane.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1));
    final JLabel label1 = new JLabel();
    this.$$$loadLabelText$$$(label1, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("CreateBranchForm.Source"));
    contentPane.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final Spacer spacer1 = new Spacer();
    contentPane.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
    sourceText = new JTextField();
    sourceText.setEditable(false);
    sourceText.setEnabled(true);
    contentPane.add(sourceText, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
    targetLabel = new JLabel();
    this.$$$loadLabelText$$$(targetLabel, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("CreateBranchForm.Target"));
    contentPane.add(targetLabel, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    targetText = new TextFieldWithBrowseButton.NoPathCompletion();
    contentPane.add(targetText, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    panel1.setVisible(false);
    contentPane.add(panel1, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Branch from version"));
    final Spacer spacer2 = new Spacer();
    contentPane.add(spacer2, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
    syncNewBranchCheckBox = new JCheckBox();
    syncNewBranchCheckBox.setActionCommand("Create local copy of new branch");
    syncNewBranchCheckBox.setLabel("Create local copy of new branch");
    this.$$$loadButtonText$$$(syncNewBranchCheckBox, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("CreateBranchForm.SyncNewBranch"));
    contentPane.add(syncNewBranchCheckBox, new GridConstraints(5, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    label1.setLabelFor(sourceText);
}
 
Example 13
Source File: DefaultNumberAxisEditor.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
@Override
protected JPanel createTickUnitPanel()
{
    JPanel tickUnitPanel = new JPanel(new LCBLayout(3));
    tickUnitPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    tickUnitPanel.add(new JPanel());
    JCheckBox autoTickUnitSelectionCheckBox = new JCheckBox(
            localizationResources.getString("Auto-TickUnit_Selection"),
            isAutoTickUnitSelection());
    autoTickUnitSelectionCheckBox.setActionCommand("AutoTickOnOff");
    autoTickUnitSelectionCheckBox.addActionListener(this);
    setAutoTickUnitSelectionCheckBox(autoTickUnitSelectionCheckBox);
    tickUnitPanel.add(getAutoTickUnitSelectionCheckBox());
    tickUnitPanel.add(new JPanel());

    tickUnitPanel.add(new JLabel(localizationResources.getString(
            "Manual_TickUnit_value")));
    this.manualTickUnit = new JTextField(Double.toString(
            this.manualTickUnitValue));
    this.manualTickUnit.setEnabled(!isAutoTickUnitSelection());
    this.manualTickUnit.setActionCommand("TickUnitValue");
    this.manualTickUnit.addActionListener(this);
    this.manualTickUnit.addFocusListener(this);
    tickUnitPanel.add(this.manualTickUnit);
    tickUnitPanel.add(new JPanel());

    return tickUnitPanel;
}
 
Example 14
Source File: DataViewUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    JButton button = (JButton) e.getSource();
    JCheckBox firstEntry = null;
    JPopupMenu popupMenu = new JPopupMenu();

    JPanel menuPanel = new JPanel();
    menuPanel.setFocusCycleRoot(true);
    popupMenu.add(menuPanel);
    menuPanel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.BASELINE_LEADING;
    constraints.weightx = 1;
    constraints.gridx = 0;
    
    Set<Integer> visibleColumns = dataPanel.getVisibleColumns();
    DataViewTableUIModel dvtm = dataPanel.getModel();
    
    for(int i = 0; i < dvtm.getColumnCount(); i++) {
        JCheckBox columnEntry = new JCheckBox(dvtm.getColumnName(i));
        columnEntry.setActionCommand(Integer.toString(i));
        columnEntry.setSelected(visibleColumns.contains(i));
        columnEntry.addActionListener(columnVisibilityToggler);
        constraints.gridy += 1;
        menuPanel.add(columnEntry, constraints);
        if(firstEntry == null) {
            firstEntry = columnEntry;
        }
    }
    
    constraints.gridy += 1;
    menuPanel.add(new JSeparator(), constraints);
    
    JCheckBox checkboxItem = new JCheckBox("Fit column width");
    checkboxItem.setSelected(dataPanel.getAutoResizeMode() != JTable.AUTO_RESIZE_OFF);
    checkboxItem.addActionListener(fitColumnWidthToggler);
    
    constraints.gridy += 1;
    menuPanel.add(checkboxItem, constraints);
    
    popupMenu.show(button, 0, button.getHeight());
    if(firstEntry == null) {
        checkboxItem.requestFocus();
    } else {
        firstEntry.requestFocus();
    }
}
 
Example 15
Source File: MaterialsTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public MaterialsTab(final Program program) {
	super(program, TabsMaterials.get().materials(), Images.TOOL_MATERIALS.getIcon(), true);
	//Category: Asteroid
	//Category: Material

	ListenerClass listener = new ListenerClass();
	
	JFixedToolBar jToolBarLeft = new JFixedToolBar();

	jOwners = new JComboBox<>();
	jOwners.setActionCommand(MaterialsAction.SELECTED.name());
	jOwners.addActionListener(listener);
	jToolBarLeft.addComboBox(jOwners, 200);

	jPiMaterial = new JCheckBox(TabsMaterials.get().includePI());
	jPiMaterial.setActionCommand(MaterialsAction.SELECTED.name());
	jPiMaterial.addActionListener(listener);
	jToolBarLeft.add(jPiMaterial);

	jToolBarLeft.addSpace(10);

	jToolBarLeft.addSeparator();

	jExport = new JButton(GuiShared.get().export(), Images.DIALOG_CSV_EXPORT.getIcon());
	jExport.setActionCommand(MaterialsAction.EXPORT.name());
	jExport.addActionListener(listener);
	jToolBarLeft.addButton(jExport);

	JFixedToolBar jToolBarRight = new JFixedToolBar();

	jCollapse = new JButton(TabsMaterials.get().collapse(), Images.MISC_COLLAPSED.getIcon());
	jCollapse.setActionCommand(MaterialsAction.COLLAPSE.name());
	jCollapse.addActionListener(listener);
	jToolBarRight.addButton(jCollapse);

	jExpand = new JButton(TabsMaterials.get().expand(), Images.MISC_EXPANDED.getIcon());
	jExpand.setActionCommand(MaterialsAction.EXPAND.name());
	jExpand.addActionListener(listener);
	jToolBarRight.addButton(jExpand);

	//Table Format
	tableFormat = new EnumTableFormatAdaptor<>(MaterialTableFormat.class);
	//Backend
	eventList = EventListManager.create();
	//Separator
	eventList.getReadWriteLock().readLock().lock();
	separatorList = new SeparatorList<>(eventList, new MaterialSeparatorComparator(), 1, Integer.MAX_VALUE);
	eventList.getReadWriteLock().readLock().unlock();
	//Table Model
	tableModel = EventModels.createTableModel(separatorList, tableFormat);
	//Table
	jTable = new JSeparatorTable(program, tableModel, separatorList);
	jTable.setSeparatorRenderer(new MaterialsSeparatorTableCell(jTable, separatorList));
	jTable.setSeparatorEditor(new MaterialsSeparatorTableCell(jTable, separatorList));
	PaddingTableCellRenderer.install(jTable, 3);
	//Selection Model
	selectionModel = EventModels.createSelectionModel(separatorList);
	selectionModel.setSelectionMode(ListSelection.MULTIPLE_INTERVAL_SELECTION_DEFENSIVE);
	jTable.setSelectionModel(selectionModel);
	//Listeners
	installTable(jTable, NAME);
	//Scroll
	jTableScroll = new JScrollPane(jTable);
	//Menu
	installMenu(program, new MaterialTableMenu(), jTable, Material.class);

	List<EnumTableColumn<Material>> enumColumns = new ArrayList<>();
	enumColumns.addAll(Arrays.asList(MaterialExtenedTableFormat.values()));
	enumColumns.addAll(Arrays.asList(MaterialTableFormat.values()));
	exportDialog = new ExportDialog<>(program.getMainWindow().getFrame(), NAME, null, new MaterialsFilterControl(), Collections.singletonList(eventList), enumColumns);

	layout.setHorizontalGroup(
		layout.createParallelGroup()
			.addGroup(layout.createSequentialGroup()
				.addComponent(jToolBarLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Integer.MAX_VALUE)
				.addGap(0)
				.addComponent(jToolBarRight)
			)
			.addComponent(jTableScroll, 0, 0, Short.MAX_VALUE)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addGroup(layout.createParallelGroup()
				.addComponent(jToolBarLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				.addComponent(jToolBarRight, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
			)
			.addComponent(jTableScroll, 0, 0, Short.MAX_VALUE)
	);
}
 
Example 16
Source File: FilterGui.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
protected FilterGui(final JFrame jFrame, final FilterControl<E> filterControl) {
	this.jFrame = jFrame;
	this.filterControl = filterControl;

	exportDialog = new ExportDialog<>(jFrame, filterControl.getName(), filterControl, filterControl, Collections.singletonList(filterControl.getExportEventList()), filterControl.getColumns());

	jPanel = new JPanel();

	layout = new GroupLayout(jPanel);
	jPanel.setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(false);

	jToolBarLeft = new JFixedToolBar();

	//Add
	JButton jAddField = new JButton(GuiShared.get().addField());
	jAddField.setIcon(Images.EDIT_ADD.getIcon());
	jAddField.setActionCommand(FilterGuiAction.ADD.name());
	jAddField.addActionListener(listener);
	jToolBarLeft.addButton(jAddField);

	//Reset
	JButton jClearFields = new JButton(GuiShared.get().clearField());
	jClearFields.setIcon(Images.FILTER_CLEAR.getIcon());
	jClearFields.setActionCommand(FilterGuiAction.CLEAR.name());
	jClearFields.addActionListener(listener);
	jToolBarLeft.addButton(jClearFields);

	jToolBarLeft.addSeparator();

	//Save Filter
	JButton jSaveFilter = new JButton(GuiShared.get().saveFilter());
	jSaveFilter.setIcon(Images.FILTER_SAVE.getIcon());
	jSaveFilter.setActionCommand(FilterGuiAction.SAVE.name());
	jSaveFilter.addActionListener(listener);
	jToolBarLeft.addButton(jSaveFilter);

	//Load Filter
	jLoadFilter = new JDropDownButton(GuiShared.get().loadFilter());
	jLoadFilter.setIcon(Images.FILTER_LOAD.getIcon());
	jLoadFilter.keepVisible(2);
	jLoadFilter.setTopFixedCount(2);
	jLoadFilter.setInterval(125);
	jToolBarLeft.addButton(jLoadFilter);

	jToolBarLeft.addSeparator();

	//Export
	jExportButton = new JButton(GuiShared.get().export());
	jExportButton.setIcon(Images.DIALOG_CSV_EXPORT.getIcon());
	jExportButton.setActionCommand(FilterGuiAction.EXPORT.name());
	jExportButton.addActionListener(listener);
	jToolBarLeft.addButton(jExportButton);

	jExportMenu = new JDropDownButton(GuiShared.get().export(), Images.DIALOG_CSV_EXPORT.getIcon());
	jExportMenu.setVisible(false);
	jToolBarLeft.addButton(jExportMenu);

	JMenuItem jExportMenuItem = new JMenuItem(GuiShared.get().exportTableData());
	jExportMenuItem.setIcon(Images.DIALOG_CSV_EXPORT.getIcon());
	jExportMenuItem.setActionCommand(FilterGuiAction.EXPORT.name());
	jExportMenuItem.addActionListener(listener);
	jExportMenu.add(jExportMenuItem);

	jToolBarLeft.addSeparator();

	//Show Filters
	jShowFilters = new JCheckBox(GuiShared.get().showFilters());
	jShowFilters.setActionCommand(FilterGuiAction.SHOW_FILTERS.name());
	jShowFilters.addActionListener(listener);
	jShowFilters.setSelected(true);
	jToolBarLeft.addButton(jShowFilters, 70, SwingConstants.CENTER);

	jToolBarRight = new JFixedToolBar();

	jToolBarRight.addSpace(10);

	//Showing
	jShowing = new JLabel();
	jToolBarRight.add(jShowing);



	updateFilters();
	add();

	filterSave = new FilterSave(jFrame);
	filterManager = new FilterManager<>(jFrame, filterControl.getName(), this, filterControl.getFilters(), filterControl.getDefaultFilters());
}
 
Example 17
Source File: GrammarVizView.java    From grammarviz2_src with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Builds a parameters pane.
 */
private void buildSAXParamsPane() {

  saxParametersPane = new JPanel();
  saxParametersPane.setBorder(BorderFactory.createTitledBorder(
      BorderFactory.createEtchedBorder(BevelBorder.LOWERED), "SAX parameteres", TitledBorder.LEFT,
      TitledBorder.CENTER, new Font(TITLE_FONT, Font.PLAIN, 10)));

  // insets: T, L, B, R.
  MigLayout saxPaneLayout = new MigLayout("insets 3 2 2 2",
      "[][]10[][fill,grow]10[][fill,grow]10[][fill,grow]10[][]", "[]");
  saxParametersPane.setLayout(saxPaneLayout);

  // the sliding window parameter
  JLabel slideWindowLabel = new JLabel("Slide the window");
  useSlidingWindowCheckBox = new JCheckBox();
  useSlidingWindowCheckBox.setSelected(this.controller.getSession().useSlidingWindow);
  useSlidingWindowCheckBox.setActionCommand(USE_SLIDING_WINDOW_ACTION_KEY);
  useSlidingWindowCheckBox.addActionListener(this);

  windowSizeLabel = new JLabel("Window size:");
  SAXwindowSizeField = new JTextField(String.valueOf(this.controller.getSession().saxWindow));

  paaSizeLabel = new JLabel("PAA size:");
  SAXpaaSizeField = new JTextField(String.valueOf(this.controller.getSession().saxPAA));

  JLabel alphabetSizeLabel = new JLabel("Alphabet size:");
  SAXalphabetSizeField = new JTextField(String.valueOf(this.controller.getSession().saxAlphabet));

  saxParametersPane.add(slideWindowLabel);
  saxParametersPane.add(useSlidingWindowCheckBox);

  saxParametersPane.add(windowSizeLabel);
  saxParametersPane.add(SAXwindowSizeField);

  saxParametersPane.add(paaSizeLabel);
  saxParametersPane.add(SAXpaaSizeField);

  saxParametersPane.add(alphabetSizeLabel);
  saxParametersPane.add(SAXalphabetSizeField);

  guessParametersButton = new JButton("Guess");
  guessParametersButton.setMnemonic('G');
  guessParametersButton.setActionCommand(GUESS_PARAMETERS);
  guessParametersButton.addActionListener(this);
  saxParametersPane.add(guessParametersButton, "");

  // numerosity reduction pane
  //
  numerosityReductionPane = new JPanel();
  numerosityReductionPane.setBorder(BorderFactory.createTitledBorder(
      BorderFactory.createEtchedBorder(BevelBorder.LOWERED), "Numerosity reduction",
      TitledBorder.LEFT, TitledBorder.CENTER, new Font(TITLE_FONT, Font.PLAIN, 10)));

  // insets: T, L, B, R.
  MigLayout numerosityPaneLayout = new MigLayout("insets 3 2 10 2", "[]5[]5[]", "[]");
  numerosityReductionPane.setLayout(numerosityPaneLayout);

  numerosityReductionOFFButton.setActionCommand(NumerosityReductionStrategy.NONE.toString());
  numerosityButtonsGroup.add(numerosityReductionOFFButton);
  numerosityReductionOFFButton.addActionListener(this);
  numerosityReductionPane.add(numerosityReductionOFFButton);

  numerosityReductionExactButton.setActionCommand(NumerosityReductionStrategy.EXACT.toString());
  numerosityButtonsGroup.add(numerosityReductionExactButton);
  numerosityReductionExactButton.addActionListener(this);
  numerosityReductionPane.add(numerosityReductionExactButton);

  numerosityReductionMINDISTButton
      .setActionCommand(NumerosityReductionStrategy.MINDIST.toString());
  numerosityButtonsGroup.add(numerosityReductionMINDISTButton);
  numerosityReductionMINDISTButton.addActionListener(this);
  numerosityReductionPane.add(numerosityReductionMINDISTButton);

  this.controller.getSession().numerosityReductionStrategy = NumerosityReductionStrategy.EXACT;
  numerosityReductionExactButton.setSelected(true);

  // PROCESS button
  //
  discretizeButton = new JButton("Discretize");
  discretizeButton.setMnemonic('P');
  discretizeButton.setActionCommand(PROCESS_DATA);
  discretizeButton.addActionListener(this);

  discretizePane = new JPanel();
  discretizePane.setBorder(BorderFactory.createTitledBorder(
      BorderFactory.createEtchedBorder(BevelBorder.LOWERED), "Hit to run GI", TitledBorder.LEFT,
      TitledBorder.CENTER, new Font(TITLE_FONT, Font.PLAIN, 10)));
  // insets: T, L, B, R.
  MigLayout processPaneLayout = new MigLayout("insets 3 2 4 2", "5[]5", "[]");
  discretizePane.setLayout(processPaneLayout);
  discretizePane.add(discretizeButton, "");

}
 
Example 18
Source File: AutoSavePanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The
 * content of this method is always regenerated by the Form Editor.
 */

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    chkUseFeature = new JCheckBox();
    chkSaveOnFocusLost = new JCheckBox();
    spnMinutes = new JSpinner();
    jLabel2 = new JLabel();

    Mnemonics.setLocalizedText(chkUseFeature, NbBundle.getMessage(AutoSavePanel.class, "AutoSavePanel.jLabel1.text")); // NOI18N
    chkUseFeature.setActionCommand(NbBundle.getMessage(AutoSavePanel.class, "AutoSavePanel.chkUseFeature.actionCommand")); // NOI18N
    chkUseFeature.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent evt) {
            chkUseFeatureItemStateChanged(evt);
        }
    });

    Mnemonics.setLocalizedText(chkSaveOnFocusLost, NbBundle.getMessage(AutoSavePanel.class,"AutoSavePanel.chkSaveOnFocusLost.text")); // NOI18N

    spnMinutes.setModel(this.spnModel);
    spnMinutes.setToolTipText(NbBundle.getMessage(AutoSavePanel.class, "AutoSavePanel.spnMinutes.toolTipText")); // NOI18N

    Mnemonics.setLocalizedText(jLabel2, NbBundle.getMessage(AutoSavePanel.class, "AutoSavePanel.jLabel2.text")); // NOI18N

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                .addComponent(chkSaveOnFocusLost)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(chkUseFeature)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(spnMinutes, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(jLabel2)))
            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                .addComponent(chkUseFeature)
                .addComponent(spnMinutes, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel2))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addComponent(chkSaveOnFocusLost)
            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
}
 
Example 19
Source File: SlowPanel.java    From VanetSim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor, creating GUI items.
 */
public SlowPanel(){
	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;
	
	
	c.gridwidth = 1;
	c.insets = new Insets(5,5,5,5);

	c.gridx = 0;
	timeToPseudonymChangeLabel_ = new JLabel(Messages.getString("SlowPanel.timeToPseudonymChange")); //$NON-NLS-1$
	++c.gridy;
	add(timeToPseudonymChangeLabel_,c);		
	timeToPseudonymChange_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
	timeToPseudonymChange_.setValue(3000);

	timeToPseudonymChange_.setPreferredSize(new Dimension(60,20));
	c.gridx = 1;
	timeToPseudonymChange_.addFocusListener(this);
	add(timeToPseudonymChange_,c);
	
	c.gridx = 0;
	slowSpeedLimitLabel_ = new JLabel(Messages.getString("SlowPanel.speedLimit")); //$NON-NLS-1$
	++c.gridy;
	add(slowSpeedLimitLabel_,c);		
	slowSpeedLimit_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
	slowSpeedLimit_.setValue(30);

	slowSpeedLimit_.setPreferredSize(new Dimension(60,20));
	c.gridx = 1;
	slowSpeedLimit_.addFocusListener(this);
	add(slowSpeedLimit_,c);
	
	c.gridx = 0;
	enableSlowLabel_ = new JLabel(Messages.getString("SlowPanel.enable")); //$NON-NLS-1$
	++c.gridy;
	add(enableSlowLabel_,c);		
	enableSlow_ = new JCheckBox();
	enableSlow_.setSelected(false);
	enableSlow_.setActionCommand("enableSlow"); //$NON-NLS-1$
	c.gridx = 1;
	enableSlow_.addFocusListener(this);
	add(enableSlow_,c);
	enableSlow_.addActionListener(this);	
	
	
	//to consume the rest of the space
	c.weighty = 1.0;
	++c.gridy;
	JPanel space = new JPanel();
	space.setOpaque(false);
	add(space, c);
}
 
Example 20
Source File: SilentPeriodPanel.java    From VanetSim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor, creating GUI items.
 */
public SilentPeriodPanel(){
	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;
	
	
	c.gridwidth = 1;
	c.insets = new Insets(5,5,5,5);
	
	c.gridx = 0;
	silentPeriodDurationLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.duration")); //$NON-NLS-1$
	++c.gridy;
	add(silentPeriodDurationLabel_,c);		
	silentPeriodDuration_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
	silentPeriodDuration_.setValue(3000);

	silentPeriodDuration_.setPreferredSize(new Dimension(60,20));
	c.gridx = 1;
	silentPeriodDuration_.addFocusListener(this);
	add(silentPeriodDuration_,c);
	
	c.gridx = 0;
	silentPeriodFrequencyLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.frequency")); //$NON-NLS-1$
	++c.gridy;
	add(silentPeriodFrequencyLabel_,c);		
	silentPeriodFrequency_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
	silentPeriodFrequency_.setValue(10000);

	silentPeriodFrequency_.setPreferredSize(new Dimension(60,20));
	c.gridx = 1;
	silentPeriodFrequency_.addFocusListener(this);
	add(silentPeriodFrequency_,c);
	
	c.gridx = 0;
	enableSilentPeriodsLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.enable")); //$NON-NLS-1$
	++c.gridy;
	add(enableSilentPeriodsLabel_,c);		
	enableSilentPeriods_ = new JCheckBox();
	enableSilentPeriods_.setSelected(false);
	enableSilentPeriods_.setActionCommand("enableSilentPeriods"); //$NON-NLS-1$
	c.gridx = 1;
	enableSilentPeriods_.addFocusListener(this);
	add(enableSilentPeriods_,c);
	enableSilentPeriods_.addActionListener(this);	
	
	
	//to consume the rest of the space
	c.weighty = 1.0;
	++c.gridy;
	JPanel space = new JPanel();
	space.setOpaque(false);
	add(space, c);
}