Results 1 to 6 of 6
Thread: help pleaseee
- 05-03-2012, 07:44 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 8
- Rep Power
- 0
- 05-03-2012, 07:45 PM #2
Member
- Join Date
- Apr 2012
- Posts
- 8
- Rep Power
- 0
Re: help pleaseee
In this assignment you will write a program to generate random boxes on a 500 x 500 pixel screen. You are to have the program draw 30 boxes. The boxes must have a random position and a random height and width. Make sure that all boxes show up in the window. Here are a couple more stipulations:
1. If the boxes have a width less than 15 they need to be filled in with magenta.
2. If the boxes have a height less than 50 and a width greater than 15 they need to be filled in with blue.
3. All other boxes are just drawn and not filled in.
import javax.swing.*;
import java.awt.*;
public class as19 extends JFrame {
Container con = getContentPane();
public as19(){
con.setBackground(Color.BLUE);
}
public void paint(Graphics gr){
super.paint(gr);
gr.setColor(Color.RED);
for(int i = 1;i <= 30;i++){
for(int j = 1;j <= i;j++){
System.out.print(i);
}
System.out.println();
}
}
//generate 4 random numbers
//if statements for what to draw
}
public static void main(String [] args){
as19 frame = new as19();
frame.setSize(200,200);
frame.setVisible(true);
}
}
heres what i got so far
- 05-03-2012, 07:46 PM #3
Member
- Join Date
- May 2012
- Posts
- 15
- Rep Power
- 0
Re: help pleaseee
Here's a quick video tutorial that will tell you how to do everything from scratch...
Java Programming Tutorial - 26 - Random Number Generator - YouTube
- 05-03-2012, 07:52 PM #4
Member
- Join Date
- Apr 2012
- Posts
- 8
- Rep Power
- 0
help please
In this assignment you will write a program to generate random boxes on a 500 x 500 pixel screen. You are to have the program draw 30 boxes. The boxes must have a random position and a random height and width. Make sure that all boxes show up in the window. Here are a couple more stipulations:
1. If the boxes have a width less than 15 they need to be filled in with magenta.
2. If the boxes have a height less than 50 and a width greater than 15 they need to be filled in with blue.
3. All other boxes are just drawn and not filled in
heres what i got so far
import javax.swing.*;
import java.awt.*;
import java.util.Random;
public class as19 extends JFrame {
Container con = getContentPane();
public as19(){
con.setBackground(Color.BLUE);
}
public void paint(Graphics gr){
super.paint(gr);
gr.setColor(Color.RED);
for(int i = 1;i <= 30;i++){
for(int j = 1;j <= i;j++){
System.out.print(i);
}
System.out.println();
}
}
Random random = new Random();
int value = random(10000);
//if statements for what to draw
public static void main(String [] args){
as19 frame = new as19();
frame.setSize(200,200);
frame.setVisible(true);
}
private int random(int i) {
// TODO Auto-generated method stub
return 0;
}
}
- 05-03-2012, 09:35 PM #5
Re: help please
Why do they call it rush hour when nothing moves? - Robin Williams
- 05-03-2012, 09:40 PM #6
Similar Threads
-
[SOLVED] cryptography and steganography - URGENT HELP NEEDED PLEASEEE
By sruthi_2009 in forum Advanced JavaReplies: 22Last Post: 02-24-2011, 05:56 PM -
embed chm to java PLEASEEE
By ashin in forum SWT / JFaceReplies: 1Last Post: 02-19-2011, 07:15 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks