Almost done with program, just a little help please

I am almost done with a program but I just need to have the planet which is _ball be painted on the screen.  I am making a planet that orbits a sun, it all works but the planet is not painted on the screen, but I used a fill method.  Can you guys help?
public class MovingBall extends SmartEllipse
    int X0 = 100, Y0 = 100;
    double X2, Y2;
    double r = 10;
    double a = 0;
    double da = .04;
    double ecc = 1;
    double TWOPI = 2 * Math.PI;
    private javax.swing.JPanel _panel;
    public MovingBall (java.awt.Color aColor, javax.swing.JPanel aPanel)
     super(aColor);
     _panel = aPanel;
     X2 = X0 + r * Math.cos(a);
     Y2 = Y0 + r * Math.sin(a);
     this.setLocation(X2, Y2);
    public void move()
     a = a + da;
     a = a % TWOPI;
     X2 = X0 + r * ecc * Math.sin(a);
     Y2 = Y0 + r * ecc * Math.sin(a);
     this.setLocation (X2, Y2);
    public boolean inFront()
     return (a <= Math.PI);
    public void SetCircle(int x, int y)
     X0 = x;
     Y0 = y;
     //ecc = 1.0 - (double)pct/100;
    public void setAngleIncrement(double inc)
        da = inc;
    public void setCenter(double g, double s)
public class MovingBallPanel extends javax.swing.JPanel implements Mover, Controller
    private final int INIT_X = 250;
    private final int INIT_Y = 200;
    private SmartEllipse _sun;
    private Sky _sky;
    private final int SUN_DIAMETER = 60;
    private MovingBall _ball;
    private final int PLANET_DIAMETER = 35;
    private final int ORBIT_DIAMETER = 185;
    int _da = 1;
    int _ecc = 1;
    private final int INTERVAL = 100;
    private MoveTimer _timer;
    public MovingBallPanel()
     super();
     this.setBackground(java.awt.Color.BLACK);
     _sun = new SmartEllipse(java.awt.Color.YELLOW);
     _sun.setSize(SUN_DIAMETER, SUN_DIAMETER);
     _sun.setLocation(INIT_X - SUN_DIAMETER/2, INIT_Y - SUN_DIAMETER/2);
     _sky = new Sky();
     _ball = new MovingBall(java.awt.Color.RED, this);
     _ball.setCenter((INIT_X - PLANET_DIAMETER)/2, (INIT_Y - PLANET_DIAMETER)/2);
     _ball.setAngleIncrement(_da);     
     _timer = new MoveTimer(INTERVAL, this);
     _timer.start();
    public void move()
        _ball.move();
        this.repaint();
    public void go (boolean g)
     if (g) _ball.setAngleIncrement(_da);
        else _ball.setAngleIncrement(0);
    public void setSpeed(int degrees)
     _da = 2 * degrees;
     _ball.setAngleIncrement(_da);
    public void setEccentricity(int pct)
     _ecc = pct;
     //_ball.setEccentricity(_ecc);
    public void paintComponent(java.awt.Graphics aBrush)
     super.paintComponent (aBrush);
     java.awt.Graphics2D betterBrush = (java.awt.Graphics2D) aBrush;
     _sky.paintSky(betterBrush);
     _sun.draw(betterBrush);
     _sun.fill(betterBrush);
     _ball.draw(betterBrush);
     _ball.fill(betterBrush);
public class PlanetApp extends javax.swing.JFrame
    ControlPanel _controlPanel;
    MovingBallPanel _movingBallPanel;
    public PlanetApp (String title)
     super(title);
     this.setSize(600,500);
     this.setBackground(java.awt.Color.BLACK);
     this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
     _movingBallPanel = new MovingBallPanel();
     _controlPanel = new ControlPanel(_movingBallPanel);
     this.add(_movingBallPanel, java.awt.BorderLayout.CENTER);
     this.add(_controlPanel, java.awt.BorderLayout.SOUTH);
     this.setVisible(true);
    public static void main (String [] args)
     PlanetApp app =  new PlanetApp("Lab 5");
