本文整理了Java中javax.swing.JButton
类的一些代码示例,展示了JButton
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton
类的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
暂无
代码示例来源:origin: skylot/jadx
String name = node.makeLongString();
final JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 3, 0));
panel.setOpaque(false);
label.setIcon(node.getIcon());
final JButton button = new JButton();
button.setIcon(ICON_CLOSE_INACTIVE);
button.setRolloverIcon(ICON_CLOSE);
button.setRolloverEnabled(true);
button.setOpaque(false);
button.setUI(new BasicButtonUI());
button.setContentAreaFilled(false);
button.setFocusable(false);
button.setBorder(null);
button.setBorderPainted(false);
button.addActionListener(e -> closeCodePanel(contentPanel));
panel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
代码示例来源:origin: stanfordnlp/CoreNLP
private void setTsurgeonState(boolean running) {
cancelTsurgeon.setEnabled(running);
runScript.setEnabled(!running);
findMatches.setEnabled(!running);
browseButton.setEnabled(!running);
}
代码示例来源:origin: spotbugs/spotbugs
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.setTitle("Title");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton();
button.setText("Hello, World!");
frame.getContentPane().add(button, BorderLayout.CENTER);
frame.setSize(200, 100);
frame.pack();
frame.setVisible(true);
frame.show();
}
}
代码示例来源:origin: stackoverflow.com
JButton button = new JButton("Do Something");
button.addActionListener( action );
代码示例来源:origin: wiztools/rest-client
@Override
public void setAsIdle() {
jb_request.setIcon(icon_go);
jb_request.setToolTipText(TEXT_GO);
}
代码示例来源:origin: marytts/marytts
private void toggleStopToRecord() {
jButton_Record.setEnabled(true);
jButton_Record.setText("Record");
jButton_Record.setIcon(IconSet.REC_16X16);
this.playingStatus = false;
}
代码示例来源:origin: wildfly/wildfly
public void go() throws Exception {
if(!no_channel && !use_state)
channel.connect(cluster_name);
mainFrame=new JFrame();
mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
panel=new DrawPanel(use_state);
panel.setBackground(background_color);
sub_panel=new JPanel();
mainFrame.getContentPane().add("Center", panel);
clear_button=new JButton("Clear");
clear_button.setFont(default_font);
clear_button.addActionListener(this);
leave_button=new JButton("Leave");
leave_button.setFont(default_font);
leave_button.addActionListener(this);
sub_panel.add("South", clear_button);
sub_panel.add("South", leave_button);
mainFrame.getContentPane().add("South", sub_panel);
mainFrame.setBackground(background_color);
clear_button.setForeground(Color.blue);
leave_button.setForeground(Color.blue);
mainFrame.pack();
mainFrame.setLocation(15, 25);
mainFrame.setBounds(new Rectangle(250, 250));
if(!no_channel && use_state) {
channel.connect(cluster_name, null, state_timeout);
}
mainFrame.setVisible(true);
setTitle();
}
代码示例来源: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: skylot/jadx
version.setAlignmentX(0.5f);
JPanel textPane = new JPanel();
textPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
textPane.setLayout(new BoxLayout(textPane, BoxLayout.PAGE_AXIS));
textPane.add(Box.createRigidArea(new Dimension(0, 10)));
textPane.add(name);
textPane.add(Box.createRigidArea(new Dimension(0, 20)));
JButton close = new JButton(NLS.str("tabs.close"));
close.addActionListener(event -> dispose());
close.setAlignmentX(0.5f);
contentPane.add(textPane, BorderLayout.CENTER);
contentPane.add(close, BorderLayout.PAGE_END);
代码示例来源:origin: apache/shiro
updateValueLabel();
saveButton = new JButton("Save Value");
saveButton.addActionListener(this);
refreshButton = new JButton("Refresh Value");
refreshButton.addActionListener(this);
JPanel valuePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
valuePanel.add(valueField);
valuePanel.add(saveButton);
valuePanel.add(refreshButton);
secureMethod1Button = new JButton("Method #1");
secureMethod1Button.addActionListener(this);
secureMethod2Button = new JButton("Method #2");
secureMethod2Button.addActionListener(this);
secureMethod3Button = new JButton("Method #3");
secureMethod3Button.addActionListener(this);
JPanel methodPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
methodPanel.add(secureMethod3Button);
frame = new JFrame("Apache Shiro Sample Application");
frame.setSize(500, 200);
代码示例来源: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: stackoverflow.com
final JFrame frame = new JFrame("Display Mode");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setUndecorated(true);
JButton btn1 = new JButton("Full-Screen");
btn1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JButton btn2 = new JButton("Normal");
btn2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
panel.add(btn1);
panel.add(btn2);
frame.add(panel);
代码示例来源:origin: stackoverflow.com
public static void main(String args[]){
JFrame f = new JFrame();
f.setLayout(new BorderLayout());
final JPanel p = new JPanel();
p.add(new JLabel("A Panel"));
f.add(p, BorderLayout.CENTER);
//create a button which will hide the panel when clicked.
JButton b = new JButton("HIDE");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
p.setVisible(false);
}
});
f.add(b,BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
private JSpinner gravitySpinner;
private JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
draw = new DrawingArea();
mainPanel.add(draw, BorderLayout.CENTER);
userInt = new JPanel();
mainPanel.add(userInt, BorderLayout.NORTH);
b1 = new JButton("Start");
b2 = new JButton("aaa");
b1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame window = new JFrame("Ball");
window.add(new StartingPoint().getMainPanel());
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.pack();
window.setLocationRelativeTo(null);
window.setVisible(true);
代码示例来源:origin: skylot/jadx
panel.add(makeOtherGroup());
JButton saveBtn = new JButton(NLS.str("preferences.save"));
saveBtn.addActionListener(event -> {
settings.sync();
if (needReload) {
JButton cancelButton = new JButton(NLS.str("preferences.cancel"));
cancelButton.addActionListener(event -> {
JadxSettingsAdapter.fill(settings, startSettings);
dispose();
});
JButton resetBtn = new JButton(NLS.str("preferences.reset"));
resetBtn.addActionListener(event -> {
int res = JOptionPane.showConfirmDialog(
JadxSettingsWindow.this,
String defaults = JadxSettingsAdapter.makeString(JadxSettings.makeDefault());
JadxSettingsAdapter.fill(settings, defaults);
getContentPane().removeAll();
initUI();
pack();
contentPane.add(panel, BorderLayout.CENTER);
contentPane.add(buttonPane, BorderLayout.PAGE_END);
getRootPane().setDefaultButton(saveBtn);
代码示例来源: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: pmd/pmd
private void init() {
JTextArea errorArea = new JTextArea();
errorArea.setEditable(false);
errorArea.setText(exc.getMessage() + "\n");
getContentPane().setLayout(new BorderLayout());
JPanel messagePanel = new JPanel(new BorderLayout());
messagePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory
.createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("COMPILE_ERROR.PANEL.TITLE"))));
messagePanel.add(new JScrollPane(errorArea), BorderLayout.CENTER);
getContentPane().add(messagePanel, BorderLayout.CENTER);
JPanel btnPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
okBtn = new JButton(NLS.nls("COMPILE_ERROR.OK_BUTTON.CAPTION"));
okBtn.addActionListener(this);
btnPane.add(okBtn);
getRootPane().setDefaultButton(okBtn);
getContentPane().add(btnPane, BorderLayout.SOUTH);
pack();
setLocationRelativeTo(getParent());
setVisible(true);
}
代码示例来源:origin: skylot/jadx
@NotNull
protected JPanel initButtonsPanel() {
progressPane = new ProgressPanel(mainWindow, false);
JButton cancelButton = new JButton(NLS.str("search_dialog.cancel"));
cancelButton.addActionListener(event -> dispose());
JButton openBtn = new JButton(NLS.str("search_dialog.open"));
openBtn.addActionListener(event -> openSelectedItem());
getRootPane().setDefaultButton(openBtn);
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
buttonPane.add(progressPane);
buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
buttonPane.add(Box.createHorizontalGlue());
buttonPane.add(openBtn);
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPane.add(cancelButton);
return buttonPane;
}
代码示例来源:origin: skylot/jadx
warnLabel.setVisible(false);
JPanel resultsPanel = new JPanel();
resultsPanel.setLayout(new BoxLayout(resultsPanel, BoxLayout.PAGE_AXIS));
resultsPanel.add(warnLabel);
resultsPanel.add(new JScrollPane(resultsTable,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
resultsInfoLabel = new JLabel("");
JButton nextPageButton = new JButton("->");
nextPageButton.setToolTipText(NLS.str("search_dialog.next_page"));
nextPageButton.addActionListener(e -> {
if (resultsModel.nextPage()) {
switchPage(renderer);
JButton prevPageButton = new JButton("<-");
prevPageButton.setToolTipText(NLS.str("search_dialog.prev_page"));
prevPageButton.addActionListener(e -> {
if (resultsModel.prevPage()) {
switchPage(renderer);
代码示例来源: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!