How Java2D repaint( ) works?

Never mind my problem with not drawing lines. Found the error myself. But it is still greatly appreciated if you could explain how repaint( ) works.
<< Edit ends >>
Old post:
I am very new to Java2D. I am programing an application that need GUI and 2D and got curious about how a panel with '2D' image updates the content.
The program has GUI interface with all menu and buttons, displaying an empty 'content' panel in the middle at the start. Information will be read in from a file and the program should display series of boxes like this:
|    |        |     |             | |        |         |
and another one
|           | |      |           |  |              |   |
--------------------------------------------------------Then, a button named 'align' will match the box stretches between two neighboring series, and the program suppose to display like this:
|    |        |     |             | |        |         |
                    |                        |
|______________________|_______________________________
|             | |      |           |  |           |   |
--------------------------------------------------------pseudo code for related components is like this:
public class alignbox {
  private Boxes[ ]boxes; // store information of box series
  private Alignment aln; // store informations of alignment
  private jFrame frame;
  private jButton[ ] quite_a_few_buttons;
  private DrawPanel pane = new DrawPanel( );
  ... // after button is clicked
  frame.getContentPane( ).repaint( );
  // "content panel"
  private class DrawPanel {
   public DrawPanel( ) {
     init( );
   void init( ) {
      Shape[ ] boxShapes = new Shape[ numOfSeries ];
      for (each bs of boxShapes)
         bs = getPath (boxes);
     Shape[ ] alignedLines = new Shape [numOfSeries -1];
      for (each line of alignedLines)
          line = getPath (aln);
  void paintComponent(Graphics g){
        init( );
        // draw boxes after "open" file
        // daw boxes and alignment lines after "align" button pressed
}from what I read, paintComponent(Graphics g) is the main play displaying images I want. I can get boxes display fine, but I couldn't get alignment line displayed at all.
Does repaint( ) call paintComponent( ) at all? I include 'init( )' in the paintComponent( ). will it allow the updates of boxes[ ] and aln reflected in the DrawPanel?
if not, how do I 'tell' DrawPanel that boxes infor or alignment info has been updated and redisplay the content? Should there be a better way to do so unlike my clumsy method?
Thanks!

Swing related questions should be posted in the Swing forum.
The repaint() invokes the paint() method which in turn ivokes the paintComponent() method (among others). Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/14painting/index.html]Painting for more information.

Similar Messages

  • How does repaint work?

    Can anybody tell me how does repaint work.

    hmm
    raheel_siddiqi = mraheel.
    Smart way of transferring Dukes (and earning more
    Dukes).
    Irrelevant question asked --> Posted in wrong forum
    --> STOOPID answer given ---> Dukes transferred.Very well pointed.... ;(
    >
    raheel bhai.. yeh baccho ka khel nahi hai :)Well Said :-)

  • JScrollPane, JList, Resizing - How does it work?

    Hello NG,
    I have the following situation:
    3 JScrollpanes with 3 JLists to display. 2 Scrollpanes (on the right, 2. and 3.) are in a JPanel with GridBagLayout. This JPanel and the 3rd JScrollpane (on the left, 1.) are in another JPanel also with GridBagLayout. All components have a gridBagConstraints.fill = BOTH setting for resizing. The JLists will be filled from another Thread different from the EventDispatcherThread.
    The Problem:
    The JFrame with the components above will be displayed on the screen. Then the other thread fills the JList of JScrollpane(1), then the two other JScrollpanes (2 and 3). After that, a resizing occurs according to the gridBagConstraints.fill constraint to fill the space between the components. So, the 3 JScrollpanes change their size, it seem to the observer that this resizing occurs without intention.
    Is there a way to prevent this risizing? How does this resizing mechanism exactly works? Who fires which event? Does anybody knows where to find a good description of it?
    So far, I know it starts with the revalidate()-method in the JLists after changing the content of the lists. revalidate() adds the component to the RepaintManger invalidation queue for repainting. But who calls revalidate()? What will happen if the revalidate()-method will be overwritten to do nothing?
    Bye
    Raoul

