Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

Java adapter class

Ads

 
 

Share on Google+Share on Google+

samar
Java adapter class
1 Answer(s)      6 years and 9 months ago
Posted in : Java Interview Questions
What is adapter class?
Ads
View Answers

October 27, 2010 at 4:48 PM


Hi,

Here is the andwer,

In the following program code, the adapter class has been used. This class has been used as an anonymous inner class to draw a rectangle within an applet. This example demonstrates the functionality of the mouse press. That is on every click of the mouse from top left corner, we get a rectangle on the release of the bottom right.

The following program demonstrates the functionality of adapter class.

import java.applet.*;
import java.awt.*; 
import java.awt.event.*; 

public class AdapterDemo extends Applet{
  public void init(){
    addMouseListener(
    new MouseAdapter(){
      int topX, bottomY;
      public void mousePressed(MouseEvent me){
        topX = me.getX();
        bottomY = me.getY();
      }
      public void mouseReleased(MouseEvent me){
        Graphics g = AdapterDemo.this.getGraphics();
        g.drawRect(topX, bottomY, me.getX()-topX, me.getY()-bottomY);
      }
    });
  }
}

Thanks.


Ads









Related Tutorials/Questions & Answers:
Java adapter class
Java adapter class  What is adapter class
Adapter Class
Adapter Class  Hello Everybody, Can anybody help me to describe what is Adapter class and when to use this class and give a suitable example... visit the following links: What is Adapter Class Example of Adapter Class
Advertisements
Adapter class
Adapter class  here may I use paint metod?If not then whats the error comes here
Java Glossary : Adapter Classes
The developer can then further subclass the adapter class so that he can override to the methods he requires. Implementing an interface directly, requires to write all the dummy methods
java class
java class  write a java program to display a msg "window closing" when the user attempts to close the window.(a) create a window class (b) create frame within the window class (c) extends window adapter class to display the msg
Version of co.openfin>openfin-desktop-java-adapter dependency
List of Version of co.openfin>openfin-desktop-java-adapter dependency
Maven Dependency openfin-desktop-java-adapter >> 3.0.1.2
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version3.0.1.2 in your project
Maven Dependency openfin-desktop-java-adapter >> 3.0.1.3
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version3.0.1.3 in your project
Maven Dependency openfin-desktop-java-adapter >> 4.40.2.5
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version4.40.2.5 in your project
Maven Dependency openfin-desktop-java-adapter >> 4.40.2.6
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version4.40.2.6 in your project
Maven Dependency openfin-desktop-java-adapter >> 4.40.2.8
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version4.40.2.8 in your project
Maven Dependency openfin-desktop-java-adapter >> 4.40.2.9
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version4.40.2.9 in your project
Maven Dependency openfin-desktop-java-adapter >> 5.44.2.0
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version5.44.2.0 in your project
Maven Dependency openfin-desktop-java-adapter >> 5.44.2.2
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version5.44.2.2 in your project
Maven Dependency openfin-desktop-java-adapter >> 5.44.2.3
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version5.44.2.3 in your project
Maven Dependency openfin-desktop-java-adapter >> 5.44.2.4
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version5.44.2.4 in your project
Maven Dependency openfin-desktop-java-adapter >> 5.44.3.1
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version5.44.3.1 in your project
Maven Dependency openfin-desktop-java-adapter >> 5.44.3.2
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version5.44.3.2 in your project
Maven Dependency openfin-desktop-java-adapter >> 5.44.3.4
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version5.44.3.4 in your project
Maven Dependency openfin-desktop-java-adapter >> 5.44.3.6
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version5.44.3.6 in your project
Maven Dependency openfin-desktop-java-adapter >> 6.0.0.1
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version6.0.0.1 in your project
Maven Dependency openfin-desktop-java-adapter >> 6.0.0.2
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version6.0.0.2 in your project
Maven Dependency openfin-desktop-java-adapter >> 6.0.1.0
You should include the dependency code given in this page to add Maven Dependency of co.openfin >> openfin-desktop-java-adapter version6.0.1.0 in your project
Java class
Java class  What is the purpose of the Runtime class
java class
java class  please send me the answer of the question which i have send according of java class assoon as possible . Write a java program to display.... a. Create a window class. b. Create frame within the window class. c. Extend
Java KeyAdapter
Java KeyAdapter       This is an abstract adapter class used to receive keyboard events. This is the class is used to receive the keyboard events. It creates the keyListener objects
java class - Java Beginners
java class  How to run a java class(Mail.java) automatically in tomcat server for a particular time
Java Class Size
Java Class Size  How to determine size of java class
Java inner class and static nested class
Java inner class and static nested class  Java inner class and static nested class
Java inner class
Java inner class  What are inner class and anonymous class
class method in java
class method in java  How to write a class method in Java?   You must read Java - Class, Object and Methods in Java