SWT/AWT的问题:怎样在listener中访问其他控件? 其他的也没几行,主要的代码就是这些了!是不是我必须要把label声明为final啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 label.setBounds (shell.getClientArea ()); 你的这些代码是不是写在STATIC方法内的?如果是你的LABALE要定义成FINAL 我给你个简单的代码:这是第一种方法:public class myframe extends Frame{ …… TextFiled txt; Button bon; …… myframe() { …… txt = new TextFiled(10); bon = new Button("OK"); bon.addActionListener(action); }; ……}class action implements ActionListener { TextFiled text; action(TextFiled t) { text = t; } public void AcitonPerformed(ActionEvent e) { text.setText("Ok!"); }}这是第二种方法:public class myframe extends Frame{ …… TextFiled txt; Button bon; …… myframe() { …… txt = new TextFiled(10); bon = new Button("OK"); bon.addActionListener(action); }; …… class action implements ActionListener //这个就称为内部类! { public void AcitonPerformed(ActionEvent e) { txt.setText("Ok!"); } }} JPCAP 反转IP问题 求eclipse的下载地址? char型向String转换不需要写.ToString? 小弟请教:Java在windows下如何将汉字输出到.txt?先谢了 我用J2SE写了个小游戏 这么把他弄成可执行程序拿给别人玩啊? 掌握了java的基本语法之后,怎样继续学下去? 关于JAVA读取文件属性的问题 搜索端口出现异常并无法继续 介绍几本 JAVA 安全的教程下载吧! java画板项目问题求老哥们解答 jButton1按钮事件里try{}catch(这里怎么写){} 哪里有JAVA-API 的下载?最好是.zip 格式的!
这是第一种方法:public class myframe extends Frame
{
……
TextFiled txt;
Button bon;
……
myframe()
{
……
txt = new TextFiled(10);
bon = new Button("OK");
bon.addActionListener(action);
};
……
}
class action implements ActionListener
{
TextFiled text;
action(TextFiled t)
{
text = t;
}
public void AcitonPerformed(ActionEvent e)
{
text.setText("Ok!");
}
}这是第二种方法:
public class myframe extends Frame
{
……
TextFiled txt;
Button bon;
……
myframe()
{
……
txt = new TextFiled(10);
bon = new Button("OK");
bon.addActionListener(action);
};
……
class action implements ActionListener //这个就称为内部类!
{
public void AcitonPerformed(ActionEvent e)
{
txt.setText("Ok!");
}
}
}