Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Moire Pattern Java Program
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Tyler Essinger
Moire Pattern Java Program
0 Answer(s)      2 years and 10 months ago
Posted in : Java Beginners


**strong text**What you are seeing in the screenshot are two sets of concentric circles. The centers of the circles are 100 pixels apart. The circles have a width of 5, and the diameter of a circle is 20 pixels larger than its next smallest one. Diameters range from 20 to 480 pixels.

Hint: You can change the width of the 'pen' used for drawing to 5 pixels with the line g2.setStroke(new BasicStroke(5)).

Hint: A circle is just an oval whose width and height are the same.

Make the program from this older code:

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Flower extends JPanel {

  public void paintComponent(Graphics g){
    final int centerX = 300; 
    final int centerY = 300;
    final int ovalWidth = 100; 
    Graphics2D g2 = (Graphics2D) g;




    g2.setColor(Color.black);
    g2.fillOval(centerX, centerY - ovalWidth / 2, 300, ovalWidth); 

    g2.rotate(Math.toRadians(15),centerX,centerY);

    g2.fillOval(centerX, centerY - ovalWidth / 2, 300, ovalWidth);
    g2.rotate(Math.toRadians(15),centerX,centerY);

    g2.fillOval(centerX, centerY - ovalWidth / 2, 300, ovalWidth);
    g2.rotate(Math.toRadians(15),centerX,centerY);

 }

  public static void main(String[] args) {
    JFrame frame = new JFrame("Window"); //frame is the window
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Flower panel = new Flower(); //panel is the graphics area where we can draw

    frame.add(panel); //put the panel inside the window
    frame.setSize(640,640); //set the window size to 640x640 pixels
    frame.setVisible(true); 
 }
}


![alt text][1]

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Moire Pattern Java Program
Moire Pattern Java Program  **strong text**What you are seeing in the screenshot are two sets of concentric circles. The centers of the circles... an oval whose width and height are the same. Make the program from this older code
Moire Pattern 2 Java
Moire Pattern 2 Java   textWhat you are seeing in the screenshot are two sets of concentric circles. The centers of the circles are 100 pixels apart... and height are the same. Make the program from this older code: import
Advertisements
pattern program
pattern program  13579 1357 135 13 1 pattern program in java   Here is your Example:- package Compare; public class PatternDemo { public static void main(String [] args){ int c=10; for(int i=0;i<
pattern program
pattern program  can any 1 print the following pattern in java .plz give the code.and yes thank u so much for answering my 2 other questions.had i... before.anyways the pattern goes like this abcdcba abc cba ab ba a a ab ba abc abc
pattern program
pattern program  can some one plz help me to wright the logic for the following pattern abcdcba abc cba ab ba a a ab ba abc cba abcdcba
Java pattern
Java pattern  Write a Java program that outputs the following pattern. 1 21 321 4321 54321 654321
logic for pattern program
logic for pattern program  what's the logic for create pattern program how can i create any pattern program with in minute. like this 123454321... create this program in java without help whats the logic how can i understand
java pattern
java pattern  12345 23451 34512 45123 41234 12345
what's the logic for create pattern program
what's the logic for create pattern program   1 2 3 4 5 5 1 2 3 4 4 5 1 2 3 3 4 5 1 2 2 3 4 5 1
code for java pattern
code for java pattern   * * * * * * * * please write the program of above pattern and do not use string tokennizer string buffer i mean to say that please use very simple method Thanks
code for java pattern
code for java pattern  1 23 345 5678 891011 please write the program of above pattern and do not use string tokennizer string buffer i mean to say that please use very simple method Thanks
code for java pattern
code for java pattern  1 121 2342 45674 6789106 please write the program of above pattern and do not use string tokennizer string buffer i mean to say that please use very simple method Thanks
Pattern
Pattern  How to print this pattern in Java please help me A AC ACE ACEG ACEGI The program should be right to left
pattern
pattern  write a java program that can create four different patterns of different sizes. The size of each pattern is determined by the number... program displays a menu and asks the user to choose a pattern and size. But note
pattern java example
pattern java example  how to print this 1 2 6 3 7 10 4 8 11 13 5 9 12 14 15
print rectangle pattern in java
print rectangle pattern in java  * * * * * * * how to generate this pattern in java??   Hi friend try this code may this will helpful for you public class PrintRectangle { public static void main
Java Singleton Pattern
In this section, you will learn about singleton pattern in Java
Pattern class - Java Interview Questions
Pattern class  1)Write a program to find out numeric occurences in an input file by using pattern class
Design pattern - Java Beginners
Design pattern  How to make a java program to check the java program is already started if started the execution then dont allow the new program to start
singleton pattern - Java Beginners
singleton pattern  how i use singleton pattern in my web aplication project.plz give an example.its urgent
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Square pattern in java using for loop
Square pattern in java using for loop  please explain the logic to program the following using for loop in Java: 1 3 5 7 9 3 5 7 9 1 5 7 8 1 3 7 9 1 3 5 9 1 3 5 7
Advertisements
 

 

 

DMCA.com