Introduction - If you have any usage issues, please Google them yourself
MyPanel.Java
package cn
import java.awt.*
import java.awt.event.*
public class MyPanel extends Panel implements ActionListener{
TextField tf
Button bt
public MyPanel()
{
tf=new TextField(10)
bt=new Button("按钮")
this.add(tf)
this.add(bt)
this.setLayout(new FlowLayout())
bt.addActionListener(this)
this.setVisible(true)
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==bt){
bt.setLabel(tf.getText())
}
}
}
MyFrame.Java
package cn
import java.awt.BorderLayout
import java.awt.Frame
import java.awt.event.*
public class MyFrame extends Frame {
MyPanel p1,p2
public MyFrame()
{
p1=new MyPanel()
p2=new MyPanel()
this.setLayout(new BorderLayout())
this.add(p1)
this.add(p2)
this.setBounds(100,100,400,200)
this.setVisible(true)
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent arg0) {
System.exit(0)
}
})
this.