Java adapter class

Ads

 
 

Share on Google+Share on Google+

samar
Java adapter class
1 Answer(s)      7 years 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 com.cookingfox>eventbus-adapter-java dependency
List of Version of com.cookingfox>eventbus-adapter-java dependency
Version of com.cookingfox>logging-adapter-java dependency
List of Version of com.cookingfox>logging-adapter-java dependency
Version of co.openfin>openfin-desktop-java-adapter dependency
List of Version of co.openfin>openfin-desktop-java-adapter dependency
Maven Dependency eventbus-adapter-java >> 2.0.0
You should include the dependency code given in this page to add Maven Dependency of com.cookingfox >> eventbus-adapter-java version2.0.0 in your project
Maven Dependency eventbus-adapter-java >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.cookingfox >> eventbus-adapter-java version1.0.0 in your project
Maven Dependency logging-adapter-java >> 0.2.2
You should include the dependency code given in this page to add Maven Dependency of com.cookingfox >> logging-adapter-java version0.2.2 in your project
Maven Dependency logging-adapter-java >> 0.3.2
You should include the dependency code given in this page to add Maven Dependency of com.cookingfox >> logging-adapter-java version0.3.2 in your project
Maven Dependency logging-adapter-java >> 0.1.2
You should include the dependency code given in this page to add Maven Dependency of com.cookingfox >> logging-adapter-java version0.1.2 in your project
Maven Dependency logging-adapter-java >> 0.3.1
You should include the dependency code given in this page to add Maven Dependency of com.cookingfox >> logging-adapter-java version0.3.1 in your project
Maven Dependency logging-adapter-java >> 0.4.0
You should include the dependency code given in this page to add Maven Dependency of com.cookingfox >> logging-adapter-java version0.4.0 in your project
Maven Dependency logging-adapter-java >> 0.3.0
You should include the dependency code given in this page to add Maven Dependency of com.cookingfox >> logging-adapter-java version0.3.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
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

Ads

 
Advertisement null

Ads