本文整理了Java中javax.swing.JButton.<init>()
方法的一些代码示例,展示了JButton.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.<init>()
方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:<init>
暂无
代码示例来源: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: 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: 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: 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: spotbugs/spotbugs
public BadlyOverriddenAdapterTest() {
addWindowListener(new WindowAdapter() {
@SuppressWarnings("DM_EXIT")
@ExpectWarning("BOA")
public void windowClosing() {
dispose();
System.exit(0);
}
});
Container cp = getContentPane();
cp.add(new JButton("Click Me"));
}
}
代码示例来源: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: stackoverflow.com
import java.awt.event.*;
import javax.swing.*;
public class YourDialog extends JDialog implements ActionListener {
JButton button;
public YourDialog() {
button = new JButton("Close");
button.addActionListener(this);
add(button);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
dispose();
}
}
代码示例来源: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);
frame = new JFrame("Apache Shiro Sample Application");
frame.setSize(500, 200);
panel.add(logo, BorderLayout.NORTH);
panel.add(valuePanel, BorderLayout.CENTER);
panel.add(methodPanel, BorderLayout.SOUTH);
代码示例来源: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: plantuml/plantuml
private JComponent getSouthLabel() {
final JPanel result = new JPanel();
final JButton ok = new JButton("OK");
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
dispose();
}
});
result.add(ok);
return result;
}
代码示例来源:origin: chewiebug/GCViewer
protected void initComponents() {
Panel buttonPanel = new Panel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
JButton okButton = new JButton(LocalisationHelper.getString("button_ok"));
okButton.setActionCommand(ACTION_OK);
okButton.addActionListener(this);
buttonPanel.add(okButton);
getContentPane().add("South", buttonPanel);
}
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame("test");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel panel = new JPanel(new GridLayout(4,4,4,4));
for(int i=0 ; i<16 ; i++){
JButton btn = new JButton(String.valueOf(i));
btn.setPreferredSize(new Dimension(40, 40));
panel.add(btn);
}
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
代码示例来源: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
JButton btn2 = new JButton("Normal");
btn2.addActionListener(new ActionListener() {
@Override
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
panel.add(btn1);
panel.add(btn2);
代码示例来源:origin: gocd/gocd
private void createView() {
JPanel controlsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10));
serverTextField = new JTextField("");
serverTextField.setColumns(15);
serverTextField.selectAll();
JPanel textPanel = new JPanel(new GridLayout(4, 2, 0, 10));
textPanel.add(new JLabel("Go Server Hostname or IP"));
textPanel.add(serverTextField);
textPanel.add(new JLabel("SSL Mode"));
sslModeComponent = new SslModeComponent();
textPanel.add(sslModeComponent);
textPanel.add(new JLabel("Server root certificate"));
fileBrowser = new FileBrowser();
textPanel.add(fileBrowser);
controlsPanel.add(textPanel);
getContentPane().add(controlsPanel, BorderLayout.NORTH);
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10));
okButton = new JButton("OK");
buttonPanel.add(okButton);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
}
代码示例来源:origin: plantuml/plantuml
private JComponent getSouthLabel() {
final JPanel result = new JPanel();
final JButton license = new JButton("License");
license.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
new LicenseWindow();
}
});
final JButton ok = new JButton("OK");
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
dispose();
}
});
result.add(license);
result.add(ok);
return result;
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
public RouteDialog(JFrame owner, String initialFrom) {
super(owner, true);
fromField = new JTextField(initialFrom, 30);
toField = new JTextField(30);
goButton = new JButton("Go");
Container pane = getContentPane();
pane.setLayout(new BoxLayout(pane, BoxLayout.PAGE_AXIS));
pane.add(new JLabel("From"));
pane.add(fromField);
pane.add(new JLabel("To"));
pane.add(toField);
pane.add(goButton);
pack();
final RouteDialog outer = this;
goButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
from = fromField.getText().trim();
to = toField.getText().trim();
outer.setVisible(false);
}
});
setVisible(true);
}
}
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame("Colored Trails");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
JPanel firstPanel = new JPanel();
firstPanel.setLayout(new GridLayout(4, 4));
firstPanel.setMaximumSize(new Dimension(400, 400));
for (int i=1; i<=4; i++) {
for (int j=1; j<=4; j++) {
btn = new JButton();
btn.setPreferredSize(new Dimension(100, 100));
firstPanel.add(btn);
JPanel secondPanel = new JPanel();
secondPanel.setLayout(new GridLayout(5, 13));
secondPanel.setMaximumSize(new Dimension(520, 200));
for (int i=1; i<=5; i++) {
for (int j=1; j<=13; j++) {
btn = new JButton();
btn.setPreferredSize(new Dimension(40, 40));
secondPanel.add(btn);
代码示例来源: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) {
JButton cancel = new JButton("Cancel");
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
getContentPane().add(main, BorderLayout.CENTER);
getContentPane().add(bottom, BorderLayout.SOUTH);
pack();
centerWindow(this);
代码示例来源:origin: stanfordnlp/CoreNLP
private JPanel makeTSurgeonButtons() {
JPanel tsurgeonButtonBox = new JPanel();
tsurgeonButtonBox.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
tsurgeonButtonBox.setLayout(new GridBagLayout());
tsurgeonHelp = new JButton("Help");
tsurgeonHelp.addActionListener(this);
cancelTsurgeon = new JButton("Cancel");
cancelTsurgeon.addActionListener(this);
runScript = new JButton("Run script");
runScript.addActionListener(this);
//make constraints and add in
GridBagConstraints c = new GridBagConstraints();
c.anchor = GridBagConstraints.NORTHEAST;
c.fill = GridBagConstraints.HORIZONTAL;
tsurgeonButtonBox.add(runScript,c);
tsurgeonButtonBox.add(cancelTsurgeon,c);
tsurgeonButtonBox.add(tsurgeonHelp,c);
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1.0;
c.weighty = 1.0;
tsurgeonButtonBox.add(new JLabel(), c);
return tsurgeonButtonBox;
}
//separated out to make constructor more readable
代码示例来源:origin: spotbugs/spotbugs
public GoodlyOverridenAdapterTest() {
addWindowListener(new WindowAdapter() {
@NoWarning("BOA")
public void windowClosing() {
dispose();
System.exit(0);
}
@Override
@NoWarning("BOA")
public void windowClosing(WindowEvent we) {
windowClosing();
}
});
Container cp = getContentPane();
cp.add(new JButton("Click Me"));
}
}
内容来源于网络,如有侵权,请联系作者删除!