Java 8 JButton - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JButton class.

This code example shows how to use the following methods:addActionListener, setActionCommand, setText, setToolTipText
            + "<p>in the selected project folder without creating a backup of the original files.</p>" 
            + "</html>"); 
  } 
 
  private void createMigrateButton() { 
    migrateButton = new JButton();
    migrateButton.setText("Migrate Project to SLF4J");
    migrateButton
        .setToolTipText("Click this button to initiate migration of your project.");
    migrateButton.addActionListener(this);
    migrateButton.setActionCommand(MIGRATE_COMMAND);
  } 
 
  private void createFileChooser() { 
    fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Source folder selector");
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  } 
 
  private void createProgressBar() { 
7
CodeRank
This code example shows how to use the following methods:addActionListener, setActionCommand, setFont
 
    private final JTextField filename = new JTextField(10);
 
    private final JLabel label;
 
    private final JButton browse = new JButton(JMeterUtils.getResString("browse")); //$NON-NLS-1$
 
    private static final String ACTION_BROWSE = "browse"; //$NON-NLS-1$
 
    private final List<ChangeListener> listeners = new LinkedList<ChangeListener>();
 
    private final String[] filetypes;
 
    // Mainly needed for unit test Serialisable tests 
    public FilePanelEntry() { 
        this(JMeterUtils.getResString("file_visualizer_filename")); //$NON-NLS-1$ 
    } 
 
    public FilePanelEntry(String label) {
        this(label, (ChangeListener) null);

7
CodeRank
This code example shows how to use the following methods:addActionListener, setBorderPainted, setPreferredSize, setToolTipText
   */ 
  public CloseButton(String toolTipText) {
    super(new FlowLayout(FlowLayout.LEFT, 0, 0));
    setOpaque(false);
    ImageIcon closeIcon = Icons.getClose();
    JButton button = new JButton(closeIcon);
    button.setBorderPainted(false);
    button.setPreferredSize(new Dimension(closeIcon.getIconWidth(),
        closeIcon.getIconHeight()));
    if (toolTipText != null) {
      button.setToolTipText(toolTipText);
    } 
    add(button);
    button.addActionListener(new ActionListener() {
      @Override 
      public void actionPerformed(ActionEvent e) {
        if (callback != null) {
          callback.onCloseRequest();
        } 
      } 
7
CodeRank
This code example shows how to use the following methods:addActionListener, setActionCommand, setEnabled, setMnemonic
        panel.add(createButtonPanel(), BorderLayout.SOUTH);
        return panel;
    } 
 
    private JButton createButton(String resName, char mnemonic, String command, boolean enabled) {
        JButton button = new JButton(JMeterUtils.getResString(resName));
        button.setMnemonic(mnemonic);
        button.setActionCommand(command);
        button.setEnabled(enabled);
        button.addActionListener(this);
        return button;
    } 
 
    private JPanel createButtonPanel() {
        boolean tableEmpty = (tableModel.getRowCount() == 0);
 
        addButton = createButton("add", 'A', ADD_COMMAND, true); //$NON-NLS-1$
        deleteButton = createButton("delete", 'D', DELETE_COMMAND, !tableEmpty); //$NON-NLS-1$
        
        // Button Panel 
6
CodeRank
This code example shows how to use the following methods:getFont, addActionListener, setActionCommand, setFont
This code example shows how to use the following methods:addActionListener, setActionCommand, setToolTipText
cancelButton = new JButton("Cancel");
		cancelButton.setToolTipText("Close and dispose.");
		cancelButton.addActionListener(this);
		cancelButton.setActionCommand(""+CANCEL);
		saveButton = new JButton("Save");
		saveButton.setToolTipText("Save the changes.");
		saveButton.addActionListener(this);
		saveButton.setActionCommand(""+SAVE);
		getRootPane().setDefaultButton(saveButton);
	} 
	 
	/**  
	 * Builds and lays out the buttons. 
	 *  
	 * @return See above. 
	 */ 
	private JPanel buildToolBar()
	{ 
		JPanel bar = new JPanel();
6
CodeRank
This code example shows how to use the following methods:addActionListener, setActionCommand
 
    private final JTextField filename = new JTextField(20);
 
    private final JLabel label = new JLabel(JMeterUtils.getResString("file_visualizer_filename")); // $NON-NLS-1$
 
    private final JButton browse = new JButton(JMeterUtils.getResString("browse")); // $NON-NLS-1$
 
    private final List<ChangeListener> listeners = new LinkedList<ChangeListener>();
 
    private final String title;
 
    private final String filetype;
 
    /** 
     * Constructor for the FilePanel object. 
     */ 
    public ReportFilePanel() { 
        this(""); // $NON-NLS-1$ 
    } 
 

6
CodeRank
This code example shows how to use the following methods:addActionListener, setActionCommand, setEnabled
 
        add(mainPanel, BorderLayout.CENTER);
    } 
 
    private JPanel createControls() {
        start = new JButton(JMeterUtils.getResString("start")); // $NON-NLS-1$
        start.addActionListener(this);
        start.setActionCommand(ACTION_START);
        start.setEnabled(true);
 
        stop = new JButton(JMeterUtils.getResString("stop")); // $NON-NLS-1$
        stop.addActionListener(this);
        stop.setActionCommand(ACTION_STOP);
        stop.setEnabled(false);
 
        JPanel panel = new JPanel();
        panel.add(start);
        panel.add(stop);
        return panel;
    } 
6
CodeRank
This code example shows how to use the following methods:addActionListener, setEnabled, setMnemonic
 
  /** the textarea for the query. */ 
  protected JTextArea m_TextQuery;
 
  /** the execute button. */ 
  protected JButton m_ButtonExecute = new JButton("Execute");
 
  /** the clear button. */ 
  protected JButton m_ButtonClear = new JButton("Clear");
 
  /** the history button. */ 
  protected JButton m_ButtonHistory = new JButton("History...");
 
  /** the spinner for the maximum number of rows. */ 
  protected JSpinner m_SpinnerMaxRows = new JSpinner();
 
  /** the connection listeners. */ 
  protected HashSet m_QueryExecuteListeners;
 
  /** the history listeners. */ 

6
CodeRank
This code example shows how to use the following methods:addActionListener, setActionCommand

Related Java 8 JButton Questions & Answers:

See Code Examples for Java 8 JButton Methods: