JButton
Code IndexAdd Codota to your IDE (free)

Best code snippets using javax.swing.JButton(Showing top 20 results out of 4,374)

Refine search

  • Container
  • JFrame
  • Window
  • JPanel
  • AbstractButton
  • Common ways to obtain JButton
private void myMethod () {
JButton j =
  • new JButton()
  • String str;new JButton(str)
  • Smart code suggestions by Codota
}
origin: iluwatar/java-design-patterns

private void setup() {
 setLayout(new BorderLayout());
 JPanel bot = new JPanel();
 add(jt.getTableHeader(), BorderLayout.NORTH);
 bot.setLayout(new BorderLayout());
 bot.add(del, BorderLayout.EAST);
 add(bot, BorderLayout.SOUTH);
 jsp = new JScrollPane(jt);
 jsp.setPreferredSize(new Dimension(500, 250));
 add(jsp, BorderLayout.CENTER);
 del.addActionListener(new DListener());
 JRootPane rootPane = SwingUtilities.getRootPane(del);
 rootPane.setDefaultButton(del);
 setVisible(true);
}
origin: libgdx/libgdx

  public void actionPerformed (ActionEvent event) {
    boolean visible = !highMaxSlider.isVisible();
    highMaxSlider.setVisible(visible);
    highRangeButton.setText(visible ? "<" : ">");
    GridBagLayout layout = (GridBagLayout)formPanel.getLayout();
    GridBagConstraints constraints = layout.getConstraints(highRangeButton);
    constraints.gridx = visible ? 5 : 4;
    layout.setConstraints(highRangeButton, constraints);
    Slider slider = visible ? highMaxSlider : highMinSlider;
    value.setHighMax((Float)slider.getValue());
  }
});
origin: stanfordnlp/CoreNLP

private void buildExtractButton() {
 if (extractButton == null) {
  JPanel buttonPanel = new JPanel();
  extractButton = new JButton("Run NER");
  buttonPanel.add(extractButton);
  frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
  extractButton.addActionListener(actor);
 }
}
origin: stackoverflow.com

 private void makeGUI()
{
  final JFrame f = new JFrame();
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.getContentPane().setLayout(new FlowLayout());

  // include: "class AnswerWorker" code here.
  // include: "JButton" b code here.

  f.getContentPane().add(b);
  f.getContentPane().add(new JButton("Nothing"));
  f.pack();
  f.setVisible(true);
}
origin: log4j/log4j

public LogFactor5ErrorDialog(JFrame jframe, String message) {
 super(jframe, "Error", true);
 JButton ok = new JButton("Ok");
 ok.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
   hide();
  }
 });
 JPanel bottom = new JPanel();
 bottom.setLayout(new FlowLayout());
 bottom.add(ok);
 JPanel main = new JPanel();
 main.setLayout(new GridBagLayout());
 wrapStringOnPanel(message, main);
 getContentPane().add(main, BorderLayout.CENTER);
 getContentPane().add(bottom, BorderLayout.SOUTH);
 show();
}
//--------------------------------------------------------------------------
origin: Konloch/bytecode-viewer

  public void refresh(JButton src) {
    if(!canRefresh) {
      src.setEnabled(true);
      return;
    }
    
    panel2.removeAll();
    try {
      image = ImageIO.read(new ByteArrayInputStream(contents));
    } catch (IOException e) {
      new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
    }
    JLabel label = new JLabel("", new ImageIcon(image), JLabel.CENTER);
    panel2.add( label, BorderLayout.CENTER );
    panel2.updateUI();
    
    src.setEnabled(true);
  }
}
origin: libgdx/libgdx

  private void initializeComponents (String chartTitle) {
    JPanel contentPanel = getContentPanel();
    {
      chart = new Chart(chartTitle) {
        public void pointsChanged () {
          value.setTimeline(chart.getValuesX());
          value.setScaling(chart.getValuesY());
        }
      };
      chart.setPreferredSize(new Dimension(150, 62));
      contentPanel.add(chart, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH,
        new Insets(0, 0, 0, 0), 0, 0));
    }
    {
      expandButton = new JButton("+");
      expandButton.setBorder(BorderFactory.createEmptyBorder(4, 10, 4, 10));
      contentPanel.add(expandButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST,
        GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
    }
  }
}
origin: stanfordnlp/CoreNLP

/**
 * Makes a color choosing button that displays only an icon with a square of the given color
 */
