⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 12_5.htm

📁 翁剀JAVA语言那门课程的教案 很多人都看多他的视频教程可惜没有ppt的教案
💻 HTM
字号:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"><html><head>   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">   <meta name="Author" content="Weng Kai">   <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win95; I) [Netscape]">   <title>Alternatives to action</title></head><body><h2>12.5 Alternatives to action</h2><hr WIDTH="100%"><br>As noted previously, action( ) isn't the only method that's automaticallycalled by handleEvent( ) once it sorts everything out for you. There arethree other sets of methods that are called, and if you want to capturecertain types of events (keyboard, mouse, and focus events) all you haveto do is override the provided method. These methods are defined in thebase class Component, so they're available in virtually all the controlsthat you might place on a form. However, you should be aware that thisapproach is deprecated in Java 1.1,so although you might see legacy codeusing this technique you should use the Java 1.1approaches (described laterin this chapter) instead.<br>&nbsp;<br>&nbsp;<table BORDER COLS=2 WIDTH="100%" ><tr><td>Component method</td><td>When it's called</td></tr><tr><td>action (Event evt, Object what)</td><td>When the "typical" event occurs for this component (for<br>example, when a button is pushed or a drop-down list item is selected)</td></tr><tr><td>keyDown (Event evt, int key)</td><td>A key is pressed when this component has the focus. The second argumentis the key that was pressed and is redundantly copied from <b>evt.key</b>.</td></tr><tr><td>keyUp(Event evt, int key)</td><td>A key is released when this component has the focus.</td></tr><tr><td>lostFocus(Event evt, Object what)</td><td>The focus has moved away from the target. Normally, what is redundantlycopied from <b>evt.arg</b>.</td></tr><tr><td>gotFocus(Event evt, Object what)</td><td>The focus has moved into the target.</td></tr><tr><td>mouseDown(Event evt, int x, int y)</td><td>A mouse down has occurred over the component, at the coordinates x,y.</td></tr><tr><td>mouseUp(Event evt, int x, int y)</td><td>A mouse up has occurred over the component.</td></tr><tr><td>mouseMove(Event evt, int x, int y)</td><td>The mouse has moved while it's over the component.</td></tr><tr><td>mouseDrag(Event evt, int x, int y)</td><td>The mouse is being dragged after a mouseDown occurred over the component.All drag events are reported to the component in which the mouseDown occurreduntil there is a <b>mouseUp</b>.</td></tr><tr><td>mouseEnter(Event evt, int x, int y)</td><td>The mouse wasn't over the component before, but now it<br>is.</td></tr><tr><td>mouseExit(Event evt, int x, int y)</td><td>The mouse used to be over the component, but now it isn't.</td></tr></table><p>You can see that each method receives an Event object along with someinformation that you'll typically need when you're handling that particularsituation 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -