我创建了一个button对象,并设置了选择监听接口,事件响应的效果是将这个按钮本身删除
可以用什么方法实现?
谢谢
可以用什么方法实现?
谢谢
解决方案 »
- double*double问题
- Socket类中connect(SocketAddress endpoint) 方法是干什么用的?
- 用java怎么才能通过串口收发短消息啊!急啊!
- J2SE问题
- 不是说抽象类不能实例化吗?为什么这里可以。
- 如何做出登陆时的那个滚动框,就是向登陆其他一些网站或登陆系统一样,输入用户名跟密码后出现的那个缓冲框!!!还有怎样使多行文本框(JTextArea)不能直接写入,就像QQ显示聊天内容的一样!!
- 在java中,对象一般都是在堆上创建的,那class对象呢?它也在堆上创建吗?
- 请教一个简单的局部变量问题
- jsdk1.4下的问题,简单问题。
- 高分求Applet中用jar的问题
- 请教一个问题
- 线程有啥用?
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*//**
*
* @author Administrator
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class NewClass {
JFrame frame;
Container contentPane;
JButton bun[];
public NewClass(){
frame=new JFrame();
frame.setSize(400,400);
contentPane=frame.getContentPane();
contentPane.setLayout(new FlowLayout());
bun=new JButton[10];
for(int i=0;i<10;i++){
bun[i]=new JButton(""+i);
bun[i].addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JButton b=(JButton)e.getSource();
//删除组件
contentPane.remove(b);
contentPane.validate();
}
});
contentPane.add(bun[i]);
}
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public static void main(String args[]){
new NewClass();
}
}
public void remove(Component c)
Removes the specified component from this container.
要删除的button我调用了dispose方法,能实现按钮不见,同时我在监听函数中还调用了另一个函数,功能是在另外一块区域布局按钮,但是函数的功能总是没实现,是不是button已经dispose了,监听函数的生命期结束了,其中包含的函数也得不到执行?