public class SmartEllipse extends java.awt.geom.Ellipse2D.Double {
    private java.awt.Color _borderColor, _fillColor;  // attributes
    private int _rotation;
    private final int STROKE_WIDTH = 2;
    public SmartEllipse(java.awt.Color aColor){
     _borderColor = aColor;
     _fillColor = aColor;    // solid color to start
     _rotation = 0;         // no rotation for now
    // methods not provided by Java
    public void setBorderColor (java.awt.Color aColor) {
     _borderColor = aColor;
    public void setFillColor (java.awt.Color aColor) {
     _fillColor = aColor;
    public void setRotation (int aRotation) {
     _rotation = aRotation;
    // more readable versions of methods provided by Java
    public void setLocation (double x, double y) {
     this.setFrame (x, y, this.getWidth(),
                 this.getHeight());
    public void setSize (int aWidth, int aHeight) {
     this.setFrame(this.getX(), this.getY(),
                aWidth, aHeight);
    public void move (int aChangeInX, int aChangeInY) {
     this.setFrame((int)this.getX()+aChangeInX,
                (int)this.getY()+aChangeInY,
                this.getWidth(),
                this.getHeight());
    public void fill (java.awt.Graphics2D aBetterBrush){
     java.awt.Color savedColor = aBetterBrush.getColor();
     aBetterBrush.setColor(_fillColor);
     aBetterBrush.fill(this); // paint a solid ellipse
     aBetterBrush.setColor(savedColor);
    public void draw (java.awt.Graphics2D aBrush) {
     java.awt.Color savedColor = aBrush.getColor();
     aBrush.setColor(_borderColor);
     java.awt.Stroke savedStroke = aBrush.getStroke();
     aBrush.setStroke(new java.awt.BasicStroke(STROKE_WIDTH));
     aBrush.draw(this);
     aBrush.setStroke(savedStroke);
     aBrush.setColor(savedColor);
}

?

Similar Messages

  • Little help please with forwarding traffic to proxy server!

    hi all, little help please with this error message
    i got this when i ran my code and requested only the home page of the google at my client side !!
    GET / HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
    Accept-Language: en-us
    UA-CPU: x86
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; .NET CLR 2.0.50727)
    Host: www.google.com
    Connection: Keep-Alive
    Cookie: PREF=ID=a21457942a93fc67:TB=2:TM=1212883502:LM=1213187620:GM=1:S=H1BYeDQt9622ONKF
    HTTP/1.0 200 OK
    Cache-Control: private, max-age=0
    Date: Fri, 20 Jun 2008 22:43:15 GMT
    Expires: -1
    Content-Type: text/html; charset=UTF-8
    Content-Encoding: gzip
    Server: gws
    Content-Length: 2649
    X-Cache: MISS from linux-e6p8
    X-Cache-Lookup: MISS from linux-e6p8:3128
    Via: 1.0
    Connection: keep-alive
    GET /8SE/11?MI=32d919696b43409cb90ec369fe7aab75&LV=3.1.0.146&AG=T14050&IS=0000&TE=1&TV=tmen-us%7Cts20080620224324%7Crf0%7Csq38%7Cwi133526%7Ceuhttp%3A%2F%2Fwww.google.com%2F HTTP/1.1
    User-Agent: MSN_SL/3.1 Microsoft-Windows/5.1
    Host: g.ceipmsn.com
    HTTP/1.0 403 Forbidden
    Server: squid/2.6.STABLE5
    Date: Sat, 21 Jun 2008 01:46:26 GMT
    Content-Type: text/html
    Content-Length: 1066
    Expires: Sat, 21 Jun 2008 01:46:26 GMT
    X-Squid-Error: ERR_ACCESS_DENIED 0
    X-Cache: MISS from linux-e6p8
    X-Cache-Lookup: NONE from linux-e6p8:3128
    Via: 1.0
    Connection: close
    java.net.SocketException: Broken pipe // this is the error message
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:115)
    at java.io.DataOutputStream.writeBytes(DataOutputStream.java:259)
    at SimpleHttpHandler.run(Test77.java:61)
    at java.lang.Thread.run(Thread.java:595)
    at Test77.main(Test77.java:13)

    please could just tell me what is wrong with my code ! this is the last idea in my G.p and am havin difficulties with that cuz this is the first time dealin with java :( the purpose of my code to forward the http traffic from client to Squid server ( proxy server ) then forward the response from squid server to the clients !
    thanx a lot,
    this is my code :
    import java.io.*;
    import java.net.*;
    public class Test7 {
    public static void main(String[] args) {
    try {
    ServerSocket serverSocket = new ServerSocket(1416);
    while(true){
    System.out.println("Waiting for request");
    Socket socket = serverSocket.accept();
    new Thread(new SimpleHttpHandler(socket)).run();
    socket.close();
    catch (Exception e) {
    e.printStackTrace();
    class SimpleHttpHandler implements Runnable{
    private final static String CLRF = "\r\n";
    private Socket client;
    private DataOutputStream writer;
    private DataOutputStream writer2;
    private BufferedReader reader;
    private BufferedReader reader2;
    public SimpleHttpHandler(Socket client){
    this.client = client;
    public void run(){
    try{
    this.reader = new BufferedReader(
    new InputStreamReader(
    this.client.getInputStream()
    InetAddress ipp=InetAddress.getByName("192.168.6.29"); \\ my squid server
    System.out.println(ipp);
    StringBuffer buffer = new StringBuffer();
    Socket ss=new Socket(ipp,3128);
    this.writer= new DataOutputStream(ss.getOutputStream());
    writer.writeBytes(this.read());
    this.reader2 = new BufferedReader(
    new InputStreamReader(
    ss.getInputStream()
    this.writer2= new DataOutputStream(this.client.getOutputStream());
    writer2.writeBytes(this.read2());
    this.writer2.close();
    this.writer.close();
    this.reader.close();
    this.reader2.close();
    this.client.close();
    catch(Exception e){
    e.printStackTrace();
    private String read() throws IOException{
    String in = "";
    StringBuffer buffer = new StringBuffer();
    while(!(in = this.reader.readLine()).trim().equals("")){
    buffer.append(in + "\n");
    buffer.append(in + "\n");
    System.out.println(buffer.toString());
    return buffer.toString();
    private String read2() throws IOException{
    String in = "";
    StringBuffer buffer = new StringBuffer();
    while(!(in = this.reader2.readLine()).trim().equals("")){
    buffer.append(in + "\n");
    System.out.println(buffer.toString());
    return buffer.toString();
    Edited by: Tareq85 on Jun 20, 2008 5:22 PM

  • OK, I am almost done with your Adobe CC. 3-4 agents have failed to fix the CC deskTop!

    OK, I am almost done with your Adobe CC. It has been over three+ months now and your Support simply REFUSES to help me fix my issue. I am not able to use or download the software and your are charging me every month.  What kind of crap is that?? I am now very strongly considering canceling my account and demanding a full refund.  Read my notes  on the account!!  You have 48 Hours!  After that I am escalating this to the Adobe Board of Directors and to the Digital Media Reviews that this new platform sucks.  Please give back the old platform!! 
    You have all my contact inforamtion, please do your job or I will ask that some one else doest it!
    Am I pissed off?? What do you think???
    Signed: Disgruntled!

    Hi Jaime O.
    We are sorry for the inconvenience you have been facing. I have reviewed the case notes from your account. I have sent you an email and will contact you on Monday and will try to get the issue fixed.
    Regards,
    Romit Sinha

  • I have a black window that keeps coming up and telling me the various tasks that I am handeling. It came after opening a power point and now I cannot make it disappear. It frames all windows and programs that I open with a black line. Help please...

    I have a black window that keeps coming up and telling me the various tasks that I am handeling. It came after opening a power point and now I cannot make it disappear. It frames all windows and programs that I open with a black line. Help please...

    Go to System Preferences - Accessibility - Voiceover - turn off Voiceover. The shortcut is command-F5, so possibly you pressed that accidentally.
    Matt

  • Guys, a little help please ???

    Guys, a little help please before i launch my new toys out of my pram   I've got the new apple TV, Ipad2, and IOS5 update. I'm trying to set up mirrorring , however, when i double click the home page and swipe, the only options it gives me are Ipad or Apple TV. The video shows that i should be able to simply click on mirrorring and whazam it appears on my TV... I can't get this option.... I've rebooted them (router, ipad 2 and Apple Tv) numerous times but still can't get it.......Can someone tell me what I'm doing wrong?
    Thanks

    Sounds as though the options you're getting are the standard Airplay output icons.
    Check current AppleTV software version in Settings>General>About
    Latest is 4.4.2 - there's a sticky at the top of the page about updating - if you're on 4.3 or lower just update from Settings.
    Maybe someone can confirm the video you mention is actually the correct way to invoke mirroring - link?
    (Yn anfodus heb iPad2 does dim syniad 'da fi os ydi'r Mirroring yn gweithio fel yn y fideo - oes linc i'r fideo, rhag ofn bod y fideo'n anghywir?)
    AC

  • HT201066 how do you close it. Its that it dosent let me close the screen recorder just minimize it.HELP PLEASE!

    how do you close it. Its that it dosent let me close the screen recorder just minimize it.HELP PLEASE!

    Launch Safari with the Shift key held down. If that doesn't work, disconnect the computer from the Internet.
    (116363)

  • In my Iphone 5, Nothing on my App Store is working its displaying blank (Except for Genius section). I've tried to uninstall and install itunes and all its component but still it doen't fix. Not sure if its problem with apple servers. Someone help please!

    In my Iphone 5, Nothing on my App Store is working,  its displaying blank (Except for Genius section). I've tried to uninstall and install itunes and all its component in my desktop but still it doesn't fix the app store issue. Not sure if its problem with apple servers. Someone help please!

    settigns>itunes and app store to make sure you are signed in.. If  you are, you will see your account name..... anyhow, click your account name, sign out and sign back in
    also go to to settings>general>reset and reset network settings... if that doesnt work settings>general>reset and reset all settings!
    one of those shall work. The last step would be to restore your device (apple.com/support) HT1414

  • Every time I try to open Photoshop Elements 12, it opens the Adobe login, after I login the program does not open:( Help please?

    Every time I try to open Photoshop Elements 12, it opens the Adobe login, after I login the program does not open:( Help please?

    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    You can use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    You have to close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")

  • Need a little help please    Airport Express

    Need a little help please.
    I am trying to set up a wireless network at my home using Airport Express.
    I have a regular phone line running in to I assume the modem. From there, there is an Ethernet cable running from that box to the back of the PC. My question is, I think, which of those do I unplug and plug into the Airport Express, the one on the back of the PC or the one that is in the back of the modem, or is this totally wrong.
    Any help would be appreciated…
    Thanks
    In advance…
    PS I have the manual but to me it is not very clear…

    Your connection sequence would look like this:
    Internet > Modem > AirPort Express >>>wireless to your computers.
    This means that you would unplug the cable that is now connected at the back of your PC and move that connection to the AirPort Express.
    Open Macintosh HD > Applications > Utilities > AirPort Utility
    Click Continue to follow the guided setup. On the third page, you will choose the option to "Create a wireless network" and continue the setup.

  • Hi, I have installed boot camp with wins xp home but i can't get on line with it. can only one help please.

    Hi, I have installed boot camp with wins xp home but i can't get on line with it. can only one help please.

    Please close this thread, I have managed to get a hold of a DVD including all the drivers, so I suppose that will work, if not one way then another.
    Thank you for the quick answers.

  • Hello i can't finish my review on my phone because i don't have a bank card so i don't what to do any help please?

    hello i can't finish my review on my phone because i don't have a bank card so i don't what to do any help please?

    Disabled
    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                         
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up     
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        

  • I have iPhone 4.I uprage it to IOS 5.1.1 and i can't go into it because i have no service.A  little help,please ? :/, I have iPhone 4.I uprage it to IOS 5.1.1 and i can't go into it because i have no service.A  little help,please ? :/

    I have iPhone 4.I uprage it to IOS 5.1.1 and i can't go into it because i have no service.A  little help,please ? :/, I have iPhone 4.I uprage it to IOS 5.1.1 and i can't go into it because i have no service.A  little help,please ? :/

    Your phone is carrier locked to a carrier other than the one you are trying to use.
    It was apparently hacked to unlock it prior to your attempt to update. Updating has re-locked it to the original carrier.
    Contact them and find out what their policy is.

  • Is everybody having problems with Canoscan drivers-can anyone help, please?

    After starting with Leopard, my LIDE25 refuses to work, and the window from the toolbox tells me a driver cannot be found, even after redownloading the driver, which, according to the Canon website, is perfectly compatible with the LIDE25 driver. Someone is not being honest, or Apple has made a huge mistake in the bug department. My smart mailboxes don't work either.Can anyone help? I see there are others with Canon scanner driver problems on this forum - what can we do? I'm so tired of fragile scanners breaking down and needing replacement - they are like VCRs in this respect, somehow a crap technology - but this time it's surely not the scanner to blame.

    I have a Conoscan 8400F scanner, and after downloading the latest driver it actually works BETTER than it ever has... used to take almost 3 minutes to scan a 8.5 X 11 page, now less than a minute.
    Jeff

  • What's wrong with this code. Any Help please?

    Hello
    I'm a newbie to java programming.I got this sample code from an online book that I use in learning java and I'm trying to run the code on eclipse but I got this error message
    "Fatal exception occurred. Programm will exit."
    This is the code:
    public class MostDivisors {
         public static void main(String[] args) {
              int N;
              int maxDivisors;
              int numWithMax;
              maxDivisors = 1;
              numWithMax = 1;
              for(N = 2 ; N <= 10000 ; N++){
                   int D;
                   int divisorCount;
                   divisorCount = 0;
                   for(D=0; D <= N; D++){
                        if (N % D == 0)
                             divisorCount++;
                   if (divisorCount > maxDivisors){
                        maxDivisors = divisorCount;
                        numWithMax = N;
              System.out.println("Among intergers between 1 and 10000,");
              System.out.println("The maximum number of divisors is "+maxDivisors);
              System.out.println("A number with " + maxDivisors + " divisors is ");
    Any Help will be appreciated. Thank you all for helping me out understand the problem here

    Thank you all participating to help this out.
    This is the code and the detailed error message:
    public class MostDivisors {
         public static void main(String[] args) {
              int N;
              int maxDivisors;
              int numWithMax;
              maxDivisors = 1;
              numWithMax = 1;
              for(N = 2 ; N <= 10000 ; N++){
                   int D;
                   int divisorCount;
                   divisorCount = 0;
                   for(D=0; D <= N; D++){
                        if (N % D == 0)
                             divisorCount++;
                   if (divisorCount > maxDivisors){
                        maxDivisors = divisorCount;
                        numWithMax = N;
              System.out.println("Among intergers between 1 and 10000,");
              System.out.println("The maximum number of divisors is "+maxDivisors);
              System.out.println("A number with " + maxDivisors + " divisors is ");
    ERROR MESSAGE starts HERE:
    java.lang.ArithmeticException: / by zero
         at MostDivisors.main(MostDivisors.java:30)
    Exception in thread "main"
    I do not think this is related to the JVM because other programs will compile and run successfully.
    Any Help will be appreciated. Thanks

  • HELP WITH IPHONE 4S IPHONE URGENT HELP PLEASE?

    IPHONE URGENT HELP PLEASE?
    for the whole day my network has been 'Searching...'
    i have tried airplane mode on and off, turning my phone on and off and network reset and taking sim in and out.
    so i backed up my phone and restored to factory settings as i don't think i did the option of choosing manually select a carrier.
    my network is still 'searching...' and it won't let my wifi to allow me to activate my iphone. i have tried to connect to itunes and it still won;t work.
    i keep getting a message about no activation server.
    this is a new iphone. i got it replaced on saturday.
    PLEASE SOMEONE HELP ME!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Hello,
    If this is a new iPhone then you will have free access, as all iPhones come with it, to Apple support. I would have them take care of an issue like this.
    Hope this helps.
    Regards,
    Jake

Maybe you are looking for