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

正文內(nèi)容

awt組件庫(ppt130)-經(jīng)營管理(編輯修改稿)

2024-09-21 16:02 本頁面
 

【文章內(nèi)容簡介】 main(String args[]) { TextExample te = new TextExample(); (); } public void go() { f = new Frame(Text Example); ( new FlowLayout() ); tf1 = new TextField(Init,20); (this); (this); ta1 = new TextArea(Initial text,4,30); (this); ta2 = new TextArea(Only horizontal scrollbar , 4, 30, HORIZONTAL_ONLY); } (tf1); (ta1); (ta2); (300,300); (true); public void actionPerformed(ActionEvent e) { (\nActionPerformed); } public void textValueChanged(TextEvent e) { (\nTextValueChanged); } } 文本組件 ?雖然 TextArea和 TextField是兩個不同的類,但是如果查閱名為 TextComponent類的文檔,就會發(fā)現(xiàn)這個類定義了很多 TextArea類和 TextField類共有的方法,這是因為該類是 TextArea類和 TextField類的父類。 TextComponent類中定義的主要方法 ?getSelectedText( )從文本組件中提取被選中的文本內(nèi)容。 ?getText( )從文本組件中提取所有文本內(nèi)容。 ?select(int, int)在文本組件中選中部分內(nèi)容。 ?selectAll( )在文本組件中選中所有內(nèi)容。 ? setEditable(boolean)設(shè)置為可編輯或不可編輯狀態(tài)。 ? setText(String)設(shè)置文本組件中的文本內(nèi)容。 列表 ? 列表( List) 是可供用戶進行選擇的一系列可選項,它支持 單項選擇 和 多項選擇 。 ? 三種構(gòu)造方法: ? public List( ) 構(gòu)造一個單選列表。 ? public List(int rows) 構(gòu)造一個顯示指定項數(shù)的單選列表,其中 int型參數(shù)指定要顯示的項數(shù)。 ? public List(int rows, boolean multipleMode) 構(gòu)造一個顯示指定項數(shù)的列表。其中 int型參數(shù)指定要顯示的項數(shù), boolean型參數(shù)指定該列表是單選( false)列表還是多選( true)列表。使用addItem( )方法向列表中加入可選項。 列表 例如: List l = newList(4, false); //這條命令構(gòu)造一個顯示 4項的單選列表。 列表 ? 當用戶單擊列表中的可選項時,將引發(fā)ItemEvent事件,該事件需要ItemListener接口中的itemStateChanged()方法進行處理。 ? 當用戶雙擊列表中的可選項時,將引發(fā)ActionEvent事件,該事件需要由ActionListener接口中的actionPerformed()方法進行處理。 程序 98: 目標: 構(gòu)造一個顯示 5個可選項的單選列表,通過 ItemListener接口中的 itemStateChanged( )方法,用戶的選擇被顯示在窗口底部。 import .*; import .*; public class ListExample extends Frame implements ItemListener{ Panel p; List theList; TextField tf; ListExample( String s ){ super( s ); } public static void main( String args[] ){ ListExample le = new ListExample (List Example ); (); } void init(){ // 構(gòu)造一個顯示 5個可選項的單選列表 theList = new List(5,false ); ( Monday ); ( Tuesday ); ( Wednesday ); ( Thursday ); ( Friday ); ( Saturday ); ( Sunday ); // 注冊 ItemEvent事件監(jiān)聽程序 (this); p = new Panel(); (theList ); add(p,Center); tf = new TextField(); add(tf,South); setSize(300,200); setVisible(true); } // 實現(xiàn) ItemListener接口中的方法 public void itemStateChanged(ItemEvent e) { (()); } } 框架 ? 框架 是一種帶 標題框 和 邊框 并且 能夠改變大小 的窗口。 ? 兩種構(gòu)造方法: (1) Frame( ) 構(gòu)造一個沒有標題的框架。 (2) Frame(String) 構(gòu)造一個顯示指定標題的框架。 框架 例如: Frame f = new Frame(“Frame Example”); /*這條命令構(gòu)造一個標題為“ Frame Example”的框架。 */ 框架 ?框架的默認布局管理器是 BorderLayout。 ?框架的大小可用 setSize( )方法設(shè)定,然而更常用的方法是使用 pack( )。 ?pack( )能夠使布局管理器進行計算,得出一個適當?shù)目蚣艽笮。沟每蚣芤跃o縮形式包容其中的組件。 框架 ?框架可對多種事件進行監(jiān)聽。 ?框架能夠作為單獨窗口使用。 ?當用戶從窗口控制菜單中選擇關(guān)閉窗口時,將引發(fā) WindowEvent事件,可以用WindowListener接口中的 WindowClosing( )方法對此進行 處理。 框架 ?如果需要監(jiān)聽鍵盤事件,最好還是在框架中加入畫布或面板之類的組件,然后再通過這類組件對鍵盤事件進行監(jiān)聽 。 面板 ?面板 通常只作為純粹的容器來使用,它不能像框架、窗口或?qū)υ捒蚰菢营毩⒋嬖冢? ?在面板中也可對多種事件進行監(jiān)聽。與畫布類似,當處理鍵盤事件時,需要事先取得焦點。 面板 ? 兩種構(gòu)造方法: (1) Panel() 構(gòu)造一個使用默認布局管理器( FlowLayout)的面板。 (2) Panel(LayoutManager) 構(gòu)造一個使用指定布局管理器的面板 面板 例如: Panel p = new Panel( ); /*這條命令構(gòu)造一個使用 FlowLayout布局管理器的面板。 */ 對話框 ?對話框( Dialog) 是與框架類似的 可移動窗口 ,它與 框架的區(qū)別 在于具有較少的修飾并且能夠被設(shè)置為“模式( modal)”窗口 ——在該窗口被關(guān)閉之前,其他窗口無法接收任何形式的輸入。 對話框 ?四種構(gòu)造方法: (1) public Dialog(Frame parent) 構(gòu)造一個 沒有標題 的對話框。 (2) public Dialog(Frame parent, boolean modal) 構(gòu)造一個 沒有標題 的對話框, boolean型參數(shù)指定對話框是否為模式窗口。 對話框 ?四種構(gòu)造方法: (3) public Dialog(Frame parent, String title) 構(gòu)造一個 顯示指定標題 的對話框。 (4) public Dialog(Frame parent, String title, boolean modal) 構(gòu)造一個 顯示指定標題的對話框 ,boolean型參數(shù)指定對話框是否為模式窗口 。 對話框 例如: Dialog d = new Dialog(f, Dialog,true); /*這條命令構(gòu)造一個標題為 Dialog的模式對話框,該對話框由框架 f所擁有。 */ 對話框 ?剛剛創(chuàng)建的對話框是不可見的,需要調(diào)用setVisible(true)方法才能將其顯示出來。 ?當對話框不需要顯示時,調(diào)用setVisible(false)方法可以將一個對話框隱藏起來。 ?對話框可對各種窗口事件( WindowEvent)進行監(jiān)聽。 程序 99: 目標: 構(gòu)造對話框,單擊其中的按鈕時,顯示對話框。 import .*; import .*; public class DialogExample extends WindowAdapter implements ActionListener{ Frame f; Button b; Dialog d; static public void main(String args[]) { DialogExample de = new DialogExample(); (); } public void go() { f = new Frame(Dialog Example); b = new Button(Show Dialog); (this); (South,b); d = new Dialog(f,Dialog,true); (Center,new Label (Hello,I’m a Dialog)); (); (this); (250,150); (true); } public void actionPerformed(ActionEvent e) { // 顯示對話框 (true); } public void windowClosing(WindowEvent e) { // 隱藏對話框 (false); }} 文件對話框
點擊復制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1