如何点了jbutton退出按钮就退出java程序

来源:百度知道 编辑:UC知道 时间:2024/05/21 19:50:38
package mypack;

import java.awt.Color;
import java.awt.Font;

import javax.swing.JButton;
import javax.swing.JDialog;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;

//VS4E -- DO NOT REMOVE THIS LINE!
public class DDDDDDD extends JDialog {

private static final long serialVersionUID = 1L;
private JButton jButton0;
private static final String PREFERRED_LOOK_AND_FEEL = "javax.swing.plaf.metal.MetalLookAndFeel";

public DDDDDDD() {
initComponents();
}

private void initComponents() {
setFont(new Font("Dialog", Font.PLAIN, 12));
setBackground(Color.white);
setForeground(Color.black);
setLayout(new GroupLayout());
add(getJButton0(), new Constraints(new Leading(103, 115, 10, 10), new Leading(63, 75, 10, 10)));
s

jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
});

performed方法名字写错了!~

加一句System.exit(0)就行。

jButton0.addActionListener(
new ActionListener(){
public void performed(ActionEvent event) {
System.exit(0);
}
}
);

在getJButton0的最后添加上面的代码