JOption box wont go away

I read input from aninputdialog box inside a loop which is in a constructor for a simple graphical clock face program
the clock is displayed in the applet, but the dialog box doesn't go away, therre is no main method for an applet, so where do i put the system.exit() or whatever so that the boxes dissappear??
also
is this sort of topic too newbie for this site??

I cant really shorten it much and i understand if Its too much to help with
thanks
<applet code="ClockApplet.class" width="1000" height="1000" ></applet>
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JApplet;
  Draws a clock
public class ClockApplet extends JApplet
     public void paint(Graphics g)
          Graphics2D g2 = (Graphics2D) g;
          Clock clockFace = new Clock(150, 150, 400);
          clockFace.draw(g2);
      a clock face with a minute and an hour hand
     Time is specified by the user
import javax.swing.JOptionPane;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
public class Clock
     private double xLeft;
     private double yTop;
     private double size;
     private double hr;
     private double min;
          constructs a clock face starting at coordinate(x, y)
          and with a given size(diameter)
          @param the x coordinate of the starting point of the circle
          @param the y coordinate of the starting point of the circle
          @param the diameter of circle
     public Clock(double x, double y, double size)
          boolean validTime = false;
          xLeft = x;
          yTop = y;
          this.size = size;
          while(!validTime)
               validTime = true;
               String input = JOptionPane.showInputDialog("enter the time ie.(5:30) : ");
               if(input.length() != 5 && input.length() !=4)
                    validTime = false;
               if(validTime)
                    //checks to see if there is a colon in the right place
                    String colonString = input.substring(input.length() - 3, input.length() - 2);
                    if((colonString.equals(":") == false))
                         validTime = false;
               if(validTime)
                    String[] time = input.split(":");
                    hr = Double.parseDouble(time[0]);
                    min = Double.parseDouble(time[1]);
                    if(min >= 60 || min < 0 || hr > 12 || hr < 1)
                         validTime = false;
               if(!validTime)
                    JOptionPane.showMessageDialog(null, "Invalid time", "ATTENTION",
                                                  JOptionPane.INFORMATION_MESSAGE);
          draws the clock face with an hour and a minute hand
          @param Graphics2D g2
     public void draw(Graphics2D g2)
          Ellipse2D.Double circle = new Ellipse2D.Double(xLeft, yTop, size, size);
          Point2D.Double p1 = new Point2D.Double((xLeft+ size/2), (yTop + size/2));
          Line2D.Double hourHand = new Line2D.Double(p1, getHourHandCoordinate(p1));
          Line2D.Double minuteHand = new Line2D.Double(p1, getMinuteHandCoordinate(p1));
          g2.draw(circle);
          g2.draw(hourHand);
          g2.draw(minuteHand);
          returns the end point of the hour hand
          @param Point2D.Double the middle of the clock face
          @return Point2D.Double end point of the hour hand line
     public Point2D.Double getHourHandCoordinate(Point2D.Double p1)
          //centre coordinates of the clock face
          double xCentre = p1.getX();
          double yCentre = p1.getY();
          //here i make the fraction smaller so that the end points will be closer to the centre
          double smallerSize = size/2;
          //amount x, and y axies change with each minute difference
          final double INCREMENT = smallerSize/30.0;
          //fraction of an hour more that the hand needs to move
          //amount x, and y axis change with each second difference
          double fraction;
          if(min!=0)
               fraction = min/60;
          else fraction = 0;
          //x and y of the end point of the hour hand
          double x = 0, y = 0;
          //calculates end point depending on the hour entered and the minute entered
          if(hr <= 3)
               x = xCentre + 5 * (hr + fraction) * INCREMENT;
               y = yCentre - 5 * (3 - hr - fraction) * INCREMENT;
          else if(hr <= 6)
               x = xCentre + 5 * ( 6 - hr - fraction) * INCREMENT;
               y = yCentre + 5 * (hr - 3 + fraction) * INCREMENT;
          else if(hr <=9)
               x = xCentre - 5 * (hr - 6 - fraction) * INCREMENT;
               y = yCentre + 5 * (9 - hr - fraction) * INCREMENT;
          else if(hr < 12)
               x = xCentre - 5 * (12 - hr + fraction) * INCREMENT;
               y = yCentre - 5 * (hr - 9 - fraction) * INCREMENT;
          else
               x = xCentre + 5*fraction * INCREMENT;
               y = yCentre - 5*( 2 + 1 - fraction) * INCREMENT;
          //creates a point object and returns it
          Point2D.Double p2 = new Point2D.Double(x, y);
          return p2;
          returns the end point of the minute hand
          @param Point2D.Double centre of clock face
          @return Point2D.Double end point of the minute hand line
     public Point2D.Double getMinuteHandCoordinate(Point2D.Double p1)
          //amount x, and y axis change with each second difference
          final double INCREMENT = size/30.0;
          //centre coordinates of the clock face
          double xCentre = p1.getX();
          double yCentre = p1.getY();
          double x = 0, y = 0;
          //calculates the end point depending on how many minutes were entered
          if(min <= 15)
               x = xCentre + min*INCREMENT;
               y = yCentre - (15 - min)*INCREMENT;
          else if(min <= 30)
               x = xCentre + (30 - min)*INCREMENT;
               y = yCentre + (min - 15)*INCREMENT;
          else if(min <= 45)
               x = xCentre - (min - 30)*INCREMENT;
               y = yCentre + (45 - min)*INCREMENT;
          else
               x = xCentre - (60 - min)*INCREMENT;
               y = yCentre - (min - 45)*INCREMENT;
          //creates a point object, and returns it
          Point2D.Double p3 = new  Point2D.Double(x, y);
          return p3;
}Edited by: rubiconTwist on May 27, 2008 4:34 AM

Similar Messages

  • Print dialog box wont go away...

    Weird print stuff? Every time I print the print dialog box stays on the screen?
    It can be moved but none of the buttons do anything. And the print boxes will stack up as many times as you print.
    Driver issue? since OS X 10.6?

    HI,
    If the printer icon is still in the Dock, click that icon, then click: Quit.
    if that doesnt work, open Activity Monitor (Applications/Utilities). Select My Processes from the pop up menu on the right. Search for your printer under Process Name, then click the red Quit Process button.
    If that doesn't help, go to...
    ~/Library/Preferences and locate the preference file associated with your printer, it will read something like this. Preference files can become corrupted. The next time you print, your Mac will create a new print pref file for you.
    com.nameofprinter.plist (I assume they're HP's according to your prior posts).
    Move that file to the Trash and restart your Mac.
    Carolyn
    Message was edited by: Carolyn Samit

  • Blank Error box wont go away!

    I have been working on this project for 3+ Hours and forgot to save and right as i was about to render it this blank error box appeared and there is no option do anything and i cant click out of it so that means i cant save the project! Please help!
    Here is what it looks like: Gyazo - da0112b6c7e16fd5082f8d805a61b657.png
    If anyone knows how to fix this PLEASE respond!

    Nobody can say anything without some system info, details about the project or even knowing what exact version of AE. Presumably you dialed in an invalid/ excessive value in some effect and you will need to fix that. Enable capslock and try to get rid of the warning, then disable your effects.
    Mylenium

  • Facebook f icon wont go away

    my facebook (f) icon wont go away and i have no new notifications or messages. same thing with my myspace icon. anyone know how to fix this please???

    Are those Facebook and MySpace notificiation icons in the upper part of your homescreen?
    Tips for clearing that unread message... try them in order.
    If you have a rogue New Message icon on your Homescreen, or a negative count (-1), any one of these solutions could clear it, or reset it to zero:
    Try these options:
    * Hard Reset the BlackBerry by holding ALT, CAP (right Shift key), and DEL (or with the BlackBerry powered ON, remove the battery and reinserting the battery)
    * View Messages > Saved Messages
    * View Messages > View Folders, check each folder (missed calls, SMS in and out boxes, MMS in and out boxes, Saved, browser, phone logs etc)
    * Scroll to top of message folder, over the date heading, click or press menu to MARK PRIOR OPEN
    * Change your theme and see if it persists, and change back to your desired theme. (Options > Theme > select.)
    * Wipe and reload your OS.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • I have a 10.2.8 os. I had opened up the AOL logo on the bottom bar. Two aol boxes came up. I can get them to go away for a short time and then they come back. I have not used AOL for 6 years. How can I get the boxes to go away?

    I have a 10.2.8 os on a G4 desktop. A week ago I clicked on the AOL icon in the bottom bar. I have not used AOL for six years. Two aol boxes came up. I can not get the boxes to go away for long. They may go away for 15 minutes and they come back  while I am working. How can I get these  aol boxes to go away?
    I will be upgading to Tiger; 10.4.

    Right click on the AOL icon and select move to trash.

  • My ipod touch 4g is turning up or down by itself, and the speaker icon wont go away

    Okay this first started yesterdy morning, when my ipod touch4g was acting funny it wouldnt turn off, so i thought if i plugged it in it would fix itself, so i thought restoring would help it,made it worse it started turning off and on apple logo came on a few times, now i got it where i can turn it off and on okay but now i cant seem to controle the volume, and the speaker icon is showing and wont go away, and when i try turning it down when i play a song or a video, it will turn back up by itself, or it will turn down by itself,
    what would be the best way to fix this without taking it in? the nearest apple store is dallas and i dont wanna spend all the money in gas to go up there, and then see what arm and leg i gotta cut off to get them to fix it.
    should i restore and resync it one more time or should i start saving for a new ipod along with the new computer im needing?

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings      
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up                             
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar          

  • When i plug in my ipod to itunes it shows an advertsment that wont go away

    i plug in my ipod touch into the computer and when i click on MY IPOD it show an advertisment  for an iphone application. when i click NOT NOW the advertisement wont go away. it stays on itunes not allowing me to sync or do anything on itunes with it. this is not a problem on my ipad 2 but just the ipod touch 3rd gen. please help.
    P.S. no i cannot restore it because i wl loose all of my songs since they are not in my itunes library yet.

    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

  • I have this icon on the top right of my screen that is a lock with like a circle and arow around it that wont go away, what does it mean?

    I have this icon on the top right of my screen that is a lock with like a circle and arow around it that wont go away, what does it mean?

    Here's the answer:
    https://discussions.apple.com/message/15098215#15098215
    https://discussions.apple.com/message/15622244#15622244

  • My i pod shows my charger and itunes so i download i tunes. But itunes said i had to do my passcode but the charger and itunes symbol wont go away long enough for me to enter my passcode! what do i do?

    My ipod shows my charger and itunes, so i download itunes. But then itunes says i musst enter my passcode on my i pod but the charger and itunes symbols wont go away long enough for me to enter my passcode. what should i do?

    Disabled
    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Forgot passcode or device disabled
    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: Back up and restore your iOS device with iCloud or iTunes       
    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        
    If problem what happens or does not happen and when in the instructions? When you successfully get the iPod in recovery mode and connect to computer iTunes should say it found an iPod in recovery mode.

  • My i phone has a new update  and it is now on a screen that has a little blue circle with the music symbol and the carger pece and an arrow in between them pointing up it wont go away or turn off the screen what do i do

    i used the new update now my screen has a blue music symbol an arrow pointing up under it and a charger symbol it wont go away whats wrong

    How long has it been like that? Have you touched it, pushed any buttons, etc.?
    GB

  • How do I delete my old iMessage email and change to my current one, that Im using when I buy apps and so on. The old one wont go away when I turn iMessage on and of again. pls help

    How do I delete my old iMessage email and change to my current one, that Im using when I buy apps and so on. The old one wont go away when I turn iMessage on and of again. pls help
    Anyone had the same?

    How do I delete my old iMessage email and change to my current one, that Im using when I buy apps and so on. The old one wont go away when I turn iMessage on and of again. pls help
    Anyone had the same?

  • What do I do if my iPhone screen is slightly purple and it wont go away?

    What do I do if my iPhone screen is slightly purple and it wont go away?

    Take it in to an Apple Store and have it evaluated.

  • My ipad 4 is frozen not charged wont stay on and has a dark grey keyboard that wont go away not charging

    my ipad 4 is frozen not charged wont stay on and has a dark grey keyboard that wont go away not charging

    Reset the device:
    Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears.
    If that doesn't help, tap Settings > General > Reset > Reset All Settings

  • Logo wont go away on ipod

    i have a logo of what looks like a wall charger and wont go away and cannot add songs on becuase of it please help now

    I still havent got a fix ive seriously tried everything that i can find or that is possible but the updater has definetly ruined my ipod.
    ive also got the same icon as you...mines got an arrow and a part that connects to the bottom of your ipod.
    can anyone help?

  • Keyboard wont go away.......

    im at the appstore and the keyboard is there and wont go away and i cant go to home screen on the appstore cuz of the keyboard still there and i dont know how to make it go away, any ideas?

    Press the home button to go back to the home screen. Then double tap the home button to bring up the multitasking bar and hold the AppStore icon. Then close the app by pressing on the top left corner of the app. Now try to reopen the app. See if that helps.
    If not restart the iPhone.
    If that doesn't work reset the iPhone by pressing both the home and sleep button till the iPhone shuts off. Ignore the slide to shut off prompt. The restart the iPhone.

