求救!如何实现在jbutton单击事件中改变jbutton本身的值??(在线给分,谢谢) button1.addActionListener(new ActionListener() { public void actionPerformed() { button1.setText("thanks"); }}); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼上,12个Jbutton,我如何才能获得他的操作权呢,我没有定义过button1 void jButton1_actionPerformed(ActionEvent e) {jButton1.setText("aaaaaaaaaaaaaa"); }你说得是这个吗? private JButton jButton1 = new JButton();jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); }void jButton1_actionPerformed(ActionEvent e) {jButton1.setText("aaaaaaaaaaaaaa"); }这样就可以了吧!! public class Subblood extends JPanel { public Subblood(){ this.setLayout(new FlowLayout(FlowLayout.LEFT,40,25)); for(int i=1;i<=12;i++){ JButton b=new JButton("guess me"); b.addActionListener(new ActionListener() { public void actionPerformed() { button1.setText("thanks"); } } ); this.add(b); } this.setPreferredSize(new Dimension(500,200)); } public class Subblood extends JPanel { public Subblood(){ this.setLayout(new FlowLayout(FlowLayout.LEFT,40,25)); for(int i=1;i<=12;i++){ JButton jb=new JButton("guess me"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JButton temp=(JButton)e.getSource(); temp.setText("thanks"); } }); this.add(jb); } this.setPreferredSize(new Dimension(500,200)); } Java udp如何通过一个对象完成接收和发送数据 请问如何用Math类里的方法会一个圆 sos FTPClient实现多线程下载单一文件时遇到的问题 *求最好方法*循环读取每行数据,判断第一个字符是否数字分别写入不同文本 递归调用时随机数异常,是不是bug? 紧急求助一个奇怪的问题 ^_^小弟急需cobol中文基础学习资料.哪位仁兄收藏.请帮个忙.不胜感激! 谁有 JBulider 的文档资料(尤其是入门资料)?我只有这些分了 靠。都到第二页了也没人回答。加分翻倍!! Applet打开网页的问题? 最少有200分!
jButton1.setText("aaaaaaaaaaaaaa"); }你说得是这个吗?
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
}
void jButton1_actionPerformed(ActionEvent e) {
jButton1.setText("aaaaaaaaaaaaaa");
}
这样就可以了吧!!
public Subblood(){
this.setLayout(new FlowLayout(FlowLayout.LEFT,40,25));
for(int i=1;i<=12;i++){
JButton b=new JButton("guess me");
b.addActionListener(new ActionListener() {
public void actionPerformed() {
button1.setText("thanks");
}
}
);
this.add(b);
}
this.setPreferredSize(new Dimension(500,200)); }
public Subblood(){
this.setLayout(new FlowLayout(FlowLayout.LEFT,40,25));
for(int i=1;i<=12;i++){
JButton jb=new JButton("guess me");
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JButton temp=(JButton)e.getSource();
temp.setText("thanks");
}
});
this.add(jb);
}
this.setPreferredSize(new Dimension(500,200)); }