package Java_project_1;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Test{
public static void main(String[] args) {
JFrame win=new JFrame("登陆界面");
JPanel panel=new JPanel();
win.add(panel);
JButton btn=new JButton("登录");
// btn.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// JOptionPane.showMessageDialog(win,"点击操作");
// }
// });
btn.addActionListener(e->JOptionPane.showMessageDialog(win,"点击"));
panel.add(btn);
win.setSize(400,300);
win.setLocationRelativeTo(null);
win.setVisible(true);
}
}
匿名内部类在开发中的真实使用场景演示
于 2022-10-17 16:00:02 首次发布