I am very new to Java and I am currently writing a program that should display the US Flag along with the originals 49 stars. I am attaching what I have....are there any ideas so I can get this project completed....I am using a book called teach yourself Java 2
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
////////// Flag
public class Flag
{
///////main
public static void main (String [] args)
{
JFrame windo = new FlagWindow();
windo.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
windo.setVisible(true);
}//end class Flag
class FlagWindow extends JFrame {
FlagWindow() {
Container content = this.getContentPane();
content.setLayout(new BorderLayout());
MyDrawing drawing = new MyDrawing ();
content.add(drawing, BorderLayout.CENTER);
this.setTitle("The Freedom Flag"
this.pack();
}//end settings
}//endclass FlagWindow
class MyDrawing extends JPanel {
////Constructor
MyDrawing (){
public void paintComponent(Graphics g)
{
super.paintComponent(g);
setPreferredSize(new Dimension(900, 700)); //screen size
this.setBackground(Color.black);
int w = getWidth( );
int h = getHeight();
double w1 = (2/3)*w; //flag width
double h1 = (2/3)*h; // flag height
double stripesHeight = (h1/13); //dividing the screen into equal number of stripes
double y = stripesHeight;
g.fillRect(w/6. h/6. (2/3)*w. (2/3)*h);
g.setColor(Color.red);
while
(y < (5/6) *w);
{
g.fillRect(w/6. (h/6. + y). (2/3)*w. (2/3)*h);
g.setColor(Color.white);
y = y + (2 stripesHeight);
}//end constructor
}//end paintComponent
}//endclass MyDrawing
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
////////// Flag
public class Flag
{
///////main
public static void main (String [] args)
{
JFrame windo = new FlagWindow();
windo.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
windo.setVisible(true);
}//end class Flag
class FlagWindow extends JFrame {
FlagWindow() {
Container content = this.getContentPane();
content.setLayout(new BorderLayout());
MyDrawing drawing = new MyDrawing ();
content.add(drawing, BorderLayout.CENTER);
this.setTitle("The Freedom Flag"
this.pack();
}//end settings
}//endclass FlagWindow
class MyDrawing extends JPanel {
////Constructor
MyDrawing (){
public void paintComponent(Graphics g)
{
super.paintComponent(g);
setPreferredSize(new Dimension(900, 700)); //screen size
this.setBackground(Color.black);
int w = getWidth( );
int h = getHeight();
double w1 = (2/3)*w; //flag width
double h1 = (2/3)*h; // flag height
double stripesHeight = (h1/13); //dividing the screen into equal number of stripes
double y = stripesHeight;
g.fillRect(w/6. h/6. (2/3)*w. (2/3)*h);
g.setColor(Color.red);
while
(y < (5/6) *w);
{
g.fillRect(w/6. (h/6. + y). (2/3)*w. (2/3)*h);
g.setColor(Color.white);
y = y + (2 stripesHeight);
}//end constructor
}//end paintComponent
}//endclass MyDrawing