public static JButton makeColorButton(final String promptText, Color iconColor, final JPanel parent) {
 final ColorIcon icon = new ColorIcon(iconColor);
 final JButton button = new JButton(icon);
 button.addActionListener(arg0 -> {
  Color newColor = JColorChooser.showDialog(parent,promptText, icon.getColor());
  if (newColor != null) {
   icon.setColor(newColor);
   parent.repaint();
  }
 });
 return button;
}
origin: libgdx/libgdx

  public void actionPerformed (ActionEvent event) {
    boolean visible = !lowMaxSlider.isVisible();
    lowMaxSlider.setVisible(visible);
    lowRangeButton.setText(visible ? "<" : ">");
    GridBagLayout layout = (GridBagLayout)formPanel.getLayout();
    GridBagConstraints constraints = layout.getConstraints(lowRangeButton);
    constraints.gridx = visible ? 5 : 4;
    layout.setConstraints(lowRangeButton, constraints);
    Slider slider = visible ? lowMaxSlider : lowMinSlider;
    ScaledNumericPanel.this.value.setLowMax(slider.getValue());
  }
});
origin: stackoverflow.com

JFrame frame = new JFrame(){{
    add( new JPanel(){{
       add( new JLabel("Hey there"){{ 
         setBackground(Color.black);
         setForeground( Color.white);
       }});
       add( new JButton("Ok"){{
         addActionListener( new ActionListener(){
           public void actionPerformed( ActionEvent ae ){
             System.out.println("Button pushed");
           }
          });
        }});
   }});
 }};
origin: stanfordnlp/CoreNLP

private void buildExtractButton() {
 if (extractButton == null) {
  JPanel buttonPanel = new JPanel();
  extractButton = new JButton("Extract");
  buttonPanel.add(extractButton);
  frame.add(buttonPanel, BorderLayout.SOUTH);
  extractButton.addActionListener(actor);
 }
}
origin: stanfordnlp/CoreNLP

private void createAndShowGUI() {
 //Make sure we have nice window decorations.
 JFrame.setDefaultLookAndFeelDecorated(true);
 //Create and set up the window.
 frame = new JFrame("Stanford Named Entity Recognizer");
 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 frame.getContentPane().setLayout(new BorderLayout());
 frame.getContentPane().setPreferredSize(new Dimension(WIDTH, HEIGHT));
 frame.setJMenuBar(addMenuBar());
 buildTagPanel();
 buildContentPanel();
 buildExtractButton();
 extractButton.setEnabled(false);
 extract.setEnabled(false);
 //Display the window.
 frame.pack();
 frame.setVisible(true);
}
origin: Konloch/bytecode-viewer

public AllatoriStringDecrypterOptions() {
  this.setIconImages(Resources.iconList);
  setSize(new Dimension(250, 120));
  setResizable(false);
  setTitle("Allatori decrypter");
  getContentPane().setLayout(null);
  JButton btnNewButton = new JButton("Decrypt");
  btnNewButton.setBounds(6, 56, 232, 23);
  getContentPane().add(btnNewButton);
  JLabel lblNewLabel = new JLabel("Class:");
  lblNewLabel.setBounds(6, 20, 67, 14);
  getContentPane().add(lblNewLabel);
  textField = new JTextField();
  textField.setToolTipText("* will search all classes");
  textField.setText("*");
  textField.setBounds(80, 17, 158, 20);
  getContentPane().add(textField);
  textField.setColumns(10);
  
  btnNewButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {
      PluginManager.runPlugin(new AllatoriStringDecrypter(textField.getText()));
      dispose();
    }
  });
  this.setLocationRelativeTo(null);
}
origin: stanfordnlp/CoreNLP

private void buildTagPanel() {
 if (tagPanel == null) {
  tagPanel = new JToolBar(SwingConstants.VERTICAL);
  tagPanel.setFloatable(false);
  frame.getContentPane().add(tagPanel, BorderLayout.EAST);
 } else {
  tagPanel.removeAll();
 }
 if (classifier != null) {
  makeTagMaps();
  Set<String> tags = classifier.labels();
  String backgroundSymbol = classifier.backgroundSymbol();
  for (String tag : tags) {
   if (backgroundSymbol.equals(tag)) { continue; }
   Color color = tagToColorMap.get(tag);
   JButton b = new JButton(tag, new ColorIcon(color));
   tagPanel.add(b);
  }
 }
 tagPanel.revalidate();
 tagPanel.repaint();
}
origin: libgdx/libgdx

  public void actionPerformed (ActionEvent event) {
    chart.setExpanded(!chart.isExpanded());
    boolean expanded = chart.isExpanded();
    GridBagLayout layout = (GridBagLayout)getContentPanel().getLayout();
    GridBagConstraints chartConstraints = layout.getConstraints(chart);
    GridBagConstraints expandButtonConstraints = layout.getConstraints(expandButton);
    if (expanded) {
      chart.setPreferredSize(new Dimension(150, 200));
      expandButton.setText("-");
      chartConstraints.weightx = 1;
      expandButtonConstraints.weightx = 0;
    } else {
      chart.setPreferredSize(new Dimension(150, 62));
      expandButton.setText("+");
      chartConstraints.weightx = 0;
      expandButtonConstraints.weightx = 1;
    }
    layout.setConstraints(chart, chartConstraints);
    layout.setConstraints(expandButton, expandButtonConstraints);
    chart.revalidate();
  }
});
origin: Konloch/bytecode-viewer

