提示找不到setAsetBclass CFrame extends JFrame
{
public CFrame()
{
setSize(500,500);
JButton aButton = new JButton ("a");
JButton bButton = new JButton ("b");
c = new CComponent();
c.add(aButton);
c.add(bButton);
add(c); aButton.addActionListener(EventHandler.create(ActionListener.class,c,"setA"));
bButton.addActionListener(EventHandler.create(ActionListener.class,c,"setB"));
}
private CComponent c;
}class CComponent extends JPanel
{
public CComponent ()
{
text_CComponent="Defualt";
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.drawString(text_CComponent, 20, 20);
}
public void setText(String text_Temp_CC)
{
text_CComponent=text_Temp_CC;
repaint();
}
public void setA()
{
setText("a");
}
public void setB()
{
setText("b");
}
private String text_CComponent;
}
{
public CFrame()
{
setSize(500,500);
JButton aButton = new JButton ("a");
JButton bButton = new JButton ("b");
c = new CComponent();
c.add(aButton);
c.add(bButton);
add(c); aButton.addActionListener(EventHandler.create(ActionListener.class,c,"setA"));
bButton.addActionListener(EventHandler.create(ActionListener.class,c,"setB"));
}
private CComponent c;
}class CComponent extends JPanel
{
public CComponent ()
{
text_CComponent="Defualt";
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.drawString(text_CComponent, 20, 20);
}
public void setText(String text_Temp_CC)
{
text_CComponent=text_Temp_CC;
repaint();
}
public void setA()
{
setText("a");
}
public void setB()
{
setText("b");
}
private String text_CComponent;
}
解决方案 »
- 请教SSH2怎么用配置方式注入hibernate和struts2???
- 在Linux下如何解决由于多个IP地址导致InetAddress.getLocalHost()异常java.net.UnknownHostException
- 求助 编写一个简单的JAVA Applet应用程序
- 请问:如何得知文件处于被其它线程写入状态?急~~~
- 用java快速导出oracle数据到文本
- swing的JFileChooser组件可否控制字体?
- !!!!!!!!树的实现方式!!!!!!!!!!!!
- 我做了一个小程序,但不知道为什么却没有结果?可是也执行了这段程序。
- 请教一个及简单的问题
- 关于Jbuilder中运行Applet的一个问题?谁来帮我?
- 使用PrepareStatements查询数据库的一点异常,求解。
- 新的问题,eclipse·暂时不会调试
import java.awt.event.*;
import java.beans.*;
import javax.swing.*;public class CFrame extends JFrame
{
public CFrame()
{
setSize(500,500); JButton aButton = new JButton ("a");
JButton bButton = new JButton ("b"); c = new CComponent(); c.add(aButton);
c.add(bButton); add(c); aButton.addActionListener(EventHandler.create(ActionListener.class,c,"setA"));
bButton.addActionListener(EventHandler.create(ActionListener.class,c,"setB"));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private CComponent c; public static void main(final String... args) {
EventQueue.invokeLater(new Runnable(){
@Override public void run(){
new CFrame().setVisible(true);
}
});
} public static class CComponent extends JPanel
{
public CComponent ()
{
text_CComponent="Defualt";
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.drawString(text_CComponent, 20, 20);
}
public void setText(String text_Temp_CC)
{
text_CComponent=text_Temp_CC;
repaint();
}
public void setA()
{
setText("a");
}
public void setB()
{
setText("b");
}
private String text_CComponent;
}
}