java dispose非静态_Java开发网 - dispose()不能释放内存
Posted by:shaneangelPosted on:2003-03-22 16:36import javax.swing.JLabel;import javax.swing.JTextField;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.
Posted by:shaneangel
Posted on:2003-03-22 16:36
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import java.awt.event.*;
import java.awt.*;
public class LoginFrame extends JFrame {
LoginFrame loginFrame= null;
public LoginFrame() {
loginFrame = this;
setTitle("登录窗口");
setSize(WIDTH,HEIGHT);
LoginPanel panel = new LoginPanel();
Container contentPane = getContentPane();
contentPane.setLayout(new GridLayout());
contentPane.add("Center",panel);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(350,250,250,100);
setResizable(false);
show();
}
class LoginPanel extends JPanel {
public LoginPanel() {
userLbl = new JLabel("输入用户名:");
passwordLbl = new JLabel("输入密码:");
userTxt = new JTextField(15);
passwordTxt = new JPasswordField(15);
yesBtn = new JButton("确定");
noBtn = new JButton("退出");
yesBtn.setBounds(10,10,5,10);
setLayout(new GridLayout(3,2));
add(userLbl);add(userTxt);
add(passwordLbl);add(passwordTxt);
add(yesBtn);add(noBtn);
yesBtn.addActionListener(new
ActionListener() {
public void actionPerformed(ActionEvent event) {
}
});
noBtn.addActionListener(new
ActionListener() {
public void actionPerformed(ActionEvent event) {
MainFrame frame = new MainFrame();
loginFrame.dispose();
}
});
}
private JLabel userLbl;
private JLabel passwordLbl;
private JTextField userTxt;
private JTextField passwordTxt;
private JButton yesBtn;
private JButton noBtn;
}
private static final int WIDTH=300;
private static final int HEIGHT=120;
}
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)