this.fcn = fcn;
getContentPane().setLayout(new BorderLayout());
getContentPane().add(tabs, BorderLayout.CENTER);
buttonPanel = new JPanel(new FlowLayout());
refreshClass = new JButton("Refresh");
refreshClass.addActionListener(this);
buttonPanel.add(refreshClass);
buttonPanel.setVisible(false);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
origin: log4j/log4j

super(jframe, title, true);
JPanel bottom = new JPanel();
bottom.setLayout(new FlowLayout());
JPanel main = new JPanel();
main.setLayout(new FlowLayout());
main.add(new JLabel(label));
JButton ok = new JButton("Ok");
ok.addActionListener(new ActionListener() {
 public void actionPerformed(ActionEvent e) {
  hide();
JButton cancel = new JButton("Cancel");
cancel.addActionListener(new ActionListener() {
 public void actionPerformed(ActionEvent e) {
  hide();
bottom.add(ok);
bottom.add(cancel);
getContentPane().add(main, BorderLayout.CENTER);
getContentPane().add(bottom, BorderLayout.SOUTH);
pack();
centerWindow(this);
origin: Konloch/bytecode-viewer

setTitle("Save As Jar..");
JButton btnNewButton = new JButton("Save As Jar..");
btnNewButton.setMaximumSize(new Dimension(999, 23));
btnNewButton.setMinimumSize(new Dimension(999, 23));
btnNewButton.setSize(new Dimension(999, 0));
getContentPane().setLayout(
    new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
getContentPane().add(scrollPane);
mani.setText("Manifest-Version: 1.0\r\nClass-Path: .\r\nMain-Class: ");
scrollPane.setViewportView(mani);
getContentPane().add(btnNewButton);
btnNewButton.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent arg0) {
    BytecodeViewer.viewer.setIcon(true);
origin: libgdx/libgdx

  ((JSpinner.DefaultEditor)((JSpinner)component).getEditor()).getTextField().setColumns(4);
JPanel panel = new JPanel();
getContentPane().add(
  panel,
  new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 0,
JPanel buttonPanel = new JPanel();
getContentPane().add(
  buttonPanel,
  new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
    new Insets(0, 0, 0, 0), 0, 0));
  JButton okButton = new JButton("OK");
  buttonPanel.add(okButton);
  okButton.addActionListener(new ActionListener() {
    public void actionPerformed (ActionEvent evt) {
      okPressed = true;
  JButton cancelButton = new JButton("Cancel");
  buttonPanel.add(cancelButton);
  cancelButton.addActionListener(new ActionListener() {
    public void actionPerformed (ActionEvent evt) {
      setVisible(false);
origin: stackoverflow.com

final JFrame frame = new JFrame("Nested Layout Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JPanel gui = new JPanel(new BorderLayout(5,5));
gui.setBorder( new TitledBorder("BorderLayout(5,5)") );
plafComponents.add(plafChooser);
plafComponents.add(pack);
gui.add(plafComponents, BorderLayout.NORTH);
  new TitledBorder("GridLayout(0,2,3,3)") );
JButton addNew = new JButton("Add Another Label");
dynamicLabels.add( addNew, BorderLayout.NORTH );
addNew.addActionListener( new ActionListener(){
gui.add( splitPane, BorderLayout.CENTER );
frame.setContentPane(gui);
frame.pack();
frame.setLocationRelativeTo(null);
javax.swingJButton

Most used methods

  • <init>
  • addActionListener
  • setEnabled
  • setText
  • setToolTipText
  • setIcon
  • setActionCommand
  • setPreferredSize
  • setVisible
  • setBorder
  • addMouseListener
  • getAccessibleContext
  • addMouseListener,
  • getAccessibleContext,
  • getPreferredSize,
  • setMargin,
  • setBorderPainted,
  • setMnemonic,
  • isEnabled,
  • doClick,
  • setFocusable,
  • setBounds

Popular classes and methods

  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • startActivity (Activity)
  • getExternalFilesDir (Context)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • BitSet (java.util)
    This implementation uses bit groups of size 32 to keep track of when bits are set to true or false.
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • JComboBox (javax.swing)
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i

For IntelliJ IDEA,
Android Studio or Eclipse

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)