读书人

小弟我如果想给一个按钮加一个点击时间

发布时间: 2012-02-15 12:09:44 作者: rapoo

我如果想给一个按钮加一个点击时间,要怎么写代码呢?
rt

[解决办法]
Button bu = new Button( "按我 ");
bu.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
System.out.println(((Button)e.getSource()).getLabel());
}



});
[解决办法]
在文本框后面追加文字,不删除原来的文字

StringBuffer textInfo=new StringBuffer(text.getText());
textInfo.append( "想追加的文字 ");
text.setText(textInfo.toString());

读书人网 >J2SE开发

热点推荐