三分自留地

          Follow your heart

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            4 Posts :: 2 Stories :: 1 Comments :: 0 Trackbacks

          常用鏈接

          留言簿

          我參與的團隊

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          2013年11月1日 #


          一、清晰型

          <%@ page contentType="image/jpeg" import="java.awt.*, 
          java.awt.image.*,java.util.*,javax.imageio.*" %> 
          <%! 
          Color getRandColor(int fc,int bc) 

          Random random = new Random(); 
          if(fc>255) fc=255; 
          if(bc>255) bc=255; 
          int r=fc+random.nextInt(bc-fc); 
          int g=fc+random.nextInt(bc-fc); 
          int b=fc+random.nextInt(bc-fc); 
          return new Color(r,g,b); 

          %> 
          <% 
          out.clear();
          response.setHeader("Pragma","No-cache"); 
          response.setHeader("Cache-Control","no-cache"); 
          response.setDateHeader("Expires", 0); 
          int width=60, height=20; 
          BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 
          Graphics g = image.getGraphics(); 
          Random random = new Random(); 
          g.setColor(getRandColor(200,250)); 
          g.fillRect(0, 0, width, height); 
          g.setFont(new Font("Times New Roman",Font.PLAIN,18)); 
          g.setColor(getRandColor(160,200)); 
          for (int i=0;i<155;i++) 

          int x = random.nextInt(width); 
          int y = random.nextInt(height); 
          int xl = random.nextInt(12); 
          int yl = random.nextInt(12); 
          g.drawLine(x,y,x+xl,y+yl); 

          String sRand=""; 
          for (int i=0;i<4;i++){ 
          String rand=String.valueOf(random.nextInt(10)); 
          sRand+=rand; 
          g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110))); 
          g.drawString(rand,13*i+6,16); 

          session.setAttribute("SRA",sRand);
          g.dispose(); 
          ImageIO.write(image, "JPEG", response.getOutputStream()); 
          %>


          二、凌亂型

          <%@ page contentType="image/jpeg"
              import="java.awt.*, 
          java.awt.image.*,java.util.*,javax.imageio.*"%>
          <%! 
          Color getRandColor(int fc,int bc) 

          Random random = new Random(); 
          if(fc>255) fc=255; 
          if(bc>255) bc=255; 
          int r=fc+random.nextInt(bc-fc); 
          int g=fc+random.nextInt(bc-fc); 
          int b=fc+random.nextInt(bc-fc); 
          return new Color(r,g,b); 

          %>
          <% 
          char[] codeSequence = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
                  'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
                  'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

          response.setHeader("Pragma","No-cache"); 
          response.setHeader("Cache-Control","no-cache"); 
          response.setDateHeader("Expires", 0); 
          int width=60, height=20; 
          BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 
          Graphics g = image.getGraphics(); 
          Random random = new Random(); 
          g.setColor(getRandColor(200,250)); 
          g.fillRect(0, 0, width, height); 
          g.setFont(new Font("Fixedsys",Font.PLAIN,18)); 
          g.drawRect(0, 0, width - 1, height - 1); // 隨機產生160條干擾線,使圖象中的認證碼不易被其它程序探測到。
          g.setColor(Color.BLACK);
          for (int i = 0; i < 30; i++) {
              int x = random.nextInt(width);
              int y = random.nextInt(height);
              int xl = random.nextInt(12);
              int yl = random.nextInt(12);
              g.drawLine(x, y, x + xl, y + yl);
          }
          String sRand=""; 
          for (int i=0;i<4;i++){     
          String rand=String.valueOf(codeSequence[random.nextInt(36)]);
          sRand+=rand; 
          g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110))); 
          g.drawString(rand,13*i+6,16); 

          session.setAttribute("SRA",sRand);
          g.dispose(); 
          ImageIO.write(image, "JPEG", response.getOutputStream()); 
          out.clear();
          out = pageContext.pushBody();
          %>


          posted @ 2013-11-01 13:43 大山 閱讀(115) | 評論 (0)編輯 收藏

          2013年5月2日 #



              1、題目是編寫java程序打印出一下數字形狀:

                  1  
                  7   2  
                  12 8   3   
                  16 13 9   4  
                  19 17 14 10 5  
                  21 20 18 15 11 6  
              
              當初做題的時候比較著急沒用做出來,其實思路也都想出來了,就是沒具體編碼出來,關鍵是控制數組的坐標變換而已:
              下來做了一下,與大家共享下,請多指正。

               
             
           public class Test {

              public static void main(String[] args) {
                  
                  int count=1;
                  int [][]  a=new int [12][12];
                  
                  //賦值
                  for(int i=0;i<12;i++){
                      for(int j=0;j<12-j;j++){
                          if(j>=i){
                              a[j][j-i]=count++;
                          }
                      }
                  }
                  
                  //打印
                  for(int i=0;i<12;i++){
                      for(int j=0;j<12;j++){
                          if(a[i][j]!=0){
                              System.out.print(a[i][j]+" ");
                          }
                          
                      }
                      System.out.println(" ");
                  }
                  
              }

          }
          posted @ 2013-05-02 17:09 大山 閱讀(216) | 評論 (0)編輯 收藏

          2013年1月22日 #


          1、先發效果圖  





























          2、上頁面
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
          <title>Back to To TEST</title>
          <LINK rel=stylesheet type=text/css href="css/lrtk.css">
          <script src="js/jquery.js"></script>
          <script type="text/javascript">
          $(function() 
          {
              $(window).scroll(function() 
          {
                  
          if($(this).scrollTop() != 0{
                      $(
          '#toTop').fadeIn();    
                  }
           else {
                      $(
          '#toTop').fadeOut();
                  }

              }
          );
           
              $(
          '#toTop').click(function() {
                  $(
          'body,html').animate({scrollTop:0},2000);
                  
          return false;//返回false可以避免在原鏈接后加上# 
              }
          );    
          }
          );
          </script>
          </head>
          <body>
          <div style="DISPLAY: none" id="toTop"><IMG border=0 src="images/top.gif"></div>


          <div id="main" style="width:1000px;padding-top:200px;height:2000px;background:#eee; margin:0 auto;text-align:center">
            
          <h1>請滾動右側滾動條查看效果</h1>
          </div>

          </body>
          </html>



          3、CSS 代碼
          #toTop {
          POSITION: fixed;
          TEXT
          -ALIGN: center;
          LINE
          -HEIGHT: 30px;
          WIDTH: 60px;
          BOTTOM: 65px;
          HEIGHT: 63px;
          FONT
          -SIZE: 12px;
          CURSOR: pointer;
          RIGHT: 30px;
          _position: absolute;
          _right: auto
          }


          示例地址:/Files/ityouknow/back_top.zip





          posted @ 2013-01-22 21:44 大山 閱讀(194) | 評論 (1)編輯 收藏

          2012年11月30日 #


          1、運行單個class文件:

          //測試需要運行class文件目錄
          c:
          cd c:\Users\Desktop\test
          //設置java環境,修改為本機java bin文件目錄
          set path=c:\Program Files\Java\jdk1.7.0_07\bin;
          // class運行需要引入的jar包,如有多個以分號分開。
          set CLASSPATH=.;C:\j2sdk1_4_2_08\lib\tools.jar;
          //運行 具體class文件名
          java HelloWorld

          2、運行包括包路徑的class文件:

          //進入下項目class目錄,絕對目錄
          D:
          cd D:\WEB-INF\classes
          set path=C:\Program Files (x86)\Java\jre6\bin;
          set CLASSPATH=.;C:\j2sdk1_4_2_08\lib\tools.jar;

          //加入包名,傳入參數XXXX  如果有多個已空格分開
          java com.ServiceClient  xxxx
          pause



          3、運行項目中的class文件,循環加入jar包。


          //循環加入所有jar包
          for %%i in (E:\lib\*.jar) do call set CLASSPATH=%%i;%%CLASSPATH%%
          set CLASSPATH=.;%CLASSPATH%
          E:
          cd E:\WEB-INF\classes
          java com.ServiceClient 1006
          pause








          posted @ 2012-11-30 19:30 大山 閱讀(882) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 泽普县| 山丹县| 射洪县| 海晏县| 昆明市| 凤庆县| 松滋市| 东宁县| 从化市| 化德县| 体育| 台湾省| 青州市| 大渡口区| 手游| 凭祥市| 凌云县| 蓬安县| 台山市| 嘉峪关市| 贵南县| 厦门市| 博爱县| 邹平县| 赣州市| 康定县| 大邑县| 凌云县| 金山区| 磴口县| 疏勒县| 富顺县| 茶陵县| 定襄县| 蓬安县| 兴隆县| 二手房| 黄山市| 延津县| 晴隆县| 玛纳斯县|