Skip to main content

Posts

Showing posts from April, 2017

Canvas class example in java

           Canvas class example on buttons import java.applet.*; import java.awt.*; import java.awt.event.*; public class CanvasDemo extends Applet implements ActionListener {             Canvas c;             Button bred,bgreen,bblue;             public void init()             {                         bred=new Button("Red");                         add(bred);                ...

Canvas class

                        Canvas class   Canvas class : The Canvas class is used for creating the small drawing object , which can we used for coloring , drawing graphs, lines etc.. The constructor of the Canvas class is ,             Canvas() It is the default constructor of the Canvas class. Method : a)  setSize() :This method is used to specify the size of the applet. The general form is ,             setSize(int x,int y) where ,             x and y specify the width and height of the canvas in pixels b) setBackground() : This method is used to set the Background color of the canvas. The ge...