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

The following examples show how to use javax.swing.JCheckBox#setMnemonic() . 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: SimpleGUI.java    From org.alloytools.alloy with Apache License 2.0 6 votes vote down vote up
/** This method performs Edit->Find. */
private Runner doFind() {
    if (wrap)
        return wrapMe();
    JTextField x = OurUtil.textfield(lastFind, 30);
    x.selectAll();
    JCheckBox c = new JCheckBox("Case Sensitive?", lastFindCaseSensitive);
    c.setMnemonic('c');
    JCheckBox b = new JCheckBox("Search Backward?", !lastFindForward);
    b.setMnemonic('b');
    if (!OurDialog.getInput(frame, "Find", "Text:", x, " ", c, b))
        return null;
    if (x.getText().length() == 0)
        return null;
    lastFind = x.getText();
    lastFindCaseSensitive = c.getModel().isSelected();
    lastFindForward = !b.getModel().isSelected();
    doFindNext();
    return null;
}
 
Example 3
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 4
Source File: NodeTableModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void makeAccessibleCheckBox(JCheckBox box, Property p) {
    box.getAccessibleContext().setAccessibleName(p.getDisplayName());
    box.getAccessibleContext().setAccessibleDescription(p.getShortDescription());

    Object mnemonicChar = p.getValue(ATTR_MNEMONIC_CHAR);

    if ((null != mnemonicChar) && (mnemonicChar.toString().length() > 0)) {
        box.setMnemonic(mnemonicChar.toString().charAt(0));
    }
}
 
Example 5
Source File: PreviewComponent.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
public PreviewComponent() {
  super(new MigLayout());
  titleLabel = new JLabel(Messages.getMessage("preview.label"));
  nameLabel = new JLabel();
  contentArea = new JTextArea();
  contentArea.setEditable(false);
  border = BorderFactory.createTitledBorder(Messages.getMessage("preview.fileContent"));
  contentArea.setBorder(border);
  contentArea.setAutoscrolls(false);
  contentArea.setFont(new Font("Courier New", Font.PLAIN, contentArea.getFont().getSize()));

  contentScrollPane = new JScrollPane(contentArea);
  contentScrollPane.setAutoscrolls(false);

  progressBar = new JProgressBar();
  progressBar.setStringPainted(true);
  progressBar.setMaximum(1);
  enabledCheckBox = new JCheckBox(Messages.getMessage("preview.enable"), true);
  enabledCheckBox.setMnemonic(Messages.getMessage("preview.enable.mnemonic").charAt(0));
  enabledCheckBox.setRolloverEnabled(true);
  enabledCheckBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent actionEvent) {
      boolean enabled = enabledCheckBox.isSelected();
      progressBar.setEnabled(enabled);
      contentScrollPane.setEnabled(enabled);
      contentArea.setEnabled(enabled);
      nameLabel.setEnabled(enabled);
      titleLabel.setEnabled(enabled);
    }
  });

  add(titleLabel, "dock north, gap 5 5 5 5, center");
  add(nameLabel, "dock north, gap 5 5 5 5");
  add(contentScrollPane, "dock center, gap 5 5 5 5");
  add(enabledCheckBox, "dock south, gap 0 5 5 5");
  add(progressBar, "dock south, gap 5 5 5 5");
}
 
Example 6
Source File: AISelectFrame.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * GUIAInitialization
 */
