package _1;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class SwingFrame extends JFrame{
private JButton button=new JButton("按键");
public SwingFrame()
{
setSize(300,300);
setLocation(400,400);
setTitle("ButtonFrame");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
//添加按键事件
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
JOptionPane.showMessageDialog(null,"点击了按键");
}
});
add(button);
}
public static void main(String[]args) {
SwingFrame frame=new SwingFrame();
frame.setVisible(true);
}
}
1577

被折叠的 条评论
为什么被折叠?



