Total members 11609 |It is currently Tue Feb 21, 2017 3:48 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka

All times are UTC [ DST ]



  Draw Flag in Java
Wed May 06, 2009 3:24 am 

Draw your country Flag in Java
This is the flag class :
Code:

import javax
.swing.*;
import java.awt.*;
/**
 
  Flag Description:
two equal vertical bands of green (hoist side) and white;
a red, five-pointed star within a red crescent centered
over the two-color boundary; the crescent, star,
and color green are traditional symbols.
 */

public class AlgerianFlag extends JComponent{
    public void paint( Graphics g )
    {

        Graphics2D g2 = ( Graphics2D ) g;
        
// draw the green space
        g2.setColor(Color.blue); 
        g2
.fillRect(0, 0, 600, 600);
// draw the green space
        g2.setColor(Color.GREEN); 
        g2
.fillRect(50, 50, 150, 200);
        
// draw the white space
        g2.setColor(Color.WHITE); 
        g2
.fillRect(200, 50, 150, 200);
        
        
    
}
}


and this is the test class:

import javax.swing.*;
import java.awt.*;

public class AlgerianFlagTest {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        // draw the red star
    
//create new frame object 
        JFrame frame = new JFrame ("Algeria");        
// set the size of the frame
        frame.setSize(600 ,600);
// set the location of the frame
        frame.setLocation(100,100);
// create new object of type flag
        AlgerianFlag flag = new AlgerianFlag();
// add the object flag to the frame
        frame.add(flag);
//display the frame and close the program when close is pushed
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    
    
}
            }

 




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Draw Flag in Java
 Get table column flag in php     -  
 Draw An Arc in java     -  
 draw Calendar in java     -  
 draw Oval in java     -  
 draw text effects in java     -  
 Draw Dashed Oval in java     -  
 Changing the color of a graph draw in java     -  
 Java code to draw shortest path tree     -  
 draw cube 3d java-Cube 3D     -  
 How to draw a gun     -  

All times are UTC [ DST ]



Topic Tags

Java Graphics






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team