protected void initUI() {
	this.getContentPane().setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));

	// AIList
	JPanel panelAIList = new JPanel();
	panelAIList.setLayout(new BorderLayout());
	panelAIList.setAlignmentX(LEFT_ALIGNMENT);
	this.add(panelAIList);

	String[] strList = new String[aiPathList.length];
	for(int i = 0; i < strList.length; i++) {
		strList[i] = aiNameList[i] + " (" + aiPathList[i] + ")";
	}
	listboxAI = new JList(strList);

	JScrollPane scpaneAI = new JScrollPane(listboxAI);
	scpaneAI.setPreferredSize(new Dimension(400, 250));
	panelAIList.add(scpaneAI, BorderLayout.CENTER);

	JButton btnNoUse = new JButton(NullpoMinoSwing.getUIText("AISelect_NoUse"));
	btnNoUse.setMnemonic('N');
	btnNoUse.addActionListener(this);
	btnNoUse.setActionCommand("AISelect_NoUse");
	btnNoUse.setMaximumSize(new Dimension(Short.MAX_VALUE, 30));
	panelAIList.add(btnNoUse, BorderLayout.SOUTH);

	// AIText box of the movement interval
	JPanel panelTxtfldAIMoveDelay = new JPanel();
	panelTxtfldAIMoveDelay.setLayout(new BorderLayout());
	panelTxtfldAIMoveDelay.setAlignmentX(LEFT_ALIGNMENT);
	this.add(panelTxtfldAIMoveDelay);

	panelTxtfldAIMoveDelay.add(new JLabel(NullpoMinoSwing.getUIText("AISelect_LabelAIMoveDelay")), BorderLayout.WEST);

	txtfldAIMoveDelay = new JTextField(20);
	panelTxtfldAIMoveDelay.add(txtfldAIMoveDelay, BorderLayout.EAST);

	// AIText box of the movement interval
	JPanel panelTxtfldAIThinkDelay = new JPanel();
	panelTxtfldAIThinkDelay.setLayout(new BorderLayout());
	panelTxtfldAIThinkDelay.setAlignmentX(LEFT_ALIGNMENT);
	this.add(panelTxtfldAIThinkDelay);

	panelTxtfldAIThinkDelay.add(new JLabel(NullpoMinoSwing.getUIText("AISelect_LabelAIThinkDelay")), BorderLayout.WEST);

	txtfldAIThinkDelay = new JTextField(20);
	panelTxtfldAIThinkDelay.add(txtfldAIThinkDelay, BorderLayout.EAST);

	// AIThread use check Box
	chkboxAIUseThread = new JCheckBox(NullpoMinoSwing.getUIText("AISelect_CheckboxAIUseThread"));
	chkboxAIUseThread.setAlignmentX(LEFT_ALIGNMENT);
	chkboxAIUseThread.setMnemonic('T');
	this.add(chkboxAIUseThread);

	chkBoxAIShowHint = new JCheckBox(NullpoMinoSwing.getUIText("AISelect_CheckboxAIShowHint"));
	chkBoxAIShowHint.setAlignmentX(LEFT_ALIGNMENT);
	chkBoxAIShowHint.setMnemonic('H');
	this.add(chkBoxAIShowHint);

	chkBoxAIPrethink = new JCheckBox(NullpoMinoSwing.getUIText("AISelect_CheckboxAIPrethink"));
	chkBoxAIPrethink.setAlignmentX(LEFT_ALIGNMENT);
	chkBoxAIPrethink.setMnemonic('P');
	this.add(chkBoxAIPrethink);

	chkBoxAIShowState = new JCheckBox(NullpoMinoSwing.getUIText("AISelect_CheckboxAIShowState"));
	chkBoxAIShowState.setAlignmentX(LEFT_ALIGNMENT);
	chkBoxAIShowState.setMnemonic('S');
	this.add(chkBoxAIShowState);

	//  buttonKind
	JPanel panelButtons = new JPanel();
	panelButtons.setLayout(new BoxLayout(panelButtons, BoxLayout.X_AXIS));
	panelButtons.setAlignmentX(LEFT_ALIGNMENT);
	this.add(panelButtons);

	JButton btnOK = new JButton(NullpoMinoSwing.getUIText("AISelect_OK"));
	btnOK.setMnemonic('O');
	btnOK.addActionListener(this);
	btnOK.setActionCommand("AISelect_OK");
	btnOK.setAlignmentX(LEFT_ALIGNMENT);
	btnOK.setMaximumSize(new Dimension(Short.MAX_VALUE, 30));
	panelButtons.add(btnOK);
	this.getRootPane().setDefaultButton(btnOK);

	JButton btnCancel = new JButton(NullpoMinoSwing.getUIText("AISelect_Cancel"));
	btnCancel.setMnemonic('C');
	btnCancel.addActionListener(this);
	btnCancel.setActionCommand("AISelect_Cancel");
	btnCancel.setAlignmentX(LEFT_ALIGNMENT);
	btnCancel.setMaximumSize(new Dimension(Short.MAX_VALUE, 30));
	panelButtons.add(btnCancel);
}
 
Example 7
Source File: DPreferences.java    From keystore-explorer with GNU General Public License v3.0 4 votes vote down vote up
private void initAuthorityCertificatesTab() {

		jlCaCertificatesFile = new JLabel(res.getString("DPreferences.jlCaCertificatesFile.text"));
		jtfCaCertificatesFile = new JTextField(caCertificatesFile.toString(), 25);
		jtfCaCertificatesFile.setToolTipText(res.getString("DPreferences.jtfCaCertificatesFile.tooltip"));
		jtfCaCertificatesFile.setCaretPosition(0);
		jtfCaCertificatesFile.setEditable(false);

		jbBrowseCaCertificatesFile = new JButton(res.getString("DPreferences.jbBrowseCaCertificatesFile.text"));
		PlatformUtil.setMnemonic(jbBrowseCaCertificatesFile,
				res.getString("DPreferences.jbBrowseCaCertificatesFile.mnemonic").charAt(0));
		jbBrowseCaCertificatesFile.setToolTipText(res.getString("DPreferences.jbBrowseCaCertificatesFile.tooltip"));

		jcbUseCaCertificates = new JCheckBox(res.getString("DPreferences.jcbUseCaCertificates.text"), useCaCertificates);
		jcbUseCaCertificates.setToolTipText(res.getString("DPreferences.jcbUseCaCertificates.tooltip"));
		PlatformUtil.setMnemonic(jcbUseCaCertificates, res.getString("DPreferences.jcbUseCaCertificates.mnemonic")
				.charAt(0));

		jcbUseWinTrustedRootCertificates = new JCheckBox(
				res.getString("DPreferences.jcbUseWinTrustRootCertificates.text"), useWinTrustRootCertificates);
		jcbUseWinTrustedRootCertificates.setToolTipText(res
				.getString("DPreferences.jcbUseWinTrustRootCertificates.tooltip"));
		PlatformUtil.setMnemonic(jcbUseWinTrustedRootCertificates,
				res.getString("DPreferences.jcbUseWinTrustRootCertificates.menmonic").charAt(0));


		jlTrustChecks = new JLabel(res.getString("DPreferences.jlTrustChecks.text"));

		jcbEnableImportTrustedCertTrustCheck = new JCheckBox(
				res.getString("DPreferences.jcbEnableImportTrustedCertTrustCheck.text"),
				enableImportTrustedCertTrustCheck);
		jcbEnableImportTrustedCertTrustCheck.setToolTipText(res
				.getString("DPreferences.jcbEnableImportTrustedCertTrustCheck.tooltip"));
		jcbEnableImportTrustedCertTrustCheck.setMnemonic(res.getString(
				"DPreferences.jcbEnableImportTrustedCertTrustCheck.mnemonic").charAt(0));

		jcbEnableImportCaReplyTrustCheck = new JCheckBox(
				res.getString("DPreferences.jcbEnableImportCaReplyTrustCheck.text"), enableImportCaReplyTrustCheck);
		jcbEnableImportCaReplyTrustCheck.setToolTipText(res
				.getString("DPreferences.jcbEnableImportCaReplyTrustCheck.tooltip"));
		jcbEnableImportCaReplyTrustCheck.setMnemonic(res.getString(
				"DPreferences.jcbEnableImportCaReplyTrustCheck.mnemonic").charAt(0));

		// layout
		jpAuthorityCertificates = new JPanel();
		jpAuthorityCertificates.setLayout(new MigLayout("insets dialog", "20lp[][]", "20lp[][]"));
		jpAuthorityCertificates.add(jlCaCertificatesFile, "split");
		jpAuthorityCertificates.add(jtfCaCertificatesFile, "");
		jpAuthorityCertificates.add(jbBrowseCaCertificatesFile, "wrap rel");
		if (Security.getProvider(SecurityProvider.MS_CAPI.jce()) != null) {
			jpAuthorityCertificates.add(jcbUseCaCertificates, "wrap rel");
			jpAuthorityCertificates.add(jcbUseWinTrustedRootCertificates, "wrap para");
		} else {
			jpAuthorityCertificates.add(jcbUseCaCertificates, "wrap para");
		}
		jpAuthorityCertificates.add(jlTrustChecks, "wrap unrel");
		jpAuthorityCertificates.add(jcbEnableImportTrustedCertTrustCheck, "wrap rel");
		jpAuthorityCertificates.add(jcbEnableImportCaReplyTrustCheck, "wrap unrel");


		jbBrowseCaCertificatesFile.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent evt) {
				try {
					CursorUtil.setCursorBusy(DPreferences.this);
					browsePressed();
				} finally {
					CursorUtil.setCursorFree(DPreferences.this);
				}
			}
		});
	}
 
