import javax.swing.AbstractButton;
import javax.swing.JFrame;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
@SuppressWarnings("serial")
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());
AbstractButton buttoon;
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);
}
}
java 小窗
最新推荐文章于 2022-05-22 11:15:00 发布