java面板布局问题
importjava.awt.*;importjava.awt.event.*;classAextendsFrameimplementsActionListener//1...
import java.awt.*;
import java.awt.event.*;
class A extends Frame implements ActionListener//1
{
Frame fr;
Panel p1,p2,p3;
TextField s;
Button bt1; //加
Button bt2; //减
Button bt3; //乘
Button bt4; //除
Button bt5; //等号
Button bt6; //sin
Button bt7; //cos
Button bt8; //tan
Button bt00;
Button bt01;
Button bt02;
Button bt03;
Button bt04;
Button bt05;
Button bt06;
Button bt07;
Button bt08;
Button bt09;
Button bt10;
public void go()
{
Frame fr=new Frame("计算器");
fr.setSize(300,200);
fr.setVisible(true);
p1=new Panel();
p2=new Panel();
p3=new Panel();
s = new TextField(30);
bt1=new Button("+");
bt2=new Button("-");
bt3=new Button("*");
bt4=new Button("/");
bt5=new Button("=");
bt6=new Button("sin");
bt7=new Button("cos");
bt8=new Button("tan");
bt00=new Button("0");
bt01=new Button("1");
bt02=new Button("2");
bt03=new Button("3");
bt04=new Button("4");
bt05=new Button("5");
bt06=new Button("6");
bt07=new Button("7");
bt08=new Button("8");
bt09=new Button("9");
bt10=new Button(".");
p1.add(s);
p2.setLayout(null);
p2.add(bt1);
p2.add(bt2);
p2.add(bt3);
p2.add(bt4);
p2.add(bt6);
p2.add(bt7);
p2.add(bt8);
p2.add(bt5);
bt1.setSize(15,10);
p3.add(bt01);
p3.add(bt02);
p3.add(bt03);
p3.add(bt04);
p3.add(bt05);
p3.add(bt06);
p3.add(bt07);
p3.add(bt08);
p3.add(bt09);
p3.add(bt00);
p3.add(bt10);
p2.setLayout(new GridLayout(4, 2));
p3.setLayout(new GridLayout(4, 3));
fr.add(p1);
fr.add(p2);
fr.add(p3);
fr.setLayout(new FlowLayout());
bt1.addActionListener(this);//2
bt2.addActionListener(this);
bt3.addActionListener(this);
bt4.addActionListener(this);
}
public static void main(String[] args)
{
A a=new A();
a.go();
}
public void actionPerformed(ActionEvent ae )
{
}
}
为什么我把bt1的大小已经改过了但还是没变化呢 展开
import java.awt.event.*;
class A extends Frame implements ActionListener//1
{
Frame fr;
Panel p1,p2,p3;
TextField s;
Button bt1; //加
Button bt2; //减
Button bt3; //乘
Button bt4; //除
Button bt5; //等号
Button bt6; //sin
Button bt7; //cos
Button bt8; //tan
Button bt00;
Button bt01;
Button bt02;
Button bt03;
Button bt04;
Button bt05;
Button bt06;
Button bt07;
Button bt08;
Button bt09;
Button bt10;
public void go()
{
Frame fr=new Frame("计算器");
fr.setSize(300,200);
fr.setVisible(true);
p1=new Panel();
p2=new Panel();
p3=new Panel();
s = new TextField(30);
bt1=new Button("+");
bt2=new Button("-");
bt3=new Button("*");
bt4=new Button("/");
bt5=new Button("=");
bt6=new Button("sin");
bt7=new Button("cos");
bt8=new Button("tan");
bt00=new Button("0");
bt01=new Button("1");
bt02=new Button("2");
bt03=new Button("3");
bt04=new Button("4");
bt05=new Button("5");
bt06=new Button("6");
bt07=new Button("7");
bt08=new Button("8");
bt09=new Button("9");
bt10=new Button(".");
p1.add(s);
p2.setLayout(null);
p2.add(bt1);
p2.add(bt2);
p2.add(bt3);
p2.add(bt4);
p2.add(bt6);
p2.add(bt7);
p2.add(bt8);
p2.add(bt5);
bt1.setSize(15,10);
p3.add(bt01);
p3.add(bt02);
p3.add(bt03);
p3.add(bt04);
p3.add(bt05);
p3.add(bt06);
p3.add(bt07);
p3.add(bt08);
p3.add(bt09);
p3.add(bt00);
p3.add(bt10);
p2.setLayout(new GridLayout(4, 2));
p3.setLayout(new GridLayout(4, 3));
fr.add(p1);
fr.add(p2);
fr.add(p3);
fr.setLayout(new FlowLayout());
bt1.addActionListener(this);//2
bt2.addActionListener(this);
bt3.addActionListener(this);
bt4.addActionListener(this);
}
public static void main(String[] args)
{
A a=new A();
a.go();
}
public void actionPerformed(ActionEvent ae )
{
}
}
为什么我把bt1的大小已经改过了但还是没变化呢 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询