关于JButton的问题 按钮能发生windowEvent吗,如果不能,我怎么设置一个按钮,当我点击时关闭窗口。最好给个实例。谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;public class DD extends JFrame{ private static final long serialVersionUID = -4158802804225659503L; public static void main(String args[]) { try { DD frame = new DD(); frame.setVisible(true); } catch(Exception e) { e.printStackTrace(); } } public DD() { super(); getContentPane().setLayout(null); setBounds(100, 100, 500, 375); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton(); button.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { DD.this.dispose(); } }); button.setText("Close"); button.setBounds(120, 168, 106, 28); getContentPane().add(button); }} 借楼主的贴顺便也问个问题想点击这个按钮后 再打开一个界面 怎么写啊b1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { } });谁帮我写个例子 actionPerformed里加上.nf frame = new frame{super(); getContentPane().setLayout(null); setBounds(100, 100, 500, 375); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton(); button.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { DD.this.dispose(); } }); button.setText("Close"); button.setBounds(120, 168, 106, 28); getContentPane().add(button); }}} Comparator排序题 PriorityQueue的方法求助 新来的! 那就免费问一个很幼稚的问题! 求一个正则表达式,提取html里的标签,谢谢 装过一次NetBeans 卸掉以后,再装就装不了了? 谁能介绍一个好的界面开发工具 基本数据类型的比较问题 请教数据库连接的速度问题 求救关于sfv结尾的的文件 请问怎么才能把tomcat 3.2做成NT服务? 这里有人是从.net转过来的吗? 谁有Clover.ETL中文资料
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;public class DD extends JFrame
{
private static final long serialVersionUID = -4158802804225659503L; public static void main(String args[])
{
try
{
DD frame = new DD();
frame.setVisible(true);
}
catch(Exception e)
{
e.printStackTrace();
}
} public DD()
{
super();
getContentPane().setLayout(null);
setBounds(100, 100, 500, 375);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton();
button.addActionListener(new ActionListener()
{
public void actionPerformed(final ActionEvent e)
{
DD.this.dispose();
}
});
button.setText("Close");
button.setBounds(120, 168, 106, 28);
getContentPane().add(button);
}
}
想点击这个按钮后 再打开一个界面 怎么写啊b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent arg0)
{
}
});
谁帮我写个例子
nf frame = new frame
{super();
getContentPane().setLayout(null);
setBounds(100, 100, 500, 375);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton();
button.addActionListener(new ActionListener()
{
public void actionPerformed(final ActionEvent e)
{
DD.this.dispose();
}
});
button.setText("Close");
button.setBounds(120, 168, 106, 28);
getContentPane().add(button);
}
}
}