Maybe you are looking for

  • Push Notifications and Enterprise

    Hello there, We have been upgraded from woodwing to Adobe DPS last month. We are slowly getting back to the way it was before and know that some features will come in future updates. There is only 1 thing I don't get or could find any documentation f

  • How can i re-download my purchases post robbery.

    I was recently mugged in clapham a few weeks ago, and they stole my Iphone4. Although i do have a laptop, it doesn't last anymore than 10 minutes before it dies on me, and then when rebooting, i have to go to a restore point, to which iTunes isn't ye

  • Tabbed panels repeat region in cms displays 2nd item as a block of content

    Hi everyone, hope someone can help: I have a test page live http://aegmotorhomes.co.uk/usedtest1.php Problem is this- I have added a repeat region on my dreamweaver template I use Perch CMS as my management for staff to add new items for sale on this

  • Connect to TV as external display

    I have been using VGA cable to a samsung digital.  I used to set up using Fn F7 and then FnSpacebar to switch between screens.  Now FnF7 changes my resolution and external display screen reads "Mode Not Supported"  Any ideas?

  • Itunes will not open anymore

    hey. im just wondering if any of you guys can help me out here.basically i had to update to the itunes 8 to make it compatabile with my new ipod touch.but even though it says its been downloaded it will not open and will come up with a message saying