    You gotta throw use a bone here... How does what work? More info please.

  • How do I work with FK in a data profile?

    Hello People:
    I am new in OWB tools and I have many doubts. Therefore, I would like to know if anyone can guide me a bit with the theme of FK and profiles.
    How do I work with FK in a data profile?
    If I have a table that has a FK to most of the tables, because it is like a parent table. What should I do to have that FK in the profile?
    e.g.
    - Table 1 FK Table 2
    - Table 1 FK Table 3
    - Table 1 FK Table 4
    - Table 1 FK Table 5
    - Table 1 FK Table 6
    - Table 2 FK Table 7
    - Table 2 FK Table 8
    - Table 8 FK Table 9
    You should have a data profile with each table or a data profile for all related tables?
    If I am all in a single profile, that it would have no problem but I would only slow every time that I have to add a new table, but if I got separated, I can not use the FK? What is the solution that will give this problem?
    e.g. PROFILE GENERAL
    - Table 1
    - Table 2
    - Table 3
    - Table 4
    - Table 5
    - Table 6
    - Table 7
    - Table 8
    - Table 9
    OR
    PROFILE 1 -> - Table 1
    PROFILE 2 -> - Table 2
    PROFILE 3 -> - Table 3
    PROFILE 4 -> - Table 4
    PROFILE 5 -> - Table 5
    PROFILE 6 -> - Table 6
    PROFILE 7 -> - Table 7
    PROFILE 8 -> - Table 8
    PROFILE 9 -> - Table 9
    OR
    PROFILE R -> Table 1 / Table 2
    PROFILE S -> Table 1 / Table 3
    PROFILE T -> Table 1 / Table 4
    PROFILE U -> Table 1 / Table 5
    PROFILE V -> Table 1 / Table 6
    PROFILE W -> Table 2 / Table 7
    PROFILE X -> Table 2 / Table 8
    PROFILE Z -> Table 8 / Table 9
    Thank you very much for your help!
    Best regard!

    Any idea, please?

  • How does this work?

    This is not a complaint, but a confused sigh of admiration. I've got an email account at the university where I teach. When I got my iBook, it took me a while, and a few conversations with IT at the school, to get this account working in the Mail application. (Since I have a Verizon DSL at home, I had to include that SMTP as the outgoing server.) Anyway, I synched this mail account (along with my AOL and .Mac accounts) onto the iPhone, and it works perfectly, both incoming and outgoing. I didn't have to change any of the settings. I thought I was computer savvy, but I can't wrap my mind around this. It seems like magic. How does it work?

    The sync process with iTunes transfers the email account settings (for your chosen accounts via your iPhone sync preferences) from the Mail application on your Mac to the iPhone's email application.
    The iPhone is running OS X and the iPhone's email client can be considered a mobile version of the Mail application.

  • My iPhone was stolen and I have contacted the police who are using the meid number to locate.  How does this work and what are my chances of getting the phone back?

    My iPhone was stolen.  I used Find My iPhone app to lock it and display a message.  The phone has not connected to the internet to locate it.  I contacted the police and they have taken my meid number.  How does this work and what are my chances of getting the phone back?  Are there other ways the theif can use it.  I was told once they put in a new sim card and use it, whatever software the police have, it will show up.

    Honestly? In the US (I can't speak to other countries, though I doubt it works much differently in a lot of the world) The police took your report and filed it either in their computers or, on paper. They will now not think of this again. The only time it will cross anyones mind is if, in the course of entering information into evidence about items recovered or seized at a crime scene, the serial number of an iPhone that was found/seized happens to match yours, in which case you will be contacted.
    The police in the US can and will do nothing to 'blok' the phone and it's not worth their time to try and locate it unless you know for a fact that it was stolen by a big time drug lord, master criminal, or some other such prime target and they can get a court order to track the location of the phone in order to locate this individual for your own purposes.  If they do that, they'll probably keep him under surveilance for a year or so before they act.
    Basically, the police don't care about your phone. If they find it, they will give it back to you. They are not, however, going to go looking for it. They have better things to do.
    I'm sorry, but that's the way it is.

  • Was told a USB device would create a PDF automatically from the data contained within when plugged into my USB port. Doesn't seem to work. How does this work and how can I fix the device I received?

    Acrobat is not on the USB device - only Adobe Reader needed on the PC. How does this work? How can I fix this device if at all?

    You need to ask the people who sold it to you. Doesn't sound like it has anything to do with Reader.
    However, you should be wary of devices that automatically try to open files when plugged in. They can also infect your computers with all kinds of viruses or malware.

  • HT2357 So how does this work on Mountain Lion? I cannot seem to ignore the iTunes 11 updates, which now seem to appear every 5 minutes!!

    So how does this work on Mountain Lion? I cannot seem to ignore the iTunes 11 updates, which now seem to appear every 5 minutes!!

    Fantastic!  Didn't work at first so restarted App store and tried again.  This time it asked 'ignore update'.  All gone!

  • TS1425 My co worker has given me his iPod to take home and transfer his music to my laptop, however, I am unable to access his music to download it to my computer.  How does this work?

    My co-worker has given me his iPod to take home and transfer his music to my laptop, however, I am unable to access his music to download it to my computer.  How does this work?

    You need to transfer the iTunes Library from the most recent backup you made before the hard drive was replaced.
    You can't transfer the full iTunes Library from the iPad back to iTunes.
    There are third-party Windows applications that will transfer data from an iOS device, but they don't re-create the iTunes Library exactly as it was before.

  • I have a macbook air and I can't cut and paste in itunes.  The right clic does not work. How can I work this out?

    I have a macbook air and I can't cut and paste in itunes.  The right clic does not work. How can I work this out?

    Great tip Stephen!!
    I was so frustated from this issue that I used to use Windows iTunes for mass editing info, adding Lyrics etc and then transfering songs to Mac. This tip has alleviated my pain!!
    Thanks for the tip. This question should be tagged as answered.

  • After upgrading to Photos, how can I work on a Book Project from another apple device?

    After upgrading to Photos, how can I work on a Book Project from another apple device?

    I'm not sure I understand what you are asking, but on the device/Settings, do you have iCloud and Photos sync turned on?

  • My wife and I have separate Ids but all our music is in one library. How will this work with iCloud?

    My wife and I have separate Ids but all our music is in one library. How will this work with iCloud? i'm trying to download past purchases from her id, but itunes is saying that I can't because the computer is associated with my apple id. Can I associate the computer with both ids for the purpose of identifying all of our music with both or just one of our ids? Is there a good way to do this? I'm sure we're not the only people with this problem...
    Using 2 iphone 3gs, ipad, mac mini, appletv, itunes for windows, macbook, and imac.

    iTunes- How to share music between different user accounts on a single computer
    You cannot merge two separate libraries across user accounts. Photos does not have the function of merging different Photos.library files. If you have Aperture then you can merge the two before migrating over to Photos.

  • HT204053 My husband and I both have iPhones but we only have one iPad. We use the same apple ID because we also share the same email address. How would this work with iCloud because we don't share the same contacts?  Thanks Elainecontacts

    My husband and I both have an iPhone and we share an iPad. We also share the same email address so how would this work with iCloud because we don't share all the same contacts?
    Thanks

    An icloud account is designed to be used by one user.  That user can have all his/her devices synced with the same Apple data (email, contacts, calendars, notes, reminders, etc.) .  When two people use the same account, then problems usually occur when one user edits data that the other user doesn't want changed on their device.  You can continue sharing the same ID for the itunes account in order to share the purchased music, apps, etc.  itunes accounts and icloud accounts are different.
    It's by far better that each user has his/her own icloud account.

  • How does Remote work with Apple TV?

    How does Remote work with Apple TV?
    1. Does Remote, "Play" the music that resides on your iPod Touch>Apple TV>Home Speakers.
    OR
    Does Remote "Control" the music that resides on Apple TV HD>Home Speakers.
    (If so... say you have a iPod Touch that only holds 8GB's but your music collection on your Apple TV exceeds that amount.
    Will Remote still "Control" the larger music collection on Apple TV or your computer?)
    2. Will iPod Wifi work on a patio outside a home to control Apple TV inside the home?
    thank you in advance, Tom

    Remote is a way to control iTunes on either your computer or Apple TV using a WiFi connection. See this article for complete instructions.

  • ICloud Photo Library (beta) - how does it work?

    8.0.2 has an option to enable iCloud Photo Library (beta), I am trying to understand how it works before I turn it on...
    The description says it will auto-upload the entire iPhoto Library to iCloud so other devices that can access these photos by using the same Apple ID. It also has sub-option to keep original photo or keep optimized photo on the device. So questions:
    1. This feature seems to do what Photo Stream does, will new taken photos be auto-sent to iCloud and Photo Stream?
    2. Does iCloud Photo Library count iCloud storage?
    3. Those albums synced with iTunes, will they be uploaded to iCloud Photo Library, and no longer sync with iTunes? Will they be deleted from devices? Will the iTunes Photo Sync selections be disabled?
    4. Here "iPhoto Library" refers to the photo library on devices only, or it includes the Photo Library on computer? My Mac iPhoto/Aperture also signs in the same Apple ID, will those photos on my Mac be auto-uploaded to iCloud?
    5. Presently I sync selected photos to devices via iTunes, if iTunes Sync is disabled after enabled iCloud Photo Library, how can I send selected photos to devices?
    Thanks

    2-factor authentication sounds good but what if in the cloud sends your photos to someone else's account?
    yeah I know sounds like someone with no idea about how these things work, well please read on.
    i posted this last night on tis same forum, and have not received any help on it so far:
    subject: Major security issue! I can see 100's of other peoples photos, Help!
    Oct 1, 2014 4:39 AM
    Using iPad Mini / iPhone 4S
    I have just recently enabled the iCloud Photo Library (Beta). I also use MS Onedrive and i have it setup to automatically backup all my photos and      videos from both my iOS devices.
    Today i opened Onedrive for no particular reason and clicked on the Photos tab, this shows the progress of photos being backed up, only this time i      scrolled down to find that there was hundreds of photos from different families mixed in with mine dating back to 2002! Naturally the first thing i am      thinking is who is looking at my photos/files. What is going on!!!!
    Let me just assure anyone reading this, that the owner of these photographs would not appreciate anyone else having them, these are Kindergarten,      public school and family photos of complete strangers. and all my photos are mixed in between them.
    Is anyone else having this issue
    iPad mini Wi-Fi + Cellular (MM), iOS 8, iOS 8.0.2

Maybe you are looking for

  • Report Pull

    The following link represent a good example . http://apex.oracle.com/pls/otn/f?p=11933:48:244535818693510::NO But i want to replace the Listbox by 3 checkbox items and realy i dont know how to get the value of checked Box! Thankyou

  • Left side of my screen touch isn't working !

    The left side of my screen isn't responding to text. Letters like a, w are impossible to type and cannot access any of the icons on the left side of the screen. I went to apple and they said its an hardware issue and I'd have to pay $200 to replace m

  • Why can't I get a smooth gradient?

    Hi there, I'm setting up a business card file in InDesign and I need a gradient background. Something similar to this effect: http://env1ro.deviantart.com/art/Own-Business-Card-79476719 http://deree.deviantart.com/art/business-card-82906488 However,

  • Odd Safari Youtube Player Issue.

    As of last night safari started doing this in Youtube where half of the video will appear white! It will go away if I enter full screen and back. I've tried every thing to correct this issue and no luck. I have reinstalled safari, deleted the cache,

  • Now on LINUX too: LabHSM, the toolkit for agile and complex event-driven development

    We are happy to announce that, thanks to the efforts of Mr. German Schumacher, LabHSM is now available to the Linux users too. If you are a LabVIEW for Linux user, please feel free to download LabHSM from the respective page of our site: http://labhs