All About Class Canvas in AWT in Java

0
154
Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

Class Canvas in AWT in Java
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);
}
 
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here