Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 13th, 2009, 11:05 AM
Authorized User
 
Join Date: Nov 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to chris1012
Default java program structure

hey all i was wondering if you could take a look at this code its driving me nuts basically its a java file used to demonstrate an erosion process its driving me nuts i need to sperate the file into two files really so that it works on behalf of an abstract class. gr programming it confuses me all help and comments appreciated cheers

Chris


import javax.swing.*;
import java.awt.*;
import java.awt.geom.Arc2D;
import java.awt.geom.Point2D;
class structureshapes extends JFrame
{
int lh = 0;
int count = 0;
public structureshapes()
{
setSize(500,500);
setBackground(Color.cyan); /*defines the background colour*/
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
do
{
try
{
Thread.sleep(1); /*draws arcs in 1mm of speed*/
}
catch (InterruptedException e) /*if the program gets interrupted*/
{
}
count = count + 1;
lh = lh+1;
repaint();
}
while (count < 50);
do
{
try
{
Thread.sleep(100);/*adapts the speed of the program*/
}
catch (InterruptedException e)
{
}
lh = lh+1;
repaint();
}
while (lh<100);
do
{
try
{
Thread.sleep(100);
}
catch (InterruptedException e)
{
}
lh = lh + 1;
repaint();
}
while (lh<160);
}
public void paint(Graphics g)
{
Graphics2D g2D = (Graphics2D) g;
if (lh < 100)
{
g.setColor(Color.black);
Point2D.Double position = new Point2D.Double(-35,500-lh);
Arc2D.Double water = new Arc2D.Double(position.x, position.y, 575, 100, 30, 120, Arc2D.OPEN);
Arc2D.Double oil = new Arc2D.Double(position.x, position.y-50, 575, 120, 30, 120, Arc2D.OPEN);
Arc2D.Double shale = new Arc2D.Double(position.x, position.y-100, 575, 120, 30, 120, Arc2D.OPEN);
Arc2D.Double sandstone = new Arc2D.Double(position.x, position.y-150, 575, 120, 30, 120, Arc2D.OPEN);
Arc2D.Double limestone = new Arc2D.Double(position.x, position.y-200, 575, 120, 30, 120, Arc2D.OPEN);
g2D.setPaint(Color.BLUE);/*defines the water layer colour*/
g2D.draw(water);
g2D.setPaint(Color.BLACK);/* defines the oil layer colour*/
g2D.draw(oil);
g2D.setPaint(Color.GRAY);/* defines the shale layer colour*/
g2D.draw(shale);
g2D.setPaint(Color.YELLOW); /* defines the sandstone layer colour*/
g2D.draw(sandstone);
g2D.setPaint(Color.GREEN);/* defines the limestone layer colour*/
g2D.draw(limestone);
g2D.setPaint(Color.YELLOW); /* defines the sun layer colour*/
g2D.fillOval(10, 50,50,50);
}
if (lh > 100)
{
/*erosion process*/
g2D.setPaint(Color.CYAN);
g2D.fillRect(0,200,500, lh-100);
}
}
public static void main (String []args)
{
structureshapes structured = new structureshapes();
}
}
__________________
in opposite world i love programming





Similar Threads
Thread Thread Starter Forum Replies Last Post
java program help chris1012 Java Basics 3 November 8th, 2007 09:35 AM
Logicial vs physical program structure darrenecm Visual C++ 2005 0 May 2nd, 2006 02:54 PM
java program todeepak_g JSP Basics 0 January 25th, 2006 06:04 AM
java program todeepak_g JSP Basics 0 January 25th, 2006 06:01 AM
Please Help Create Java Program!! Tigermoney JSP Basics 4 April 18th, 2004 09:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.