关于事件监听的问题 急 大家帮忙看看 谢谢 我想写一个 点击 按钮 然后 跳转另外一个页面的事件该怎么写?我是新手!麻烦大家帮帮忙 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 XXClass extends JFrame implements ActionListener{JButton XXButton;public void init(){XXButton = new JButton("AButton");XXButton.addActionListener(this);//注册监听}public void actionPerformed(ActionEvent e){//点击事件if(e.getActionCommand().equals("AButton")){....}}} import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;public class SwitchFrame extends JFrame implements ActionListener{ /** * @param args */ JButton bt; public SwitchFrame() { super("Frame1"); setSize(100,100); this.setDefaultCloseOperation(EXIT_ON_CLOSE); bt = new JButton("跳转"); bt.addActionListener(this); this.setLayout(new FlowLayout()); add(bt); setVisible(true); } public static void main(String[] args) { // TODO Auto-generated method stub new SwitchFrame(); } @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub Object source = e.getSource(); if(source == bt) { this.setVisible(false); new Frame2(); } }}import javax.swing.JFrame;public class Frame2 extends JFrame{ public Frame2() { super("Frame2"); setSize(200,200); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setVisible(true); }} 各位大牛,如何在JAVA里面实现倒排表 finalize()方法什么时候执行? Applet访问客户端的文件 对象和实例的区别理解 关于JAVA的FLOAT类型和DOUBLE类型 得到一个DefaultMutableTreeNode对象,怎么让JTree展开到该节点 请问关于路径设置的问题 大家写java都用什么IDE或编辑器? java与数据库 初学者对于多线程服务器程序的几点疑问??? getInputStream导致的jvm崩溃,高手帮忙看看应该怎么修改? java下改变字体无效????求高人解决
JButton XXButton;
public void init(){
XXButton = new JButton("AButton");
XXButton.addActionListener(this);//注册监听
}public void actionPerformed(ActionEvent e){//点击事件
if(e.getActionCommand().equals("AButton")){
....
}
}
}
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class SwitchFrame extends JFrame implements ActionListener{ /**
* @param args
*/
JButton bt;
public SwitchFrame() {
super("Frame1");
setSize(100,100);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
bt = new JButton("跳转");
bt.addActionListener(this);
this.setLayout(new FlowLayout());
add(bt);
setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new SwitchFrame();
} @Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Object source = e.getSource();
if(source == bt) {
this.setVisible(false);
new Frame2();
}
}
}import javax.swing.JFrame;public class Frame2 extends JFrame{
public Frame2() {
super("Frame2");
setSize(200,200);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
}
}