import java.awt.*;
import javax.swing.*;
import java.awt.event.*;public class Order extends JFrame {
private String[] month={"01","02","03","04","05","06","07","08","09","10","11","12" };
private String[] day={"01","02","03","04","05","06","07","08","09","10","11","12","" +
            "13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
    private JRadioButton jrb_year_1,jrb_year_2,jrb_passenger_1,jrb_passenger_2,jrb_plane_1,jrb_plane_2;
    public void order(){
        JFrame frame = new JFrame("国内机票订票系统");
        frame.setLocation(200, 200);//订票系统主界面位置
        frame.setSize(600, 600);//订票系统主界面大小
        frame.setBackground(Color.GRAY);//订票系统主界面背景颜色
        frame.setVisible(true);//主界面可见
        frame.setResizable(false);//主界面大小不可变        frame.setLayout(null);//布局管理        JButton button1 = new JButton("提交订票信息");
        JButton button2 = new JButton("返回主界面");
        frame.add(button1);//添加按钮1
        frame.add(button2);//添加按钮2
        button1.setBounds(150, 500, 120, 30);//设置button1位置
        button2.setBounds(330, 500, 120, 30);//设置button2位置
        //添加主界面事件触发接口
        Monitor bh = new Monitor();
        button1.addActionListener(bh);//添加接口        //日期年份单选框
//        JPanel p1 = new JPanel();
//        frame.add(p1);
//        p1.setBounds(50, 15, 100, 100);
//        p1.add(new JLabel("选择航班日期:"));
        
//        JPanel p2 = new JPanel();
//        frame.add(p2);
//        p2.setBounds(50, 50, 50, 100);
//        p2.add(new JLabel("年份"));        JPanel year_RadioButton = new JPanel();
        frame.add(year_RadioButton);//添加单选框到主界面
        year_RadioButton.setBounds(50, 80, 50, 100);//设置单选框位置
        year_RadioButton.add( jrb_year_1 = new JRadioButton("2009"));//添加单选框内容
        year_RadioButton.add( jrb_year_2 = new JRadioButton("2010"));
        ButtonGroup group_1 = new ButtonGroup();//设置只能单选
        group_1.add(jrb_year_1);
        group_1.add(jrb_year_2);//        JPanel p3 = new JPanel();
//        frame.add(p3);
//        p3.setBounds(150, 50, 50, 100);
//        p3.add(new JLabel("月"));        //日期月份复选框
        JComboBox monthBox = new JComboBox();
        frame.add(monthBox);//添加复选框到主界面
        monthBox.setBounds(150, 90, 50, 20);//设置主界面位置
        for(int i=0;i<month.length;i++)//添加复选框内容
monthBox.addItem(month[i]);//        JPanel p4 = new JPanel();
//        frame.add(p4);
//        p4.setBounds(250, 50, 50, 100);
//        p4.add(new JLabel("日"));        //日期day复选框
        JComboBox dayBox = new JComboBox();
        frame.add(dayBox);//添加复选框到主界面
        dayBox.setBounds(250, 90, 50, 20);//设置复选框位置
        for(int i=0;i<day.length;i++)//添加复选框内容
dayBox.addItem(day[i]);//        JPanel p5 = new JPanel();
//        frame.add(p5);
//        p5.setBounds(350, 50, 50, 100);
//        p5.add(new JLabel("乘客类型"));        //乘客类型单选框
        JPanel passenger_RadioButton = new JPanel();
        frame.add(passenger_RadioButton);//添加单选框到主界面
        passenger_RadioButton.setBounds(350, 80, 50, 100);//设置单选框位置
        passenger_RadioButton.add( jrb_passenger_1 = new JRadioButton("成年"));
        passenger_RadioButton.add( jrb_passenger_2 = new JRadioButton("儿童"));
        ButtonGroup group_2 = new ButtonGroup();//设置只能单选
        group_2.add(jrb_passenger_1);
        group_2.add(jrb_passenger_2);//        JPanel p6 = new JPanel();
//        frame.add(p6);
//        p6.setBounds(450, 50, 50, 100);
//        p6.add(new JLabel("机票类型"));        //票程类型单选框
        JPanel plane_RadioButton = new JPanel();
        frame.add(plane_RadioButton);//添加单选框到主界面
        plane_RadioButton.setBounds(450, 80, 50, 100);//设置单选框位置
        plane_RadioButton.add( jrb_plane_1 = new JRadioButton("单程"));
        plane_RadioButton.add( jrb_plane_2 = new JRadioButton("往返"));
        ButtonGroup group_3 = new ButtonGroup();//设置只能单选
        group_3.add(jrb_plane_1);
        group_3.add(jrb_plane_2);
    }
    public static void main(String [] args){
        Order o = new Order();
        o.order();
    }
}
class Monitor extends JFrame implements ActionListener{
    public void actionPerformed(ActionEvent e){
        JOptionPane.showMessageDialog(null,"已提交订票信息!请稍后!");
        JOptionPane.showMessageDialog(null, "正在返回结果!");
    }
}

解决方案 »

  1.   

    取消那些注释掉的 面板代码后
    package javaapplication2;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;/**
     *
     * @author JuneVa
     */
    public class Order extends JFrame {
    private String[] month={"01","02","03","04","05","06","07","08","09","10","11","12" };
    private String[] day={"01","02","03","04","05","06","07","08","09","10","11","12","" +
                "13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
        private JRadioButton jrb_year_1,jrb_year_2,jrb_passenger_1,jrb_passenger_2,jrb_plane_1,jrb_plane_2;
        public void order(){
            JFrame frame = new JFrame("国内机票订票系统");
            frame.setLocation(200, 200);//订票系统主界面位置
            frame.setSize(600, 600);//订票系统主界面大小
            frame.setBackground(Color.GRAY);//订票系统主界面背景颜色
            frame.setVisible(true);//主界面可见
            frame.setResizable(false);//主界面大小不可变        frame.setLayout(null);//布局管理        JButton button1 = new JButton("提交订票信息");
            JButton button2 = new JButton("返回主界面");
            frame.add(button1);//添加按钮1
            frame.add(button2);//添加按钮2
            button1.setBounds(150, 500, 120, 30);//设置button1位置
            button2.setBounds(330, 500, 120, 30);//设置button2位置
            //添加主界面事件触发接口
            Monitor bh = new Monitor();
            button1.addActionListener(bh);//添加接口        //日期年份单选框
            JPanel p1 = new JPanel();
            frame.add(p1);
            p1.setBounds(50, 15, 100, 100);
            p1.add(new JLabel("选择航班日期:"));
            
            JPanel p2 = new JPanel();
            frame.add(p2);
            p2.setBounds(50, 50, 50, 100);
            p2.add(new JLabel("年份"));        JPanel year_RadioButton = new JPanel();
            frame.add(year_RadioButton);//添加单选框到主界面
            year_RadioButton.setBounds(50, 80, 50, 100);//设置单选框位置
            year_RadioButton.add( jrb_year_1 = new JRadioButton("2009"));//添加单选框内容
            year_RadioButton.add( jrb_year_2 = new JRadioButton("2010"));
            ButtonGroup group_1 = new ButtonGroup();//设置只能单选
            group_1.add(jrb_year_1);
            group_1.add(jrb_year_2);        JPanel p3 = new JPanel();
            frame.add(p3);
            p3.setBounds(150, 50, 50, 100);
            p3.add(new JLabel("月"));        //日期月份复选框
            JComboBox monthBox = new JComboBox();
            frame.add(monthBox);//添加复选框到主界面
            monthBox.setBounds(150, 90, 50, 20);//设置主界面位置
            for(int i=0;i<month.length;i++)//添加复选框内容
    monthBox.addItem(month[i]);        JPanel p4 = new JPanel();
            frame.add(p4);
            p4.setBounds(250, 50, 50, 100);
            p4.add(new JLabel("日"));        //日期day复选框
            JComboBox dayBox = new JComboBox();
            frame.add(dayBox);//添加复选框到主界面
            dayBox.setBounds(250, 90, 50, 20);//设置复选框位置
            for(int i=0;i<day.length;i++)//添加复选框内容
    dayBox.addItem(day[i]);        JPanel p5 = new JPanel();
            frame.add(p5);
            p5.setBounds(350, 50, 50, 100);
            p5.add(new JLabel("乘客类型"));        //乘客类型单选框
            JPanel passenger_RadioButton = new JPanel();
            frame.add(passenger_RadioButton);//添加单选框到主界面
            passenger_RadioButton.setBounds(350, 80, 50, 100);//设置单选框位置
            passenger_RadioButton.add( jrb_passenger_1 = new JRadioButton("成年"));
            passenger_RadioButton.add( jrb_passenger_2 = new JRadioButton("儿童"));
            ButtonGroup group_2 = new ButtonGroup();//设置只能单选
            group_2.add(jrb_passenger_1);
            group_2.add(jrb_passenger_2);        JPanel p6 = new JPanel();
            frame.add(p6);
            p6.setBounds(450, 50, 50, 100);
            p6.add(new JLabel("机票类型"));        //票程类型单选框
            JPanel plane_RadioButton = new JPanel();
            frame.add(plane_RadioButton);//添加单选框到主界面
            plane_RadioButton.setBounds(450, 80, 50, 100);//设置单选框位置
            plane_RadioButton.add( jrb_plane_1 = new JRadioButton("单程"));
            plane_RadioButton.add( jrb_plane_2 = new JRadioButton("往返"));
            ButtonGroup group_3 = new ButtonGroup();//设置只能单选
            group_3.add(jrb_plane_1);
            group_3.add(jrb_plane_2);
        }
        public static void main(String [] args){
            Order o = new Order();
            o.order();
        }
    }
    class Monitor extends JFrame implements ActionListener{
        public void actionPerformed(ActionEvent e){
            JOptionPane.showMessageDialog(null,"已提交订票信息!请稍后!");
            JOptionPane.showMessageDialog(null, "正在返回结果!");
        }
    }这次运行后,结果是带有随机性,框架内容显示不完整,而且不完整的内容是随机的,有时也是完整的
    再次运行:
      

  2.   

    你可以试一下  明确你每一个小panel的布局管理器   
    比如说 
    year_RadioButton
    这个panel
    改成如下的代码year_RadioButton.setLayout(new BorderLayout());
    year_RadioButton.add(jrb_year_1 = new JRadioButton("2009"),BorderLayout.NORTH);//添加单选框内容
    year_RadioButton.add(jrb_year_2 = new JRadioButton("2010"),BorderLayout.SOUTH);
    然后再试下  应该会好了 ·
      

  3.   

    borderlayout只能设置东南西北中呀,不过确实是面板过多问题