基础内容结束,存档

This commit is contained in:
2025-08-28 07:31:15 +08:00
parent 32825e5512
commit 6afcf58b15
2 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
package class44;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class LoginFarme extends JFrame implements ActionListener {
public LoginFarme()
{
this.setTitle("登录界面");
this.setSize(400,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
init();
}
private void init()
{
JPanel panel = new JPanel();
this.add(panel);
JButton btn = new JButton("登陆");
btn.addActionListener(this);
panel.add(btn);
}
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(this,"点击了登陆按钮");
}
}

10
src/class44/Test.java Normal file
View File

@@ -0,0 +1,10 @@
package class44;
public class Test {
public static void main(String[] args) {
// 自定义窗口
LoginFarme lf = new LoginFarme();
lf.setVisible(true);
}
}