Redraw order problems with paintComponent

hi,
i've got this test code below which is simply meant to overlay the scrolling transparent text "HELLO" a few times on top of a normal component
my problem is that the image in the panel, is seemingly being redrawn after the text, when it should be drawn as part of the call to super.paintComponent(g)
is having a thread calling repaint() every few milliseconds is the right way to be doing this in the first place??
any help really appreciated,
asjf
ps. pls ignore the dodgy positioning of text, and calculations of widths etc :)
import javax.swing.*;
import java.awt.*;
import java.net.URL;
class AnimTest extends JPanel {
   Font myFont;
   Color myColor;
   int x=0;
   AnimTest(URL u){
      super(new BorderLayout(8,8));
      add(new JLabel("Demo text: ajsk sdjfkl dsjfks jd aisuda siu"), BorderLayout.CENTER);
      add(new JLabel(new ImageIcon(u)), BorderLayout.EAST);
      setOpaque(true);
      setBackground(Color.white);  
      myColor = new Color(255,0,0,128);
      myFont = new Font("Dialog",Font.BOLD,14);
      new Thread(new Runnable(){
         public void run() {
            try {
               while(true) {
                  repaint();
                  Thread.sleep(25);
                  x++;
            }catch(InterruptedException e) {
               e.printStackTrace();
      }).start();
   public void paintComponent(Graphics g) {
      super.paintComponent(g);
      g.setColor(myColor);
      g.setFont(myFont);
      int width = 3*(getWidth()/2);
      int mid = getHeight()/2 + 10; // sort out later
      for(int i=0; i<width; i+=width/5)
         g.drawString("HELLO",((x+i) % width)-(width/5),mid);
   public static void main(String [] arg) throws Exception {
      URL demo = new URL("http://java.sun.com/images/duke.gif");
      JFrame frame = new JFrame("AnimTest");
      frame.getContentPane().add(new AnimTest(demo));
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.pack();
      frame.show();
}

hi, thanks for the reply. I am not drawing the image myself, but am expecting it to be done as part of the redraw of my classes superclass
public void paintComponent(Graphics g) {
   super.paintComponent(g);i was expecting the call to super.paintComponent(g) to draw the contents of the JPanel that I've added (which it does do). The strange this is that the image attached to the JPanel is drawn on top the string that I paint after super.paintComponent(g) has completed. Am not sure how this could possibly happen without some complicated postponing of .drawImage coming into play??
thanks,
asjf

Similar Messages

  • Problem with paintComponent, and CPU usage

    Hi,
    I had the weirdest problem when one of my JDialogs would open. Inside the JDialog, I have a JPanel, with this paintComponent method:
    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Color old = g.getColor();
    g.setColor(Color.BLACK);
    g.drawString("TEXT", 150, 15);
    g.setColor(old);
    parent.repaint();
    now when this method is called, the CPU usage would be at about 99%. If i took out the line:
    parent.repaint();
    the CPU usage would drop to normal. parent is just a reference to the Jdialog that this panel lies in.
    Anyone have any ideas on why this occurs?
    Thanks!

    1) I never got a stack overflow, and i have had this in my code for quite sometime...If you called paint() or paintComponent(), I'm betting that you would see a stack overflow. The way I understand it, since you are calling repaint(), all you are doing is notifying the repaint manager that the component needs to be repainted at the next available time, not calling a paint method directly. good article on how painting is done : http://java.sun.com/products/jfc/tsc/articles/painting/index.html#mgr
    2) If this is the case, and the two keep asking eachother to paint over and over, .....
    see above answer

  • Paul McCartney Pre-Order Problem with Sorting

    I pre-ordered the new McCartney album last week (at which point it downloaded the "Ever Present Past" single) and when it became available today I downloaded the rest fine, except "Ever Present Past" (which should be song number 2) had a different album title ("Ever Present Past Single" or something like that) and thus didn't sort correctly with the rest of the album... so I edited the track to match the same album name and correct track number (being very careful to make sure that all of the fields in the Get Info window match the other tracks, and that there are no invisible spaces throwing it off), but it refuses to sort with the rest of the album... even tried to rebuild the iTunes Library file but that didn't work either... just curious if anyone else has a similar problem and/or a possible solution. Thanks.

    This is ridiculous that this issue isn't being
    > addressed. Same problem here, and I guarantee that
    > I'm not alone.
    Check out the emails I got from Apple on this:
    "I understand that the single " Memory Almost Full" from the album you pre-ordered, will did not download with the album and now you're unable to listen to the album without it stopping to get to the single. Please note that re-downloading the album, will not resolve this issue. You are correct when you mentioned that this issue will happen because iTunes sees it as two different albums because it was downloaded separately. Don't worry. To resolve this issue, I recommend creating a playlist for the album itself. That way, you can arrange the contents of the album so that they will play without interruption.
    This article will show you how to do this:
    Organizing your music and video using playlists
    http://docs.info.apple.com/article.html?path=iTunesWin/7.0/en/517win.html
    I hope you continue to enjoy using the iTunes Store."
    Well, that's great...so not only do I have to isolate the album from the rest of my iTunes collection, it also does nothing to fix the issue on my iPod. So I responded to them as such, and got this response:
    "You did mention very valid points when stating your disappointment with the way pre-ordered albums are downloaded and Apple recognizes that no one is better qualified to provide feedback about iTunes than the people who use it.
    I encourage you to use the iTunes Feedback page to submit your comments:
    http://www.apple.com/feedback/itunesapp.html
    Your efforts to share your feedback are very much appreciated.
    I hope you continue to enjoy using the iTunes Store.
    Is this ridicuous or what? Unbelievable. If I bought a CD in a store and the tracks were incorrectly burned on the CD, the store would take it back or at least try to exchange it for a new copy that wasnt defective. This TECHNICAL ISSUE needs to be resolved.
    iMac 17" 1.83 GHz Intel, iBook G4 12.1"   Mac OS X (10.4.6)  
    iMac 17" 1.83 GHz Intel, iBook G4 12.1"   Mac OS X (10.4.9)  

  • Sales Order : Problem with incompletion log for items

    Hello Experts,
    I am trying to get the incompletion log details for each item of a sales order. I can get the data from xvbuv[] and xvbup[].
    However I am stuck in a strange issue as explained below.
    I am working in the exit move_fields_to_vbak . For a given order say O1 there are two items ( I1 and I2 ).
    Now for the two items I1 and I2 the exit is getting 3 times.
    Call 1 : vbap-posnr is I1, xvbuv[] and xvbup[] is null.
    Call 2 : vbap-posnr is I2, xvbuv[] and xvbup[] contains the data for item I1
    Call 3 :  vbap-posnr is I2, xvbuv[] and xvbup[] contains the data for item I1 and I2.
    The problem here is that vbap and (xvbuv[] , xvbup[] ) are not in sync. I want to process the items one by one in each pass ( Call 1 and Call 2 ) but I am not able to get the correct data. Is this normal behaviour and any idea how to deal with it ?
    Please let me know if any clarification required.
    Regards,
    Sayantan

    Hello Shiva,
    Sorry I wrongly mentioned exit VBAK . I am working with both vbak and vbap exits. vbap is getting triggered twice for two line items 10 and 20. However issue with xvbup[] and xvbuv[] remains, As  .
    As you can see in the image in call 1 zvbup[] and xvbuv[] is not getting populated. and in call 2 its getting populated for line item 10 not 20. I was wondering if these tables related to  incompletion log gets populated after items are processed ?
    Regards,
    Sayantan

  • Iphoto Book ordering problems

    After 3 weeks of constant attempts I feel I need to see if anyone out there has a thought on why I receive a return email from my book order "Problems with your order - you have not been charged etc etc"
    I have done everything possible from deleting photos, trying EVERY theme, deleting maps, background photos. I have corresponded by email with the Apple help, and I have spent about an hour at the Genius Bar at Apple to see if anyone can solve my problem. Everyone has comeback with "we don't know"
    I work with a MacBook Pro Mac OS X 10.6.4, have plenty of memory, all software is up to date.
    I am just about to reinitialise my hard disk, install iLife 11 and make the book again, as I can see no other way to try to get this book ordered. Hopefully, oh every so hopefully this will solve my problem.
    Any guru help?

    Since yesterday there have been many reports from all over the world of people unable to buy a book or any print products from Apple.
    Apple has to fix this on the servers.
    See for example this link:  Re: Trying to buy book I created. When I hit "checkout" nothing happens. It's not like Apple to not want to make more m…

  • I just order 8 calendars from iPhoto and they came to me fine. Now I need to order two more but when I go thru the process I get a message  saying:unable to assemble calendar. There is a probleme with the photo with the file name"(Null)"   more........ .

    Would someone be able to explain to me the following issue with Iphoto?
    I ordered 8 same calendars for my soccer team and received them fine. Although a couple of pictures on it are a little off (out of focus). I need to order two more of the same calendars but when I go thru the process ireceive an error message saying:
    "Unable to to assemble  calendar" There is a problem with the photo with the file name "(Null)" The full resolution version of this photo either cannot be located or is corrupt. Please replace this photo or delete it from your calendar.
    How can  I fine this "corrupt" photo? How did it go thru with the first batch of calendars but won't go thru now?
    Thank you for your help.   

    Apply the two fixes below in order as needed:
    Fix #1
    Launch iPhoto with the Command+Option keys held down and rebuild the library.
    Since only one option can be run at a time start
    with Option #4 and then #1 as needed.
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    1 - download iPhoto Library Manager and launch.
    2 - click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    3 - Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option.
    4 - In the next  window name the new library and select the location you want it to be placed.
    5 - Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments.  However, books, calendars, cards and slideshows will be lost. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    OT

  • A problem with return order with free goods

    Hello
    I am working on ECC 6.0
    I am facing a problem with the return order the case is I created an order of 1000 pc with inclusive free goods (w/o item generation) condition record that for every 10 pc over the 100 the customer will take  1 free pc
    1 pc = 10 $
    100 pcs = 900 $
    120 = 1080 $
    the problem when I am creating a return order with 30 pcs the system  calculate the price as if there are free goods the system returns the 30 pcs with 270 $ instead of 180 $ and it should not calculate the free goods because the remaining items are 90 pcs that should not take a free goods discount
    Regards
    Jacopo Francios

    hi ,
    Such scenerios can be tackled by different pricing procedure in return scenerio.
    See Pricing procedure Depends on sales area + customer pricing procedure + Document pricing procedure .
    So for Return document type please maintain different pricing than the normal scenerio this will solve ur problem.
    This is generally done also for tackling such scenerios.
    Thanks & Regards

  • Problem with material and document date in sales order

    Hi All,
    I am working in ECC 6.0 .I am facing problem with two fields when in enter in to sales order(tcode:va01)
    1.A material comes automatically in line item.
    2.Document date also comes as 27.03.2008 instead of todays date in each order i create.
    I think its not related to configuration.I think its related to some modifications through exits or enhancement points.could someone suggest me a where to check and solve that.
    Your's suggestion is appreciated.

    Hi Sharad,
    Check MV45AFZZ include in se38..It is a user exit for basic validation on sales...We may be able to find some code there (if screen data is predefined by code as mentioned)
    Hope it helps
    Regards
    Byju

  • Problem with order in iPhoto

    problem with order in iPhoto. I can't buy a card, because there comes an Message "Ihre Karte enthält offenbar Standardtext, der noch nicht bearbeitet wurde. Gedruckte Karten enthalten diesen Text nicht. Möchten Sie fortfahren?" What should I do?

    That message means that you have text boxes that have not been used.  The holding text that appears in the box will not be printed. But if you want to get rid of the warning just put a space in the text box.
    OR, check to see if the card layout has the same page but without a text box.  Most do.
    OT

  • I have an iPhone 4S and never had a problem with syncing it. But suddenly, when I connected my phone to my mac, it says that its in recovery mode, and I need to restore it in order to sync. I've updated both my phone and my itunes, and it didnt work.Help?

    I have an iPhone 4S and never had a problem with syncing it. But suddenly, when I connected my phone to my mac, it says that its in recovery mode, and I need to restore it in order to sync. I've updated both my phone and my itunes, and it didnt work.Help?

    fighter19lisa wrote:
    that only makes it say its synced, when its not.
    No, it does not.  It transfers purchases from the iDevice to the computer.  The computer must be authorized for the Apple ID that the content was acquired with.
    fighter19lisa wrote:
    my playlists wont show up on the phone.
    Are they selected to sync?  Is Manually Manage content on the device selected?
    fighter19lisa wrote:
    i had to change my password for my aol account again and i still cannot get my email on my phone to even work
    What does that have to do with syncing content to the device?  FYI, nothing.

  • Problem with prod. ver. explosion to production order

    Hi
    I have problem with production versions. I have FERT with 3 production versions. Additionaly we have Z-program (on Z-table) which control parameter sold to party (from sale order) with production version. So after MRP I see in planned order right production version for example 3 - field PLAF-VERID; in master data in planned order I see right alternative BOM and routing; but when I make a conversion to production order I see that system always explode 1st version; additionaly in planned order in components (button)  I see 1st pr.ver (1st alternative BOM) and in Bill of Material (it seems like to manually expolding BOM) I see right version??? But it couldn't be like this that to have right data I need to go to transaction MD12, explode BOM manully, save and after that make a prod. ord.
    I would like to system explode BOM according to production version (field VERID) already in planned order; so after that it should be that when I will converted it to production order I should have right BOM and right routing from production version signed in planned order.
    I know it sounds complicated Add. in configuration all parameters are set right to explode BOM etc. etc. system version: 4.7
    Thanks and regards. Joanna
    Additional info: I cancel this question cause problem is in Z-program; becuase when according to Z-table system change input in field VERID for system it is only "digital" not parameter for which system should explode right BOM; sorry for disturbing, we need to change Z-programm; I do not know how but maybe any function module can help - we will think. Regards
    Edited by: Kostkaj on Aug 17, 2010 10:25 AM

    HI
    Check this link and find valuable suggestion by Mr Mangalraj regarding selection of PVs
    Produciton version selection in MRP
    Regards
    Anupam Sharma

  • PROBLEM WITH THE PHONE ORDERS

    Hello,
    Is there a problem with the orders which are done with an international credit card? I am asking this because my brother and I have been trying to place an order to buy Macbook Pro with Retina Display for 2 days.
    We placed 2 online orders with my international credit card. In each order I inputted the international address provided by the Bestbuy web site(10780 Kempwood Dr. - Houston, TX 77043) to the billing address. And I inputted my brother's address in the US to the shipping address. Each time, at first,orders were accepted but after 1 minute we received an email that indicated orders were cancelled. Customer service told me that the shipping address and billing address on my order are same and there might be an issue on the system that causes this problem and suggested me to place the order over the phone. I replaced the order over the PHONE(WITH SALES DEPARTMENT) but again I received two emails, one of them is "We received your email" and the other one is "Your order has been cancelled".You can find the reason of the cancellation in the email below;
    We're sorry, but an item on your order placed on June 12, 2014 has been canceled because we were unable to verify your information.
    I am really tired of that,it is like a joke.
    An authorized person should answer this; does BestBuy accept international credit cards or not?

    Hello nbilgin,
    Placing orders on BestBuy.com should be both exciting and easy, and I'm disheartened to read that you've run into these difficulties in trying to purchase your new Macbook Pro. Surely, this is not the experience that we strive to provide and I regret very much that you've been disappointed.
    Using the information you provided when you signed up for our Community. I was able to locate your orders. I am investigating the situation now and as soon as I have additional details, I will let you know. I'm sorry that I must impose on your patience and good nature in the interim; I should have more details shortly.
    I'm very grateful that you wrote to us about this situation.
    Sincerely,
    John|Social Media Specialist | Best Buy® Corporate
     Private Message

  • After I updated lion to 10.7.4, app store does not recognize my ID APPLE and it unable to connect me to app store in order to update/download apps? What have I to do? I have the same problem with mac mini e mac book air. Please help me!

    After I updated lion to 10.7.4, app store does not recognize my ID APPLE and it unable to connect me to app store in order to update/download apps? What have I to do? I have the same problem with mac mini e mac book air. Please help me!

    Your advice did not help me. I also installed 10.7.4 combo but the situation is the same.
    my internet connection is ok, mail is ok, but app store after 3 resets does not recognize my ID and it says "connection is not possible". Why? I have the same problem in both my mac mini late 2009 and mac book air 2010? Is it a problem of 10.7.4 update? I have to solve this problem and how can i return to 10.7.3 if my last backup was not with 10.7.3???thank you for your kind collaboration...

  • Problem with track order (ID3 tags) when transfering from ZENcast Organizer = Vision:M 3

    Hi there, I am using ZENcast Organizer V.2.00.4 and my Zen Vision:M's firmware version is V..6.0e
    Okay, I have a time consuming problem with the way my podcasts are organized on my player. When i download my podcast from ZENcast Organizer everything is neatly organized. By that i mean that the tracks are positioned in the order in which they were released by the radioshow. Let me just give you a picture : [IMG]ttp://img530.imageshack.us/img530/4476/zencastbv4.jpg[/IMG]you can see that after the 27th comes the 28th and the 29th etc. That is also the way i would want the files to be played on my player, but unfortunately they are not.
    Here is a pic of what the order looks like on my player after i have transfered some of the podcasts . Since there are no ID3 tags concerning track number, the player seems to sort the files alphabetically, which is a hassle for me as i have to search through my tracks each time I would like to listen to the following show.
    The way that I have dealt with it until now is to download the tracks with ZENcast Organizer and then add the track number information with Media Monkey and then upload them to the player via Zencast Organizer. That is a lengthy and annoying process and since i have missed the show (due to my new work) for 4 month now, i have a lot of files that i must edit.
    So I was just wondering if there is an easier method? I was thinking in the lines of a plugin for ZENcast Organizer that would add track number information? I wouldn't care if it numbers them 2 3 4 or 2 22 23 24 just as long as they come in the chronologically right order when i play them.

    I did some testing and discovered that ZENcast Organizer indeed does know how to sort the files on my player so that they are played in the right order - under the transfer you just have to check the box which makes ZENcast Organizer convert the music (mp3) files into videofiles as shown in the picture: http://img50.imageshack.us/img50/439...ransferar5.jpg
    This makes my player play them in the right order as shown here:
    But i do not want player to be spending a huge amount of unnecessary power on showing a screen I am not going to be looking at.... my podcast is a radio show, there is nothing to LOOK at, literally.
    Why on earth does ZENcast not change the filename when i choose to download the shows in their nati've mp3 form but only when I convert them to video?

  • I cannot install itunes to my windows 7 computer. I've deleted everthing apple related (in order recommended). I get a message each time that states "There is a problem with this windows installer package. etc.. What should I do?

    I've also spent hours on the phone with both apple and windows technical support specialists. This is very clearly not a windows issue. I've given my computer a clean boot, disable my antivirus and firewall, and then attempted to download (yes, from apple's website). I've delete all of the programs (in the necessary order) and then attempted reinstalling with absolutely no luck. I'm starting to think that there's absolutely nothing I will be able to do. I've also never been able to fine "apple software updater or apple software update on my computer, which is particularly odd because I haven't found a post in this community that answers that question. No, "apple software update" cannot be found by accessing the start menu or anything in the "C drive". Apple software update is also never included in the itunes download package that I get from apple's website (the others, such as bonjour, apple application support, and apple mobile support are). No matter what I do, I always get the mesage at the end of the download, "There is a problem with this windows installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor."
    This may or may not be related to the "apple software update" issue.

    Apparently it's an itunes issue. I just tried to update and got the same issue. Called att to activate my iphone 4s and they say they can do the swap but apple is telling them itunes is down atm.  So will have to wait

Maybe you are looking for

  • Certificate problem? Take my help but I need help too

    Thanks to every one who views my post. I have tried around 4 tecniques for obtaining a self certificate for my mobile application. If any one have tried or succeeded in self certifing your application ,please help me. Or if u too r struggling with it

  • Small cusom class with generic dataypes.

    I'm working on a little project for a class in algorithm analysis. I have to use Java to create a simple list data type from scratch (BasicList); it has 8 functions + constructor. The implementation must be self-contained (no import declarations) and

  • Popup in NetworkManager

    Hello all, Sorry about bothering you with this simple matter but my search for this problem on Google hasn't yet been successful. I've been using a dongle to connect my laptop to the Internet for a long time and it works fine. However, yesterday I ac

  • Internet Exployer has stopped working

    It seemes my computer updated to windows 8.1 automatically and now I keep getting a message that "Internet Exployer has Stopped Working" ----How do I fix this problem??

  • ITunes sometimes freezes during backup phase of syncing

    Usually every day or two when I plug my iPhone in to my Mac to Sync (ios 4.1, iTunes 10) it hangs during the backup phase - even if I leave it for hours. I then disconnect the iphone and shut it down but it hangs when it shuts down (just a spinning w