Java adapter class



Share on Google+Share on Google+

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

October 27, 2010 at 4:48 PM


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(){
    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);



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
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 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
jdbc adapter exception - JDBC
jdbc adapter exception  Through JDBC, I connected to MySQL Server and Iam working with InnoDB database. I will want to disable foreign key checks in MySQL through my Java Application. For that I added "?sessionVariables
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
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 class - Java Beginners
java class  How to run a java class( automatically in tomcat server for a particular time
Java Class Size
Java Class Size  How to determine size of java class
converting java class to java fx class
converting java class to java fx class   i am working on a java project which would convert text to speech and speech to text. i have developed a java file that would work for text to speech. it is working fine as a .java file
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
Java dictionary class
Java dictionary class  What is the Dictionary class
java class - Java Beginners
java class  Define a class product with the following data members 1.Product number int(Auto generated) 2.Product name char [20] 3.Price float... program to execute the above class ad functions for 5 products
Java class file
Java class file  How do i open a java class file using eclipse
Example of HashMap class in java
Example of HashMap class in java. The HashMap is a class in java collection framwork. It stores values in the form of key/value pair. It is not synchronized
java Class - Java Beginners
java Class  Can anyone please explain what this code means? import java.util.TreeMap; import java.util.Iterator; //Please tell me what this class declaration means???????????? public class ST, Val> implements Iterable
Java abstract class
Java abstract class  Can an abstract class be final
Java file class
Java file class  What is the purpose of the File class
java Math class
java Math class  Why are the methods of the Math class static
Java math class
Java math class  Can you instantiate the Math class
abstact class - Java Beginners
abstact class  write a java program to implement an animal abstact class
Java System class
Java System class  What is the purpose of the System class
java anonymous class
java anonymous class  Can an anonymous class be declared as implementing an interface and extending a class
What is Calendar class in Java?
What is Calendar class in Java?  Hi, What is Calendar class in Java? I want to learn about this class to make use of it in Java programs. Thanks   Hi, java.util.Calendar is an abstract class in Java and its static
The nested class - Java Beginners
The nested class  Hi, What is nested class in Java? What is the benefits of nested class? Write examples of nested class. Thanks   .../java/n/java-nested-class.shtml Thanks
java class - Java Beginners
java class  wts need of this code? UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());   Hi Friend, If you want to give Window look to your frame,dialog box etc,then you have to use the following
How to create a class in java
How to create a class in java  I am a beginner in programming and tried to learn how to do programming in Java. Friends please explain how can I create a class in Java


Advertisement null