Skip to main content

Posts

Showing posts from April, 2018

Reactangle example in java

                    Swing Rectangle example Rectangles   To draw rectangles, we use the drawRect() method. To fill rectangles with the current color, we use the fillRect() method.   package PRACTICEPROGRAM; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; class DrawPanel extends JPanel {       public void paintComponent(Graphics g) {         super.paintComponent(g);         Graphics2D g2d = (Graphics2D) g;             g2d.setColor(new Color(212, 212, 212));             g2d.drawRect(10, 15, 90, 60);          ...

C Instructions

                            C Instructions   C Instructions There are basically four types of instructions in C: (a)    Type Declaration Instruction (b)    Input/Output Instruction (c)    Arithmetic Instruction (d)    Control Instruction (a)    Type Declaration Instruction This instruction is used to declare the type of variables being used in the program. Ex.-    int bas;     Float rs,grosssal;     Char name,code; (b)    Input/Output Instruction To perform the function of supplying input data to a program and obtaining the output results from it. Printf ()          Output Scanf()           Input   (c )   Arit...

C variable and Keywords

      C Introduction variable and  Keywords Rules for Constructing Character Constants 1.    A character constant is a single alphabet a single digits or a single       Special symbol enclosed within single inverted commas. 2.    The Maximum length of a character constant can be 1 character. Variables: -     In C a quantity that may vary during program execution is called a variable. Rules for Constructing Variable Name 1.    A variable name is any combination of alphabets, digits or underscores. 2.    The first character in the variable name must be an alphabet. 3.    No Commas or blank are allowed within a variable name. 4.    No special symbol other than an underscore can be used in a variable name. Keywords: Keywords are the words whose meaning has already been explained to the C compiler There are only 32 Keyword...

Explanation of line example

               Explanation of line example in java   In the example, we draw five lines. The first line is drawn using the default values. Other will have a different stroke. The stroke is created using the BasicStroke class. It defines a basic set of rendering attributes for the outlines of graphics primitives.  float[] dash1 = { 2f, 0f, 2f };   Here we create a dash, that we use in the stroke object. BasicStroke bs1 = new BasicStroke(1, BasicStroke.CAP_BUTT,     BasicStroke.JOIN_ROUND, 1.0f, dash1, 2f ) This code creates a stroke. The stroke defines the line width, end caps, line joins, miter limit, dash and the dash phase. Join us on Facebook:  Click Here  

C Introduction

                                   C introduction   C Programming                                  C has been written in assembly languages .C is a robust language with a rich set of built-in function and operator.Programs those are written in C are highly portable.C does not provide Object Oriented Programming (OOPs) concepts.C does not provide Constructor and Destructors. Rules for Constructing Character Constants 1.    A character constant is a single alphabet a single digits or a single         Special symbol enclosed within single inverted commas. 2.    The Maximum length of a character constant can be 1 character. Variables ...

Line example

                              Line example in java Lines A line is a simple graphics primitive. It is drawn using two points. package PRACTICEPROGRAM; import java.awt.BasicStroke; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; class DrawPanel extends JPanel {     public void paintComponent(Graphics g) {         super.paintComponent(g);         Graphics2D g2d = (Graphics2D) g;             float[] dash1 = { 2f, 0f, 2f };             float[] dash2 = { 1f, 1f, 1f };             ...

Explanation of Points example

                       Points example in JAVA   Click here for the example One point is difficult to observe. Why not paint 1000 of them. In our example, we do so. We draw 1000 blue points on the panel. class DrawPanel extends JPanel {        We are drawing on a custom drawing panel, which is a JPanel component. The drawing panel will later be added to a JFrame component. public void paintComponent(Graphics g) {     super.paintComponent(g); The painting is performed inside the paintComponent() method. Graphics2D g2d = (Graphics2D) g; Painting in Swing is done on the Graphics2D object. g2d.setColor(Color.blue); We will paint our points in blue color. Dimension size = getSize(); Insets insets = getInsets(); The size of the window includes borders and tit...