ext登錄及tabpanel_第1頁(yè)
ext登錄及tabpanel_第2頁(yè)
ext登錄及tabpanel_第3頁(yè)
ext登錄及tabpanel_第4頁(yè)
免費(fèi)預(yù)覽已結(jié)束,剩余1頁(yè)可下載查看

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、.Ext個(gè)人學(xué)習(xí)資料1. 添加panel并居中顯示Ext.onReady(function()var loginForm=new Ext.Panel(renderTo:"loginForm",width:300,height:200,title:"用戶登錄",frame:true,floating:true /表示panel是浮動(dòng)的);var viewPort=new Ext.Viewport();var loginFormX=(viewPort.getSize().width-loginForm.getSize().width)/2;var login

2、FormY=(viewPort.getSize().height-loginForm.getSize().height)/loginForm.setPosition(loginFormX,loginFormY);)2. 驗(yàn)證碼的好處:可以防止惡意的注入,以及惡意的注冊(cè)。完整的驗(yàn)證碼代碼:<% page language="java" import="java.util.*,java.awt.*, java.awt.image.*,javax.imageio.*" pageEncoding="utf-8"%><%pag

3、e import="java.io.OutputStream"%><%!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);%><%response.setHeader(&

4、quot;Pragma","No-cache");response.setHeader("Cache-Control","no-cache");response.setDateHeader("Expires",0);/在內(nèi)存中創(chuàng)建圖片int width=60,height=20;BufferedImage image=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);/獲取圖形上下文Graphics g=image.getGraphics

5、();Random random=new Random();/ 設(shè)定背景色g.setColor(getRandColor(200,250);g.fillRect(0,0,width,height);/設(shè)定字體g.setFont(new Font("Times New Roman",Font.PLAIN,18);/畫(huà)邊框/g.setColor(new Color();/g.drawRect(0,0,width-1,height-1);/隨機(jī)產(chǎn)生155條干擾線,使圖像中的認(rèn)證碼不易被其他程序探測(cè)到g.setColor(getRandColor(160,200);for(int

6、i=0;i<155;i+)int x=random.nextInt(width);int y=random.nextInt(height);int x1=random.nextInt(12);int y1=random.nextInt(12);g.drawLine(x,y,x+x1,y+y1);/取隨機(jī)產(chǎn)生的認(rèn)證碼(4位數(shù)字)String sRand=""for(int i=0;i<4;i+)String rand=String.valueOf(random.nextInt(10);sRand+=rand;/將認(rèn)證碼顯示到圖像中g(shù).setColor(new Co

7、lor(20+random.nextInt(110),20+random.nextInt(110),random.nextInt(100);/調(diào)用函數(shù)出來(lái)的顏色相同,可能是因?yàn)榉N子太接近,所以只能直接生成g.drawString(rand,13*i+6,16); /將認(rèn)證碼存入sessionsession.setAttribute("rand",sRand);/圖像生效g.dispose();OutputStream output=response.getOutputStream();/輸入圖像到頁(yè)面ImageIO.write(image,"JPEG",

8、response.getOutputStream();output.flush(); out.clear();out=pageContext.pushBody(); %>3. 如何調(diào)用驗(yàn)證碼:var rc=Ext.getDom("randcode");var rcp=Ext.get(rc.parentNode);rcp.createChild(tag:"img",src:"random.jsp",align:"absbottom");4. 有關(guān)活動(dòng)面板的添加a) 如何在tabPanel中添加一個(gè)活動(dòng)面板。點(diǎn)擊

9、樹(shù)節(jié)點(diǎn)時(shí)添加監(jiān)聽(tīng)事件:"click":function(n) if(isOpen=false) var tab=Ext.getCmp("tabPanel"); var tagPage=tab.add( title:n.text, html:"路線管理", closable:true, listeners: "beforedestroy":function(aa) alert(aa); isOpen=false; ); tab.setActiveTab(tagPage); isOpen=true; b) 如何添加右鍵

10、菜單欄,給tabPanel添加右鍵事件listeners: "contextmenu":function(tabPanel,tab,e) var cc=new Ext.menu.Menu( text:"關(guān)閉當(dāng)前選項(xiàng)頁(yè)",handler:function() if(tabPanel.getItem(0)!=tab) tabPanel.remove(tab); , text:"關(guān)閉其他所有選項(xiàng)卡", handler:function() tabPanel.items.each(function(item) if(item!=tab&&item!=tabPanel.getItem(0) tabPanel.remove(item); ) ); cc.showAt(e.getPoint(); c) 如何設(shè)置打開(kāi)面板是唯一的i. 設(shè)置一變量,初始值為false。var isOpen=false;ii. 在變量為false時(shí)打開(kāi),打開(kāi)后設(shè)置變量為true。添加銷(xiāo)毀監(jiān)聽(tīng)事件,在組件銷(xiāo)毀時(shí)在設(shè)置默認(rèn)值為false。if(isOpen=false) var tab=Ext.getCmp("tabPanel"); var tagPage=tab.add

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論