Swing不丑系列:ScrollPane

          今天上班的路上碰到JScrollPane 他非常憤怒,吹著胡子問我:喂!什么時候才能輪到我??我已經平淡很久了.
          其實不能怪我..他是一個麻煩的家伙..相對于JButton JComboBox等一些簡單組件來說.

          但看在
          JScrollPane
           默默的為Swing滾動的份上..嘗試讓他從我手里,成為一個帥哥.

          |----------------------------------------------------------------------------------------|
                               版權聲明  版權所有 @chensiyu
                      引用請注明來源 
          www.aygfsteel.com/chensiyu04

                      本文由  陳思羽 于 2011年8月24號 出品..
          |----------------------------------------------------------------------------------------|

          想要做好組件 心一定要細, 例如ScrpllPane得右下角Component 都要對著漸變一下.
          但一定要首先判斷 用戶是否設置了右下角Component 

          if (scrollPane.getCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER) == null) {
                      Component component 
          = new JLabel("") {

                          @Override
                          
          protected void paintComponent(Graphics g) {
                              Graphics2D g2 
          = (Graphics2D) g;
                              Paint oldPaint 
          = g2.getPaint();
                              Rectangle bounds 
          = getBounds();
                              Paint backgroupRectPaint 
          = new GradientPaint(00new Color(216216216),
                                      bounds.width, bounds.height, 
          new Color(152152152));
                              g2.setPaint(backgroupRectPaint);
                              g2.fillRect(
          00, bounds.width, bounds.height);
                              g2.setPaint(oldPaint);

                          }
                      };
                      scrollPane.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, component);
                  }

          在代碼里附帶了中文注釋.詳細可以下載代碼看,

          下載地址:ScrollBarDemo

          posted on 2011-08-25 16:35 相信 閱讀(3357) 評論(4)  編輯  收藏 所屬分類: Swing文章

          評論

          # re: Swing不丑系列:ScrollPane[未登錄] 2011-08-26 10:30 greatghoul

          這個ScrollPane的確漂亮呀。  回復  更多評論   

          # re: Swing不丑系列:ScrollPane 2011-08-27 12:02 相信

          哈哈..雖然麻煩..但畢竟他的功勞不小..  回復  更多評論   

          # re: Swing不丑系列:ScrollPane 2011-09-05 17:54 swingboy

          樓主 你的swing主題是用的什么啊 挺好看的   回復  更多評論   

          # re: Swing不丑系列:ScrollPane 2011-09-06 09:20 相信

          系統自帶的皮膚. ubuntu  回復  更多評論   

          <2011年8月>
          31123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          導航

          統計

          公告

          不顯示applet

          常用鏈接

          留言簿(16)

          我參與的團隊

          隨筆檔案

          文章分類

          文章檔案

          新聞檔案

          相冊

          swingchina 專業搞Swing的網站

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 施甸县| 梅河口市| 东阳市| 苍溪县| 扬州市| 榆社县| 英德市| 苏尼特右旗| 蛟河市| 莱芜市| 封丘县| 平舆县| 平邑县| 大丰市| 宁武县| 叶城县| 洪洞县| 沧州市| 陆良县| 万年县| 阜南县| 育儿| 林芝县| 泰兴市| 临潭县| 兰考县| 延安市| 洞头县| 桂平市| 兰西县| 衡山县| 福泉市| 高清| 大同市| 丰县| 勃利县| 含山县| 梨树县| 绥滨县| 彰化县| 阿荣旗|