java 高手帮忙~

来源:百度知道 编辑:UC知道 时间:2024/06/03 18:33:52
帮我改下错~主要是当按第2个按钮时~后面的!!!!!会变成"你好,世界!"
顺便帮我帮那显现的字开始就出现在中间~

package second;
import java.awt.*;
import java.awt.event.*;
public class myframe extends Frame implements ActionListener
{
private Panel flowPanel;
Label lb1;
public myframe(String title)
{
super(title);
setSize(480, 360);
setLocation(640, 512);
setFlowLayoutPanel();
add(flowPanel);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public void setFlowLayoutPanel()
{
flowPanel=new Panel();
Button btn1=new Button("按我三");
btn1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{

//改了一点,你看看

import java.awt.*;
import java.awt.event.*;

public class myframe extends Frame implements ActionListener
{
private Panel flowPanel;
Label lb1;

public myframe(String title)
{
super(title);
setSize(480, 360);
setLocation(640, 512);
setFlowLayoutPanel();
add(flowPanel);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
setVisible(true);
}

public void setFlowLayoutPanel()
{
flowPanel = new Panel();
Button btn1 = new Button("按我三");
btn1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
((Button) e.getSource()).setLabel("按我旁边");
}
});
Button btn2 = new Button("点我- -");
lb1 = new Label();
fl