Total members 11894 |It is currently Thu Nov 21, 2024 6:43 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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     -  



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
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com