You
can see all event methods in java.awt.Event class and
java.awt.event.FocusListener is an Interface that includes methods named
focusGained() and focusLost() and both takes FocusEvent as an argument.
javap java.awt.event.FocusListener(type over command prompt)
echo %path%(type over command prompt to check path)
Step 1: Create a java source file with name SecondEvent.java that is name of java class and it is mandatory that class name and file name must be same. Applet class must be public.
In java source file commented applet code will not be compile by java compiler but will executed by AppletViewer.
In command addFocusListener(this) "this" keyword refers as object of current class. we can also write "new SecondEvent()" at place of "this" keyword.
Download Code Link 1
Download Code Link 2
Step 2: Run cmd(command prompt) and compile java source file, SecondEvent.class file'll be build.then give appletviewer command and applet will pop out.
Output:
javap java.awt.event.FocusListener(type over command prompt)
echo %path%(type over command prompt to check path)
Step 1: Create a java source file with name SecondEvent.java that is name of java class and it is mandatory that class name and file name must be same. Applet class must be public.
In java source file commented applet code will not be compile by java compiler but will executed by AppletViewer.
In command addFocusListener(this) "this" keyword refers as object of current class. we can also write "new SecondEvent()" at place of "this" keyword.
Download Code Link 1
Download Code Link 2
Step 2: Run cmd(command prompt) and compile java source file, SecondEvent.class file'll be build.then give appletviewer command and applet will pop out.
Output:
Focus Gained |
Focus Lost |
More Applet Topics :
- Applet lifecycle
- Basic Applet Program
- Applet using html
- How to handle image with Applets
- How to Move a Banner with Applet class and Runnable Interface
- Explore Applet by creating textbox,checkbox,list,radio button
- Component class methods mouseEnter,mouseExit and action used with applet
- Event handling using applet class and ActionListener interface
- Event handling using applet class and FocusListener interface
- Login using applet class and ActionListener interface
- Simple calculator using Java Applet and Event Handling
No comments:
Post a Comment