import java.awt.*;
import java.awt.event.*;
public class P211_8{
class MyPanel extends Panel implements ActionListener{
TextField text1,text2;
Button button;
MyPanel()
{
Panel1=new Panel();
text1=new TextField(10);
add(text1);
button1=new Button();
add(button1);
button1.addActionListener(this);
Panel2=new Panel();
text2=new TextField(10);
add(text2);
button2=new Button();
add(button2);
button2.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==button1)
button1.setLabel(getText(text1));
if(e.getSource()==button2)
button2.setLabel(getText(text2));
}
}
}
public static void main(String args[])
{
Frame f=new Frame("123");
new MyPanel();
f.setBounds(100,100,300,300);
f.setVisible(true);
f.add(Panel1,BorderLayout.WEST);
f.add(Panel2,BorderLayout.EAST);
f.validate();
}
其实已经很不好意思再提问了,实在是添麻烦给大家了。- -||||MyPanel为Panel的子类,这个例子中编译后出现:Z:\P211_8.java:37: 'class' or 'interface' expected
public static void main(String args[])
^
1 error
不知道怎么改?
[此贴子已经被作者于2007-5-19 14:58:04编辑过]