关于事件监听的问题 急 大家帮忙看看 谢谢 我想写一个 点击 按钮 然后 跳转另外一个页面的事件该怎么写?我是新手!麻烦大家帮帮忙 解决方案 » 免费领取超大流量手机卡,每月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读取网页的更新时间? 请问多线程中怎么实现两种方法比较? 怎么在GUI实现文件树 小问题 Swing高手请进!!!!!!!!! 送分:JAVA如何显示中文?(WINDOWS平台) 如何用Java建立基于推技术的聊天室???各位高手请帮忙!!! 用java开发数据库也用ado么 小弟初学,请指教,我对数据封装不太明白! 【100分】Linux下面,JBOSS的项目,总是无法利用getProperty(),获取属性值!救命啊! 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);
}
}