作业
只学了简单的布局管理器,这种不知道如何实现,请教大家!

解决方案 »

  1.   

    晕错了   刚刚看了一眼 是网格布局  java.awt.GridLayout()
      

  2.   

    我..楼上楼主小号啊这么多要求啊 这就不是一个布局了是一个组合的啊
    整体上用box中间的用网格的 动态调整大小是什么意思啊
      

  3.   


    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Rectangle;
    import java.awt.SystemColor;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;import javax.swing.ButtonGroup;
    import javax.swing.JDialog;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JRadioButton;public class b extends JDialog implements ActionListener {
        private JPanel jContentPane = null;
        public JLabel jLabelDealingID = null;
        static JLabel jLabelSumShow = null;
        static JLabel jLabelMerberIDShow = null;
        static JLabel jLabelMerberNameShow = null;
        static JLabel jLabelMerberLevelShow = null;
        static JLabel jLabelMerberDiscountShow = null;
        static JLabel jLabelMerberPointsShow = null;
        static JRadioButton jRadioButtonCommon = null;
        static JRadioButton jRadioButtonMerBer = null;
        private ButtonGroup bg = new ButtonGroup();
        private JLabel jLabelNum = null;
        static JLabel jLabelNumShow = null;
            public b() {    
            initialize();
            this.setVisible(true);
        }
        private void initialize() {
            this.setTitle("CashRegister");
            this.setSize(500, 200);
            this.setModal(true);
            this.setLocationRelativeTo(this);
            this.setContentPane(getJContentPane());
        }    private JPanel getJContentPane() {
            
            if (jContentPane == null) {
                jLabelNumShow = new JLabel();
                jLabelNumShow.setBounds(new Rectangle(40, 0, 53, 25));
                jLabelNumShow.setForeground(Color.WHITE);
                jLabelNumShow.setText("");
                jLabelNum = new JLabel();
                jLabelNum.setBounds(new Rectangle(0, 0, 40, 25));
                jLabelNum.setForeground(Color.WHITE);
                jLabelNum.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.BOLD, 12));
                jLabelNum.setText("总计:");
                
                
                jContentPane = new JPanel();
                jContentPane.setLayout(null);
                jContentPane.add(getJRadioButtonMerBer(), null);
                jContentPane.add(jLabelNum, null);
                jContentPane.add(jLabelNumShow, null);
                jContentPane.setBackground(SystemColor.darkGray);//背景颜色
                
                
            }
            return jContentPane;
        }
        private JRadioButton getJRadioButtonMerBer() {
            if (jRadioButtonMerBer == null) {
                jRadioButtonMerBer = new JRadioButton();
                jRadioButtonMerBer.setBounds(new Rectangle(300, 0, 54, 21));
                jRadioButtonMerBer.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.BOLD, 12));
                jRadioButtonMerBer.setText("点我");
                jRadioButtonMerBer.setSelected(false);// 交易后返回普通用户
                bg.add(jRadioButtonMerBer);
                jRadioButtonMerBer.addItemListener(new java.awt.event.ItemListener() {
                    public void itemStateChanged(java.awt.event.ItemEvent e) {
                       
                        
                    }
                });
            }
            return jRadioButtonMerBer;
        }    public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            
        }
        
        
            public static void main(String args[]) {
            b  test=new b();
            test.setVisible(true);
                
            }
        }  方法很多,我给你介绍的是采用这种坐标实现 
    jRadioButtonMerBer.setBounds(new Rectangle(300, 0, 54, 21));
    (x轴,y轴,长,宽)希望对你有帮助