All About Class Canvas in AWT in Java



A canvas component represents a blank rectangular area of the screen onto which the application can draw or form which the application can trap input events from the user.An application must sub class the canvas class in order to get useful functionality such as creating a custom components. The paint method must be overridden in order to perform custom graphics on the canvas.The mouse,keyboard and focus events that may occur over canvas can be understood or sensed.The below methods may be overridden in order to catch user events-

  • gotFocus()
  • lostFocus()
  • keyDown()
  • keyUp()
  • mouseEnter()
  • mouseExit()
  • mouseMove()
  • mouseDrag()
  • mouseDown()
  • mouseUp()
The structure of the Class Canvas is given as:

public class java.awt.Canvas extends java.awt.Component{
//constructor
public Canvas();
//Methods
public void addNotify();
public void paint(Graphics g);
}
 
All About Class Canvas in AWT in Java All About Class Canvas in AWT in Java Reviewed by Animesh Chatterjee on October 23, 2018 Rating: 5

No comments:

Powered by Blogger.