Example 8
Source File: ViewOptions.java    From AML-Project with Apache License 2.0 4 votes vote down vote up
public ViewOptions()
{
	super();
	aml = AML.getInstance();
	
	this.setTitle("Graph Options");
	this.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
	
	languageLabel = new JLabel("Label Language:");
	Vector<String> languages = new Vector<String>(aml.getLanguages());
	languageSelector = new JComboBox<String>(languages);
	languageSelector.setSelectedItem(aml.getLabelLanguage());
	languagePanel = new JPanel();
	languagePanel.add(languageLabel);
	languagePanel.add(languageSelector);

	ancestors = new JCheckBox("View Ancestors");
	ancestors.setMnemonic(KeyEvent.VK_C);
	ancestors.setSelected(AML.getInstance().showAncestors());
	descendants = new JCheckBox("View Descendants");
	descendants.setMnemonic(KeyEvent.VK_C);
	descendants.setSelected(AML.getInstance().showDescendants());
	directionPanel = new JPanel();
	directionPanel.add(ancestors);
	directionPanel.add(descendants);
	
	classLabel = new JLabel("Class extension (edges):");
	classSelector = new JComboBox<Integer>(DIST);
	classSelector.setSelectedIndex(AML.getInstance().getClassDistance());
       classPanel = new JPanel();
	classPanel.add(classLabel);
	classPanel.add(classSelector);
	
	individualLabel = new JLabel("Individual extension (edges):");
	individualSelector = new JComboBox<Integer>(DIST);
	individualSelector.setSelectedIndex(AML.getInstance().getIndividualDistance());
	individualPanel = new JPanel();
	individualPanel.add(individualLabel);
	individualPanel.add(individualSelector);

	cancel = new JButton("Cancel");
	cancel.setPreferredSize(new Dimension(70,28));
	cancel.addActionListener(this);
	ok = new JButton("OK");
	ok.setPreferredSize(new Dimension(70,28));
	ok.addActionListener(this);
	buttonPanel = new JPanel();
	buttonPanel.add(cancel);
	buttonPanel.add(ok);
	
	dialogPanel = new JPanel();
	dialogPanel.setPreferredSize(new Dimension(300,150));
	dialogPanel.setLayout(new BoxLayout(dialogPanel, BoxLayout.PAGE_AXIS));
	if(!aml.getLanguageSetting().equals(LanguageSetting.SINGLE))
		dialogPanel.add(languagePanel);
	dialogPanel.add(directionPanel);
	dialogPanel.add(classPanel);
	dialogPanel.add(individualPanel);
	dialogPanel.add(buttonPanel);
	
	add(dialogPanel);
       
       this.pack();
	GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
	int left = g.getCenterPoint().x - (int)(this.getPreferredSize().width / 2);
	this.setLocation(left, 0);
       this.setVisible(true);
}