求救!如何实现在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)); } 关于打包jar后部分代码段失效的问题,具体的大侠里面请 B/S C/S 正则表达式的使用 Java中void方法的异常处理 java ResultSet问题请各位帮帮忙啊 0.2*0.2*0.2=多少 为什么 在线等 散分 关于liunix下找不到配置文件的问题 【JAVA】【张孝祥Java视频教程】 在java中有没有数据库控件,例如jdbTable,但是是以ResultSet作为参数? 中文JAVA技术网正式成为共创软件联盟成员网站 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)); }