importjava.awt.*;importjava.awt.event.*;classAextendsPanelimplementsActionListener{Buttonbutton1,button2;ColorbackColor;A(){button1=newButton("确定");button2=newButton("取...
import java.awt.*;
import java.awt.event.*;
class A extends Panel implements ActionListener
{Button button1,button2;
Color backColor;
A(){
button1=new Button("确定");
button2=new Button("取消");
add(button1);
add(button2);
setBackground(Color.pink);
backColor=getBackground();
button1.addActionListener(this);
button2.addActionListener(this);}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==button1)
{setBackground(Color.cyan);}
else if(e.getSource()==button2)
{setBackground(backColor);}}}
class W extends Frame implements ActionListener
{A panel1;
Button button1;
W()
{
setLayout(new FlowLayout());
panel1=new A();
button1=new Button("退出");
add(panel1);
add(button1);
button1.addActionListener(this);
setBounds(60,60,200,200);
setVisible(true);
validate();}
public void actionPerformed(ActionEvent e)
{System.exit(0);}}
public class mb
{public static void main(String args[])
{new W();}}
我想调成面板大小使之是窗口大小的二分之一
上面程序段可以怎样修改?
请教高手!!
嗯 各位的方法我都试过了 我是一位学生 netbeans开发工具我们没用过
我要想把面板放在我所建的窗口的正中央 可以怎么做呢?
展开