freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

第5次上機(jī)題實(shí)驗(yàn)報(bào)告(編輯修改稿)

2024-11-03 16:02 本頁面
 

【文章內(nèi)容簡(jiǎn)介】 yout (cardlayout1)。 Panel pnlFirst=new Panel( )。 ()。 ()。 (first,pnlFirst)。 (new Label(This is the first Panel) )。 Panel pnlSecond=new Panel( )。 ()。 ()。 (second,pnlSecond)。 (new Label(This is the second Panel) )。 Panel pnlThird=new Panel( )。 ()。 ()。 (third,pnlThird)。 (new Label(This is the third Panel) )。 Panel pnlFourth=new Panel( )。 ()。 ()。 (fourth,pnlFourth)。 (new Label(This is the fourth Panel) )。 (new ActionListener(){ public void actionPerformed(ActionEvent e) { processAction(e)。 } })。 (new ActionListener(){ public void actionPerformed(ActionEvent e) { processAction(e)。 } })。 (new ActionListener(){ public void actionPerformed(ActionEvent e) { processAction(e)。 }})。 (new ActionListener(){ public void actionPerformed(ActionEvent e) {processAction(e)。 } })。 //把四個(gè)功能按鈕加入到 Panel ( btnFirst )。 ( btnPrevious )。 ( btnNext )。 ( btnLast )。 } public static void main( String[] args ) { //創(chuàng)建框架窗體的實(shí)例 CardLayoutDemo frmCardLayout= new CardLayoutDemo()。 //設(shè)置框架窗體的事件監(jiān)聽 (關(guān)閉窗體事件 ) (new WindowAdapter(){ public void windowClosing(WindowEvent e) {(0)。 } })。 //顯示框架窗體 ()。 ()。 } public Dimension getPreferredSize() { return new Dimension(300,300)。 } //處理按鈕的事件 private void processAction(ActionEvent e) { //獲取事件源 ( 用戶選擇是哪個(gè)按鈕 ) Button btnEvent=(Button)()。 if( (btnFirst)) ( pnlDisplayArea )。 else if( (btnLast)) ( pnlDisplayArea )。 else if( (btnPrevious)) ( pnlDisplayArea )。 else if( (btnNext)) ( pnlDisplayArea )。 } } 運(yùn)行結(jié)果 GridLayout布局管理器 GridLayout 提供了一種基于網(wǎng)格的布局管理方式。網(wǎng)格的行數(shù)和列數(shù)可以在創(chuàng)建 GridLayout 對(duì)象時(shí)指定。另外,容器中每個(gè)組件將占據(jù)大小完全相同的一個(gè)網(wǎng)格。向網(wǎng)格中布局 GUI組件有兩種方法: ?使用默認(rèn)的順序 ?采用 add(Component p,int index) 構(gòu)造函數(shù) ? GridLayout( ) ? GridLayout(int rows,int cols) ? GridLayout(int rows,int cols, int hgap,int vgap) import .*。 import .*。 public class GridLayoutDemo extends Frame { public GridLayoutDemo( ) { ( new GridLayout(2,4))。 ( new Button(1) )。 ( new Button(2) )。 ( new Button(3) )。 ( new Button(4) )。 ( new Button(5) )。 ( new Button(6) )。 ( new Button(7) )。 ( new Button(8) )。 } public static void main( String[ ] args ) { GridLayoutDemo frmGridLayout=new GridLayoutDemo(。 (new WindowAdapter( ){ public void windowClosing(WindowEvent e) {(0)。}})。 ( )。 ( )。 } } 運(yùn)行結(jié)果 不使用布局管理器 import .*。import .*。 public class NullLayoutDemo extends Frame { Label lblUserName = new Label(用戶名稱: )。 TextField txtUserName = new TextField( )。 Label lblUserPasswd = new Label(用戶密碼: )。 TextField txtUserPasswd = new TextField( )。 Button btnLogin = new Button(登錄 )。 Button btnReset = new Button(重設(shè) )。 public NullLayoutDemo( ) { (null)。 (new Rectangle(45, 38, 67, 34))。 (new Rectangle(115, 39, 210, 33))。 (new Rectangle(43, 86, 66, 26))。 (new Rectangle(115, 84, 210, 33))。 (39。*39。)。 (new Rectangle(78, 150, 86, 30))。 (new Rectangle(193, 150, 86, 30))。 (lblUserName)。 (txtUserName)。 (lblUserPasswd)。 (txtUserPasswd)。 (btnLogin)。 (btnReset)。 } public static void main( String[] args ) { NullLayoutDemo frmNullLayout=new NullLayoutDemo( )。 (new WindowAdapter( ){ public void windowClosing(WindowEvent e) {(0)。 }})。 ( )。 ( )。 } public Dimension getPreferredSize() { return new Dimension(355, 204)。 } } 運(yùn)行結(jié)果 菜單組件 菜單組件包括菜單欄 (MenuBar)、菜單 (Menu)和菜單項(xiàng) (MenuItem)三部分。通常, MenuBar中包含一個(gè)或多個(gè) Menu,每個(gè) Menu又包含一個(gè)或多個(gè) MenuItem。 創(chuàng)建菜單的基本步驟 ?創(chuàng)建 MenuBar ?創(chuàng)建 Menu,并加入到 MenuBar中 ?創(chuàng)建 MenuItem,并加入到 Menu中 ?將 MenuBar加入到容器中 ?事件處理 Swing—— 特點(diǎn) ? Swing是 100%的純 Java,不依賴于具體的操作系統(tǒng),可在各種平臺(tái)上實(shí)現(xiàn) ? Swing對(duì)很多 AWT組件進(jìn)行了重寫 ? Swing提供了可插入觀感 (Pluggable look and feel)技術(shù),可以讓用戶定制自己的桌面,以便更適合用戶的習(xí)慣和需求 模型 視圖 控制器體系 (modelviewcontroller) ? 維護(hù)數(shù)據(jù)并提供訪問數(shù)據(jù)的方法 ? 繪制和顯示模型數(shù)據(jù) ? 處理用戶與組件的交互。必要時(shí),更新模型或視圖以響應(yīng)用戶的行為 模型 (組件 數(shù)據(jù) ) 視圖 (外觀 ) 控制器 (響應(yīng) 事件 ) 用戶界面管理器 JComponent組件類 JComponent是所有 Swing組件的基類。它增加了以下功能: ?支持組件的可插入觀感 ?支持工具提示 ?當(dāng)組件被拖拽時(shí),支持列表或樹的自動(dòng)滾動(dòng) ?支持?jǐn)U展組件類,以創(chuàng)建自己需要的組件 JToggleButton組件 ? JToggleButton有稱反轉(zhuǎn)按鈕,具有“選取”和“取消選取”兩種狀態(tài),它是 JCheckBox和 JRadioButton的基類。 ? JToggleButton一般與 ButtonGroup一起搭配使用,組成具有相互排斥的選取組件。 構(gòu)造函數(shù) ? JToggleButton( ) ? JToggleButton(Icon) ? JToggleButton( String) ? JToggleButton(String,Icon ) ? JToggleButton( Icon,boolean) ? JToggleButton(String,boolean ) ? JToggleButton(String,Icon,boolean ) JRadioButton組件 ? JRadioButton( ) ? JRadioButton( Icon) ? JRadioButton( String) ? JRadioButton( String,Icon) ? JRadioButton( Icon,boolean) ? JRadioButton( String,boolean) ? JRadioButton( String,Icon,boolean) JPasswordField組件 //獲取口令 內(nèi)容 char[ ] getPassword( ) //將口令復(fù)制到緩沖區(qū),但不清除組件中輸入的口令 void copy( ) //將口令復(fù)制到緩沖區(qū),并清除組件中輸入的口令 void cut( ) char getEchoChar( ) //返回回顯字符 void setEchoChar(char c) //設(shè)置回顯字符 JProgressBar組件 進(jìn)度條組件主要用來反應(yīng)耗時(shí)任務(wù)完成的百分比,讓用戶知道任務(wù)完成的狀態(tài)。 JFrame容器組件 JFrame類不能直接添加組件和使用布局管理器,必須獲取一個(gè)內(nèi)容窗格,在此窗格中添加組件或使用布局管理器。 Component Container Window Frame JFrame 第 8 章 事件處理 事件 ? 事件是系統(tǒng)對(duì)其可能處于的某種狀態(tài)或某種操作的預(yù)先定義。例如:當(dāng) Quit菜單被選中時(shí),事件生成且啟用事件監(jiān)聽器進(jìn)行處理。 ? 事件監(jiān)聽器包括事件處理的代碼。 ? 幾乎所有圍繞 GUI進(jìn)行的活動(dòng)都會(huì)產(chǎn)生事件,但事件并不僅限于 GUI組件。 ? 事件發(fā)生后,系統(tǒng)可以自動(dòng)地啟用相應(yīng)的事件處理程序。 Java 采用基于 代理 (委托 )的事件模型,即產(chǎn)生事件的對(duì)象可以委托另外一個(gè)類對(duì)象對(duì)事件做出響應(yīng),其基本原理是:組件激發(fā)事件,事件監(jiān)聽器監(jiān)聽并進(jìn)行處理。 事件處理的基本過程 事件源 系統(tǒng)事 件隊(duì)列 dispatchEvent() processEvent() 調(diào)用特定的 事件處理方法 是否監(jiān)聽 放棄事件 分發(fā)事件 代理模型的三要素 ? 事件:具體的事件類型 ? 事件源:產(chǎn)生事件 ? 事件監(jiān)聽器:處理事件 EventObject AWTEvent ActionEvent TextEvent ItemEvent ComponentEvent
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1