java布局管理器swing:想在一个面板上再加一个面板怎么加?

来源:百度知道 编辑:UC知道 时间:2024/09/28 10:35:31
我在做一个计算器的面板,大体上用BorderLayout分成了4块在其之上还想加FlowLayout怎么做啊?
代码第一部分
import java.awt.*; import java.awt.event.*;
import javax.swing.*;
public class FlowLayout extends JFrame
{
Container contentPane1=getContentPane();
contentPane1.setLayout( new FlowLayout( ));
contentPane1.add( new JButton("MC") );
contentPane1.add( new JButton("MR") );
contentPane1.add( new JButton("MS") );
contentPane1.add( new JButton("M+") );
setSize(40,160); setVisible(true); setResizable(false);

这是一个简单的计算器,代码如下:
import java.awt.*;
import java.awt.event.*;
public class Homework2 extends Frame implements ActionListener,KeyListener
{
Label label;
Button n1,n2,n3,n4,n5,n6,n7,n8,n9,n0,addition,subtraction,multiplication,division,equle,C;
Font f;
char ch;
String regA,regB;
char op;
double sum;
Homework2()
{
setTitle("简易计算器");
setLayout(null);
regA=new String("");
regB=new String("");

label=new Label("0",Label.RIGHT);
label.setBackground(Color.black);
f=new Font("arial",Font.BOLD,12);
label.setForeground(Color.white);
label.setFont(f);
n1=new Button("1");
n2=new Button("2");
n3=new Button("3");
n4=new Button("4");
n5