弹出窗口问题(拜托个位高人了,急!!!) 使用监听事件,有两个界面A和B,当单击A中的一个按扭时,弹出界面B,切界面A不见,那个监听事件怎么写? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 package com.ddpie.frame;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;public class TestFrameSwitch { public static void main(String[] args) { final JFrame frameA = new JFrame("窗口A"); final JFrame frameB = new JFrame("窗口B"); JButton buttonA = new JButton("切换成窗口B"); JButton buttonB = new JButton("切换成窗口A"); frameA.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER,0,0)); frameB.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER,0,0)); frameA.getContentPane().add(buttonA); frameB.getContentPane().add(buttonB); frameA.setSize(300, 200); frameB.setSize(600, 600); frameA.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frameB.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frameA.setVisible(true); buttonA.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { frameA.setVisible(false); frameB.setVisible(true); } }); buttonB.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { frameB.setVisible(false); frameA.setVisible(true); } }); }} 如果是两个panel切换可以考虑用CardLayout 对于这种情况 建议写两个单独的Frame类 不要写在一个类中 添加功能时会很乱 也难后期修改 一般来说,一个Frame就应该是一个类 jsp中如何返回一个对象 ubuntu 8.04(英文版)eclipse 3.4.2(英文版) 图形用户界面(比如JCheckBox中)中文乱码 高手请进,帮我注释下代码,我已经考虑了N天了。不懂。 java 关于停止按钮的实现 j2se中SWT高手请进! 求高手指点 如何把本机的屏幕的一切事件通过SOCKET传输到远程终端! 一个applet网络通讯的问题,救救我吧!!! linux下Java调用其他程序 急急急,初级问题~~~~~~~~~~~~~ java高手请进,一个问题 致JAVA初学者+如何下手学JAVA [精华] 关于SWT的,请懂的大虾教教小弟
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;public class TestFrameSwitch {
public static void main(String[] args) {
final JFrame frameA = new JFrame("窗口A");
final JFrame frameB = new JFrame("窗口B");
JButton buttonA = new JButton("切换成窗口B");
JButton buttonB = new JButton("切换成窗口A");
frameA.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER,0,0));
frameB.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER,0,0));
frameA.getContentPane().add(buttonA);
frameB.getContentPane().add(buttonB);
frameA.setSize(300, 200);
frameB.setSize(600, 600);
frameA.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frameB.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frameA.setVisible(true);
buttonA.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
frameA.setVisible(false);
frameB.setVisible(true);
}
});
buttonB.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
frameB.setVisible(false);
frameA.setVisible(true);
}
});
}}