My repaint( ) just re-paints but doesn't clear the back

Hi, i am using repaint( ) with the timer method to randomly draw 100 randomly colored lines.But every time the timer calls actionperformed which contains repaint( ), the application just paints the new 100 lines on top of the old ones, not cleaning the first painting. Maybe this is the way to repaint continuesly, but isn't repaint( ) supposed to clear the back. Here is my code, thanks for helping!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class RandomLines extends JFrame
implements ActionListener {
private int x1,y1,x2,y2;
private int r,gr,b;
Timer timer;
public RandomLines()
super("Drawing Random Lines");
timer=new Timer(10000, this);
timer.start();
setSize(400,400);
show();
public void paint(Graphics g)
for(int i=1;i<=100;i++)
x1=1+(int)(Math.random()*399);
y1=1+(int)(Math.random()*399);
x2=1+(int)(Math.random()*399);
y2=1+(int)(Math.random()*399);
r=1+(int)(Math.random()*255);
gr=1+(int)(Math.random()*255);
b=1+(int)(Math.random()*255);
g.setColor(new Color(r,gr,b));
g.drawLine(x1,y1,x2,y2);
public void actionPerformed(ActionEvent e)
repaint();
public static void main(String args[])
RandomLines app=new RandomLines();
app.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e)
System.exit(0);
}

I reckon this might be part of it:
Container update(Graphics g):
Updates the container. This forwards the update to any lightweight components that are children of this container. If this method is reimplemented, super.update(g) should be called so that lightweight components are properly rendered. If a child component is entirely clipped by the current clipping setting in g, update() will not be forwarded to that child.
Component update(Graphics g):
Updates this component.
The AWT calls the update method in response to a call to repaintupdate or paint. You can assume that the background is not cleared.
The updatemethod of Component does the following:
Clears this component by filling it with the background color.
Sets the color of the graphics context to be the foreground color of this component.
Calls this component's paint method to completely redraw this component.
The apparently contradictory statements in the definition for Component are slightly puzzling - maybe they mean that "You can assume that the background has yet to be cleared"? This would also seem to imply that a Panel, being a container, does not clear its background, but that a Canvas does. I can't remember if this is the case. Anyone care to verify?--
<sig> http://www.itswalky.com http://www.crfh.net </sig>

Similar Messages

  • Mdmclient in OS X is not responding to mdm commands just sends idle but doesn't perform or Acknowlegde the sent command

    Hi Everyone
    The mdmclient in OS X is not responding to mdm commands just sends idle in response to the command but doesn't perform the action or Acknowledge or Command Format Error. please help in tracing down the issue.same server config works fine in iOS .. used 1024 for access rights to support OSX
    I'm Using Self Signed Server Cert with correct Subject Alt name i.e DNS and IP Address ,Self Signed CA and Identity is generated by SCEP.
    the Device Response.. to apns notification
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"> <dict> <key>Status</key> <string>Idle</string> <key>UDID</key><string>nnjknjkjknjk</string> <key>UserID</key> <string>nnjknjkjknjk</string> <key>UserLongName</key> <string>cdffefeef</string> <key>UserShortName</key> <string>fefef</string> </dict> </plist>
    Sent Command for OSX is
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Command</key> <dict> <key>PIN</key> <string>123456</string> <key>RequestType</key> <string>DeviceLock</string> </dict> <key>CommandUUID</key> <string>some uuid</string> </dict> </plist>
    Any Help in this regards is really appreciated.. Thanks

    Hi Pranav,
    Do you have any update on this issue? I have enabled mdmclient debug messages and there is always "Server provided no commands to process" message even when the server has sent the commands.

  • I just purchased an iPad 3 and it works great with most of my email accounts, but with an imap account from school it will download the content of the folders in the account, but doesn't download the messages in the inbox.

    Hi,
    I just purchased an iPad 3 and it works great with most of my email accounts, but with an imap account from school it will download the content of the folders in the account, but doesn't download the messages in the inbox. I have deleted and created the account several times. I have checked the status of the account and it's active and works either from safari or from my Mac or iPhone. I have turned off both my Mac and my iPhone as not to have competing devices, I can even send emails from the account successfully. It simply won't download the content of the inbox. Help!

    Hi Csound1, thanks. The email host is 1and1.co.uk, however, i am going to fess up and make myself look like a plonker now -
    the email account in question was set up in Outlook as POP - stupid, stupid, stupid me, wasted an afternoon on this!  I have now changed the Outlook account to IMAP and Mail.app works perfectly - and looks much nicer than Outlook did.  Im in the middle of converting from Windows to a Mac, and still finding my way around the Mac
    The lesson learned, never assume - always double  check!  All my other email addresses with 1and1 are all imap, except this one, and it happened to be the first one I set up in the Mail.app. (bows head in disgrace!)
    Thank you anyway for attempting to help me!
    Cheers

  • Just bought iPad gen3 the silence switch on the side doesn't work, it shows the symbol on screen but doesn't silence the iPad?????

    Just bought iPad gen3 the silence switch on the side doesn't work, it shows the symbol on screen but doesn't silence the iPad?????

    The Side Switch is to mute your ringers, and most of the application's sound. To totally mute the sound, you must use the rocker to mute it.

  • Mac Mini blank white screen. Did Cmd+R reprograms but doesn't leave the white screen!!

    Mac Mini blank white screen. Did Cmd+R  but doesn't leave the white screen! I tried Cmd+Option+R, this allows reprogramming but after 34 or so minutes it remains in the white screen! Any ideas?

    Unfortunately, the white screen will not go away! Therefore, I do not have the option to the Disk Utility!! I wish I could! I would have already erased the disk and reinstalled the OS. Side note here is that an Apple Fan told me that she and her husband had a similar scenario with a new iMac!! Turned out (after 3 attempts by Apple Techs to fix) to have to replace it! They related to me that there was an issue with the connections between the Logic Board and the Hard Drive! The hard drive got burnt out and so did the Logic board on different occasions. I have been a PC user for years until I got tired of all the maintenance and wanted to try Mac. So many thrilled fans claiming they never get issues as often as a PC. Well, here I am six weeks after buying the Mac Mini having issues...I guess a machine is a machine, is a machine! I was thrilled with the Lion OS and all the interaction I was having with it! I truly thought that this was a highly superior computer. I expected quality control to have equally a superiority that one would expect from an Apple product. It could be that this unit is a lemon! It happens! Because I also have iPad and iPhone that have given me the best performance ever!! So I hope that I will someday see the same from this Mac Mini that is just over 40 days old!
    If you know another way to get thru the white screen to get to the Disk Utility...I would love to try it. In any case, I am waiting for a call back to confirm an appointment date and time to visit a Mac store for repair.

  • Double clicking on a file launches the app but doesn't open the file anymore. Why?

    Double clicking on a file launches the app but doesn't open the file anymore. Why?

    I would post in the Illustrator forum here http://forums.adobe.com/community/illustrator or the Dreamweaver forum here http://forums.adobe.com/community/dreamweaver. One of these product forums will be able to help.

  • Ive just subscribed online but realised I have the wrong service by mistake... I require Convert PDF into Word doc service but selected Adobe send in error, sorry. Can you please switch the service for me? Thanks Anthony Levy

    Ive just subscribed online but realised I have the wrong service by mistake... I require Convert PDF into Word doc service but selected Adobe send in error, sorry. Can you please switch the service for me? Thanks Anthony Levy

    Hi Tony,
    Please refer this KB document : Return, cancel, or exchange an Adobe order
    Please let me know if you need any further assistance.
    Regards,
    Rahul

  • I can't open a picture from Lightroom to photoshop using Cmd E, photoshops opens up but doesn't show the picture to edit

    I can't open a picture from Lightroom to photoshop using Cmd E, photoshops opens up but doesn't show the picture to edit

    Ok I sorted it, by uninstalling and re-installing Photoshop

  • I have a hp dv1340us i just install win7 but i cant find the audio Altec Lansing

    i have a hp dv1340us i just install win7 but i cant find the audio Altec Lansing

    Hi:
    You can see if the Vista driver works.
    Manually install it if you have to.
    http://h20565.www2.hp.com/portal/site/hpsc/template.PAGE/public/psi/swdDetails/?spf_p.tpst=swdMain&s...
    There is also this one...
    http://h20565.www2.hp.com/portal/site/hpsc/template.PAGE/public/psi/swdDetails/?spf_p.tpst=swdMain&s...

  • HT3275 Time Machine doesn't see the back-up disk

    Time Machine doesn't see the back-up disk after I've logged off and then back on, even though the disk is available to the iMac 24/7. Turning the disk off and then on in the current session works, but this seems to defeat the purpose of an unattended back-up disk. I can't find a setting that ensures the back-up disk is recognized after log-in or restart. Is there a solution?

    Is this Mountain Lion??
    It seems to have made some changes that make the disk drop out.. it does this even if you are continually connected to the TC and we don't have a solution yet.
    For your login issue, is the TC using a disk password.. or are you setting it to default? Could you try just turning on the guest account in the TC to read and write access and see if this helps. Tell us how it goes.
    There is another fix.. but it involves using disconnect all users from v5 airport utility.. Apple removed the function in v6.
    If you are on Lion or Mountain Lion even you can install the v5 utility.
    How to load 5.6 into ML.
    1. Download 5.6 for Lion.
    http://support.apple.com/kb/DL1482
    Click to open the dmg but do not attempt to install the pkg.. it won't work anyway.
    2. Download and install unpkg.
    http://www.timdoug.com/unpkg/
    Run unpkg on the desktop.. it is very simple.. drag the AirPortUtility56.pkg file over to unpkg.. and it will create a new directory of the same name on the desktop.. drill down.. applications utilities .. there lo and behold is Airport utility 5.6 .. drag it to your main utilities directory or just run it from current location.
    You cannot uninstall 6.1 so don't try.. and you cannot or should not run them both at the same time.. so just ignore the toyland version.. the plastic hammer.. and start using 5.6.. a real tool.

  • My contacts have disappeared this morning, I backed up yesterday but dont know where the back up is

    My contacts have disappeared this morning, I backed up yesterday but dont know where the back up is

    the iphone is designed to be synced to your computer.  You should have been syncing your contacts with Outlook, Address Book for example from day one.
    Have you failed to do this?
    "* Your contacts are part of the backup to preserve recent calls and favorites lists. Back up your contacts to a supported personal information manager (PIM), iCloud, or another cloud-based service to avoid any potential contact data loss."
    Learn more about what is stored in a backup.

  • I can't download any app. It just says waiting but doesn't install. I upgraded iOS 5.0 a few days ago.  Could that be the problem?

    Apps will not download. They just say "waiting" but never install. What should I do?

    Creating an iTunes account without a credit card

  • Installed new screen on macbook pro 15" and now it boots fine but doesn't show the grey boot screen???

    I recently installed a used but in good condition glossy display on my 15" macbook pro as mine the backlight was starting to have issues and there were some surface scratches on the screen. Anyway the screen works perfect except I don't get the grey boot screen when i start the machine up. You can tell the screen is on as you can see the backlight come on. But the screen doesn't actually show anything until it starts to go into OS X. not sure what the problem could be. I relize this is not a big issue but I am stumped on why it is doing this. Also maybe I am just crazy b/c I have dealt with the other screen for such a long time now but it doesn't seem like I am getting exactly the right colors and brighness on the new screen. I have calibrated it and all and like i said it might just be me. More concerned with the whole no boot screen issue. Anyone experience this before, and if so any solutions for me. Thanks.

    It's hard to diagnose but you do have a problem. Take it to an Apple store or AASP and have them diagnose your damage. And, no AppleCare does not cover user accidents. Check with your homeowners insurance.

  • PFR Updated a DFF value in VO but doesn't change the value on the page

    I am in an R12 instance and lets just say I have 2 items in the same VO which I am wanting to update within the ProcessFormRequest. For this case lets just say i want both of the fields to be updated with the string "test". One of the attributes is attached to a descriptive flex field and the other is not. Both of them are displayed within the same region and start off null. What i want to happen is for both of these fields to start off null and once the PFR fires i would like them both to have a value of "test". I should note that both fields do not have any LOVs assigned to them. Right now what happens is when the process form request fires the field not to the DFF is updating correctly but the one tied to the DFF is not. I verified that the DFF field has the correct value for itself in the VO by displaying the value directly from the VO with debug statements right after the setAttribute command was triggered.
    Here is the code for the main controller's PFR:
       super.processFormRequest(pageContext, webBean);
       OAApplicationModule am = pageContext.getApplicationModule(webBean);
       OAViewObject myVO = (OAViewObject)am.findViewObject("the VOs Name");
       OARow row = (OARow)myVO.getCurrentRow();
       row.setAttribute("FieldNotTiedtoDFF","test"); *<--works, the field is then set to test, item not tied to DFF*
       row.setAttribute("Attribute1","test"); *<--not working and stays blank and doesn't get refreshed to test, item tied to the DFF*
    The same thing occurs when i try:
       OAMessageTextInputBean nonDffField = (OAMessageTextInputBean)webBean.findChildRecursive("FieldNotTiedtoDFF");
       nonDffField.setValue(pageContext,"test");
       OAMessageTextInputBean DffField = (OAMessageTextInputBean)webBean.findChildRecursive("FlexID1");
       DffField.setValue(pageContext,"test");
    Any suggestions on why the field for the DFF isn't updated on the user's screen?

    Hi,
    Just try redirecting to the same page at the end of ProcessFormRequest.
    Regards,
    Guru Krishnan V.

  • My music is in alphabetical order but doesn't show the letter headings or the letters on the side. Can anyone help?

    I just synced my Iphone to my new computer and added new music but the music doesn't show up like it used to. It doesn't have the letter headings or the letters going down the side. I have 21 songs right now and they are in alphabetical order but are shown like a playlist rather than a library.

    You do not have enough music to display the letters on the side. The phone needs more music for it to determine you need help going through the alphabet. I saw it written somewhere some time ago, and it does the same thing for Contacts. I believe it takes somewhere between 50-100 entries before it will display that letter side on the right side.

Maybe you are looking for