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

          真正的快樂來源于創(chuàng)造

            BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
            368 Posts :: 1 Stories :: 201 Comments :: 0 Trackbacks
                 // 設(shè)定布局
                  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構(gòu)造函數(shù)四個參數(shù)的順序依次為上,左,下,右, 逆時針方向。這樣比較好記憶。
                  Swing中其它類似的四參數(shù)形式(如BorderFactory.createEmptyBorder(top, left, down, right))也類同此例。

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

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


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 准格尔旗| 民丰县| 通许县| 南宁市| 宜黄县| 满城县| 舟曲县| 弥勒县| 乌拉特中旗| 大田县| 孝义市| 孝昌县| 札达县| 尉犁县| 邮箱| 宁国市| 泰和县| 连平县| 清水县| 保定市| 鄂伦春自治旗| 察隅县| 中山市| 瑞安市| 高邑县| 财经| 博白县| 乐平市| 舟山市| 屏边| 罗平县| 厦门市| 扶风县| 沙洋县| 阿荣旗| 当阳市| 谢通门县| 民丰县| 黑龙江省| 辰溪县| 景洪市|