當柳上原的風吹向天際的時候...

          真正的快樂來源于創造

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            368 Posts :: 1 Stories :: 201 Comments :: 0 Trackbacks
                 // 設定布局
                  int gridx, gridy, gridwidth, gridheight, anchor, fill, ipadx, ipady;
                  
          double weightx, weighty;
                  GridBagConstraints c;
                  Insets inset;
                  GridBagLayout gridbag 
          = new GridBagLayout();
                  
          this.setLayout(gridbag);
                  
                  
          // 0,0
                  gridx = 0;
                  gridy 
          = 0;
                  gridwidth 
          = 1;
                  gridheight 
          = 1;
                  weightx 
          = 1.00;
                  weighty 
          = 1.00;
                  anchor 
          = GridBagConstraints.CENTER;
                  fill 
          = GridBagConstraints.BOTH;
                  inset 
          = new Insets(up, left, down, right);
                  ipadx 
          = 0;
                  ipady 
          = 0;
                  c 
          = new GridBagConstraints(gridx, gridy, gridwidth, gridheight,
                          weightx, weighty, anchor, fill, inset, ipadx, ipady);
                  JScrollPane js
          =new JScrollPane(msgArea);
                  gridbag.setConstraints(js, c);
                  
          this.add(js);

                  以上代碼中,Insets構造函數四個參數的順序依次為上,左,下,右, 逆時針方向。這樣比較好記憶。
                  Swing中其它類似的四參數形式(如BorderFactory.createEmptyBorder(top, left, down, right))也類同此例。

          posted on 2011-01-24 15:00 何楊 閱讀(3247) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 壤塘县| 上杭县| 深水埗区| 京山县| 额尔古纳市| 孟连| 莱阳市| 蕲春县| 哈巴河县| 武强县| 沛县| 普陀区| 辽源市| 迁西县| 乳源| 曲麻莱县| 固阳县| 晋中市| 申扎县| 平利县| 淳化县| 新乡市| 漳浦县| 乌兰察布市| 望都县| 英德市| 武义县| 家居| 浏阳市| 融水| 新密市| 景谷| 卢湾区| 信丰县| 西畴县| 晋州市| 桐乡市| 天台县| 莱西市| 连江县| 兖州市|