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

正文內(nèi)容

java面向?qū)ο蟪绦虻脑O(shè)計(jì)(董小園版)-資料下載頁(yè)

2025-06-25 07:00本頁(yè)面
  

【正文】 (new BorderLayout())。 PanNumber pan = new PanNumber()。 (txfResult,)。 (pan)。 setDefaultCloseOperation()。 setVisible( true )。 }}// import 。import 。import 。public class PanNumber extends JPanel { PanNumber(){ setLayout(new GridLayout(4,4))。 addButton(7)。 addButton(8)。 addButton(9)。 addButton(/)。 addButton(4)。 addButton(5)。 addButton(6)。 addButton(*)。 addButton(1)。 addButton(2)。 addButton(3)。 addButton()。 addButton(0)。 addButton(.)。 addButton(=)。 addButton(+)。 } void addButton(String s){ JButton btn = new JButton(s)。 add(btn)。 } } 第11章 可視化程序的事件處理1. 編寫(xiě)程序,能夠在窗體內(nèi)顯示被點(diǎn)擊按鈕的信息。運(yùn)行效果圖如下:// import .*。import .*。public class MyFrame extends JFrame implements ActionListener{ JButton btnOK,btnCancel。 JLabel lab。 MyFrame(String s){ super(s)。setSize(200,200)。setLocationRelativeTo(null)。 JPanel pan = new JPanel()。setContentPane(pan)。 btnOK = new JButton(OK)。 (this)。 btnCancel = new JButton(Cancel)。 (this)。 lab = new JLabel( )。 (btnOK)。 (btnCancel)。 (lab)。setDefaultCloseOperation()。 setVisible( true )。 } public void actionPerformed(ActionEvent e){ if(()==btnOK) (點(diǎn)擊了確定按鈕)。 if(() .equals(Cancel)) (點(diǎn)擊了取消按鈕)。 }}// public class EventDemo { public static void main(String[] args) { MyFrame frm = new MyFrame(按鈕事件演示)。 }}2. 編寫(xiě)程序,實(shí)現(xiàn)如下界面,當(dāng)用戶在文本框中輸入內(nèi)容后,點(diǎn)擊不同的按鈕,能夠把文本框中的內(nèi)容粘貼到文本區(qū)中?!爸刂谩卑粹o實(shí)現(xiàn)將文本框和文本區(qū)中的內(nèi)容清空。界面上的文本區(qū)只能顯示內(nèi)容,不能讓用戶輸入文本。提示:得到文本框中的文本、得到選中的文本、設(shè)置文本區(qū)中的文本、附加文本等,設(shè)置文本區(qū)不可用等,JTextField和JTextArea類均有相應(yīng)方法實(shí)現(xiàn)。//import .*。import .*。import .*。public class MyFrame extends JFrame implements ActionListener{ JButton btnPasteAll,btnPasteSeleted,btnAppendAll,btnAppendSeleted,btnReset。 JTextField txt 。 JTextArea txa。 JPanel pan = new JPanel()。 MyFrame(String s){ super(s)。 setSize(250,300)。 (null)。 setContentPane(pan)。 txt = new JTextField(20)。 txa = new JTextArea(5,20)。 (false)。 //(false)。 btnPasteAll = new JButton(粘貼全部)。 btnPasteSeleted = new JButton(粘貼所選)。 btnAppendAll = new JButton(附加全部)。 btnAppendSeleted = new JButton(附加所選)。 btnReset = new JButton(重置)。 (this)。 (this)。 (this)。 (this)。 (this)。 (txt)。 (txa)。 ()。 ()。 ()。 ()。 ()。 ()。 setVisible( true )。 } public void actionPerformed(ActionEvent e){ if(()==) (())。 if(()==) (())。 if(()==) (())。 if(()==) (())。 if(()==){ ()。 ()。 } }}//public class EventDemo { public static void main(String[] args) { MyFrame frm = new MyFrame(按鈕事件演示)。 }}3. 模仿例題,實(shí)現(xiàn)在窗體內(nèi)移動(dòng)鼠標(biāo)時(shí),能夠?qū)崟r(shí)顯示鼠標(biāo)指針的坐標(biāo)位置。// import 。import 。import .*。public class MouseFrame extends JFrame implements MouseMotionListener { JPanel pan。 JLabel lab。 MouseFrame(String s){ super(s)。 setSize(200,200)。 setLocationRelativeTo(null)。 pan = new JPanel()。 setContentPane(pan)。 lab = new JLabel()。 (lab)。 addMouseMotionListener(this)。 setDefaultCloseOperation()。 setVisible( true )。 } public void mouseDragged(MouseEvent e) { } public void mouseMoved(MouseEvent e) { int x = ()。 int y = ()。 String s = (+x+,+y+)。 (s)。 (x,y,50,20)。 }}// public class EventDemo { public static void main(String[] args) { MouseFrame frm = new MouseFrame(鼠標(biāo)事件演示)。 }}4. 參考例題,編寫(xiě)程序,給界面上的文本框增加鍵盤(pán)事件處理,當(dāng)在文本框中輸入內(nèi)容時(shí),界面上不可編輯的文本區(qū)顯示相應(yīng)的按鍵信息。實(shí)現(xiàn)原理:在鍵盤(pán)事件接口的三個(gè)方法中均得到按鍵碼,再根據(jù)按鍵碼轉(zhuǎn)換為按鍵信息,增加到文本區(qū)中顯示。(())提示:最好使用帶滾動(dòng)窗格的文本區(qū)。輸出按鍵信息的同時(shí)還輸出方法名稱,以方便觀察按鍵事件處理的先后順序。//KeyEventFrame .javaimport 。import 。import 。import .*。public class KeyEventFrame extends JFrame implements KeyListener { JTextField txt。 JTextArea txa。 JScrollPane scroll。 JPanel pan。 KeyEventFrame(String s){ super(s)。 setSize(500,300)。 setLocationRelativeTo(null)。 txt = new JTextField()。 txa = new JTextArea()。 (false)。 scroll = new JScrollPane(txa)。 pan = new JPanel()。 (new BorderLayout())。 (txt,)。 (scroll,)。 setContentPane(pan)。 (this)。 setDefaultCloseOperation()。 setVisible( true )。 } public void keyTyped(KeyEvent e) { // TODO Autogenerated method stub (keyTyped: + () +\n)。 } public void keyPressed(KeyEvent e) { // TODO Autogenerated method stub (keyPressed: +(())+\n)。 } public void keyReleased(KeyEvent e) { // TODO Autogenerated method stub (keyReleased: +(())+\n)。 }}// public class EventDemo { public static void main(String[] args) { KeyEventFrame frm = new KeyEventFrame(鍵盤(pán)事件演示)。 }}5. 編寫(xiě)程序,實(shí)現(xiàn)使用鍵盤(pán)上的上下左右箭頭控制界面上圖片的移動(dòng)。移動(dòng)到邊界時(shí)從界面另一側(cè)出現(xiàn)。移動(dòng)過(guò)程中顯示另一個(gè)圖片,停止時(shí)恢復(fù)原來(lái)的圖片。// import 。import 。import .*。public class KeyEventFrame extends JFrame implements KeyListener { JPanel pan。 JLabel lab。 Icon icon1 = new ImageIcon()。 Icon icon2 = new ImageIcon()。 int x,y。 KeyEventFrame(String s){ super(s)。 (400,300)。 (null)。 pan = new JPanel()。 (pan)。 (null)。 lab = new JLabel(icon1)。 x = (()50)/2。 y = (()50)/2。 (x,y,50,50)。 (lab)。 (this)。 ()。 (true)。 } public void keyTyped(KeyEvent arg0) { // TODO Autogenerated method stub } public void keyPressed(KeyEvent e) { // TODO Autogenerated method stub int keycode = ()。 if(keycode == ) y = y=50?()50:y5。 if(keycode == ) y = y=()?0:y+5。 if(keycode == ) x = x=50?()50:x5。 if(keycode == ) x = x=()?0:x+5。 (icon2)。 (x,y,50,50)。 } public void keyReleased(KeyEvent arg0) { // TODO Autogenerated method stub (icon1)。 }}// public class GUIDemo
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1