Paint(), repaint(), update() question

I have an applet window which paints text,
then a request may be made to the applet to add more text,
my problem is that i seem to be repainting evertything.
please help :o|

i have altered it slightly so that now my program uses a vector which is a list of names, if the list is updated the paint method will need recalling and the new list displayed
//i havent used a canvas but i think it may be more useful is that right?
  public void init()
    this.setSize(250,350);
    this.addWindowListener(new java.awt.event.WindowAdapter()
      public void windowClosing(WindowEvent e)
        chatOnlineListClosing_windowClosing(e);
    this.setBackground(new Color(13, 79, 158));
  } //end init()
  public void paint(Graphics g)
    positionX = 80;
    positionY= 85;
    g.setColor(Color.white);
    g.fillRect(40,40,150,250);
    g.setColor(Color.black);
    g.setFont(new java.awt.Font("Dialog", 1, 11));
    g.drawString("GroupNames", 60, 70);
    if(! nameVec.elementAt(0).equals("")) //checks there is a value in the vector
      for(int i = 0; i < nameVec.size(); i++)
        String name = (String)nameVec.elementAt(i);
        g.drawString(name, positionX, positionY);
        positionY = positionY + 15;
  }//end paint()

Similar Messages

  • Graphics question. paint(), repaint(), update()

    Hi
    I have a GUI which consists of swing components and I want to paint onto them. For example if somebody select a component I want to paint a rectangle around it.
    The select event stores the component in a variable and calls repaint(). This shoul call paint() which looks like this:
    public void paint( graphics g){
    draw the rectangle
    super.paint(g);
    The rectangle is actually painted for half a second. Then it is gone again. I want to have it painted permanentely. Why is the rectangle erased after that? Is it because of the update() method?
    I tried to overwrite the update method with a plain method:
    public void update(graphics g) { }
    it didnt do anything.
    Another question. I have to paint differnt stuff regarding what events are thrown. Is it a good programming style to put all the draw stuff into the paint method and look what happend like:
    if(event a)
    else if(event b)
    ...

    Have you tried putting super.paint(g) before the code to draw the rectangle? I think what's happening is that the super's paint is drawing the component, thus erasing your rectangle.
    You may want to check the API for other options. There may be a property that indicates the size and color of a border. It would be easier and probably look better to adjust that, if it exists.
    I believe that update() draws a background (just a square of background color) and then calls paint(). If you override it with an empty method, I'd expect that nothing would be drawn.

  • Can we make things more Useful...? not an update question.

    Ok well i said its not an update question.. well it kinda is.
    today is friday.. the release date of the new iphone 3g.. great.. i love my iphone.. im goin to wait a week or so before i go ahead and buy the new phone for sake of bugs and lil tweaks..
    ok so today i dont know what drove me to update my iphone.. and it got totally bricked for 3 hours.. until i finnally got thru using the "clicking" solution... well i understand the server is overwelmed.. and everyone is updatin and the same time.. but there was a prompt askin if i wanted to update and get the latest iphone software and the latest version of itunes... good.. lets all download it.. most of us it will take 3-6 hours for the iphone to update because the whole problem with the overload on apples side...
    ..BUT...
    what if we cant wait that long?
    i SYNC'd my iphone before the update.. well everyone does... itunes prompts you to do so.. WHY.. emphasizing on WHY... if we synced the phone to our computer systems.. and a problem like for example is goin forth now with this update... CAN'T we just restore our iphones back to how it was before we even tried updating it?
    IT did SAVE to our computers right?
    why cant we just double click here, right click right there..
    and BOOM..
    back for pre 2.0 days.. well until after the storm has passedt..
    why cant we have that option in itunes... heck why not?
    hey doctors will always have beepers to get in contact with.. so hey the whole life death situation thing means it isnt that that THAT bad.. but hey everyone needs there cell phone and people use cell phones.. this one in particular for business.. so maybe we could have avoided some confrontation to some conference calls and clients.. etc... well regardless.. as easy for the update to have made the iphone in a way "bricked".. i think it should have been easy to restore to pre 2.0 .
    windows has that option in its system restore feature...
    download something that messes up your system? virus? update that doesnt work well with the OS?.. restore to an earlier date is an option in the control panel..
    i think itunes need something like that with the iphone version..
    last but not least..
    i love my iphone :-D

    uppers

  • Updated question: Both Mac & PC links possible??

    I apologize right away for posting a new topic with my updated question. But I realized I didn't phrase it right to get any help.
    The question is - is it possible make both Mac links and PC links available on one disk. They would be in separate chapters. (i.e., directing Mac users to this page and Pc to another) Anyone tried this.
    thanks.

    hi jujubes
    I just realised I misled you in my replay to your earlier post due to my poor writing skills
    to clarify:
    I suggest using Intellidisc to create the links for playback on a PC
    you would also use DVD@Access within DVDSP to create the links for Mac playback
    the links will work when played back on both mac and PC from this single disc
    the Intellidisc website gives all this in a tutorial at:
    wwwintellidisc.com

  • Software Update Questions

    Hi everybody,
    I'm still relatively green in the computer world, so, I'm sure these questions are way to "rookie" for you. Nevertheless; here they are.
    Software Update Questions:
    1. What is J2SE 5.0 Release 4, version 4.0 (39.3 MB) and, is it necessary to install?
    2. What is X11 Update 2006, version 1.1.2 (51.0 MB) and, is it necessary to install?
    In case you need to know, I have Mac OS X (10.4.8) with a Verizon FIOS connection.
    Thanks,
    Wayhun
    iMac   Mac OS X (10.4.8)  

    J2SE 5.0 is the latest version of Java. Mac OS X originally ships with Java 1.4 and this gives you the opportunity to upgrade to the latest version.
    It's an optional upgrade since there are many changes between Java 1.4 and java 5, so some people might prefer to hold off until they've verified their Java apps work with the new version. For most people, though, it isn't an issue.
    X11 (also known as XWindows) is a standard GUI interface for Unix systems. If you're using X11 you'd probably alredy know about it and therefore wouldn't be asking this question. It's not going to cause any problems if you update it, but it won't offer any advantage unless you're running X11-based applications.

  • Choose between: paint, repaint, paintComponent

    Hi,
    I am having problem's refreshing elements that i have draw in a jpanel, which is include in a container (well .. i just can not see anything at all).
    what do i have to use : paint, repaint, paintComponent ?
    is there some good tutorial online to learn to draw whith swing ??
    or better : to learn to draw a graph from a given tree.
    thank you!
    Syl.

    Must Read !!!
    Thanks
    --j                                                                                                                                                                                                                                       

  • JTree Updating question

    Hi there. I have two questions.
    I have a data structure that is being displayed in a JTree, so I made a Model and it works great. The data structure can be updated from non-gui interaction. The nodes don't change position or anything, its just the data that is displayed is changed. I handle it currently by calling a function in the model I made called nodesChanged(), which basically does the following:
    public void nodesChanged()
        int len = treeModelListeners.size();
        TreeModelEvent e = new TreeModelEvent(this, new Object[] {rootItem});
        for (int i = 0; i < len; i++) {
          ( (TreeModelListener) treeModelListeners.elementAt(i)).treeNodesChanged(e);
      }It does actually work, the changes are reflected in the JTree, but it seems a little expensive, and the updates to the actual data model could come at about 150 per second. To deal with that now, I just use a timer class that updates it about every 3/10's of a second, which does a pretty good job, but is there a more elegant way to do this? Something where the node is an observer of the data in the data structure (which are Observable objects)?
    The second question I have is when I do the above, sometimes the display name of the node will be larger than the value it had previously, but the Textbox (if that's what it is) doesn't grow, so I get a ... at the end.
    For example, if I have "Run" and it changes to "Stopped", it will show up as "Sto...".
    Any help would be great. TIA.

    well, you can start by making the node you put in the tree model event the lowest node in the tree that needs updating, instead of root.
    I don't know about the timer thing, cuz as far as I know, the listener will invoke code that will refresh the renderers, as opposed to painting where repaint calls can be merged into one. If you aren't getting that many updates all the time, you could implement something where the listener fires to an intermediate listener which will fire the info to the tree after a slight delay. That way if you get multiple updates, you can effectively ignore lots of them.
    The ... thing, I thought that treeNodesChanged was the appropriate method, although maybe it has to be for the specific node, not root.

  • Paint()/repaint() problem w/applet

    Hi all. Here's my dilemma: I'm trying to create an applet that asks for simple multiplication answers, and draws a string giving feedback after the question is answered ("Very good!" or "No, try again."). The problem is that the book says to draw everything from paint(), and gives the impression that repaint() should magically refresh everything on the applet, which it does not. How can I make the strings I drew in paint() go away and give way to new strings based on user answer (whether correct or not), instead of piling up on top of each other, because they don't refresh? Also, my JButton and JTextField aren't showing up until the mouse is scrolled over them. Thanks for your time!
    code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class Week5Class extends JApplet implements ActionListener
        static int int1 = (int)(Math.random()*10);
        static int int2 = (int)(Math.random()*10);
        JTextField answer = new JTextField(3);
        JButton verifyAnswer = new JButton("Click to see if correct");
        public void init()
            Container myContainer = getContentPane();
            myContainer.add(answer);
            myContainer.add(verifyAnswer);
            verifyAnswer.addActionListener(this);
            myContainer.setLayout(new FlowLayout());
        static int j = 0;
        static int i;
        public void paint(Graphics gr)
              gr.drawString("How much is " + int1 + " * " + int2 + "?", 10, 70);
              if(i == 1)
                  gr.drawString("VeryGood!", 300, 200);
              else if(i == 0 && j != 0)
                  gr.drawString("No. Please try again.", 300, 200);
              j++;
        public void actionPerformed(ActionEvent e)
            int x = 300;
            int y = 200;
            if(Integer.parseInt(answer.getText()) == (int1*int2))
                int1 = (int)(Math.random()*10);
                int2 = (int)(Math.random()*10);
                i = 1;
                repaint();
            else
                i = 0;
                repaint();
    }

    The problem is that you're mixing doing your own drawing and using child objects. The paint method you've overriden would be the one that draws the text field and button.
    A far easier approach would be to use a JLabel to display your response message, and insert that as another component into the container, as you've inserted the button and input field.
    Then use setText() on the label to change the message.
    If you really want to have an area that you draw arbitary shapes on it's best to create your own child component, add it to the container, and override it's paintComponent method. Alternatively create a class which implments the Icon interface and put it in a JLabel.
    FlowLayout isn't very clever, by the way, try a BorderLayout or maybe a BoxLayout.

  • EFI Update Question

    Hey all.
    I just have a question about the EFI update that i have been promted to install via the update function on my new MBP 2011.
    But then when i read witch models that are affected, then my model is not amoung the affected models, so why do i need to install this update...?
    Therefor my question is this...! Is there something "sinister" about the hardware, that i dont know about in my MBP 2011 edition, since this update is primarily for older MacBooks. So is it an "old" MacBook in disguise.....or just something everybody has to install...?

    The EFI updates are designed to install Apple monitoring software so they can read your hard drive, your browser and record any ripped MP3 files or other copyrighted media you have.
    This is the exact intention of why EFI was created by Intel at the behest of the media industry. The UEFI forum is run by the MIAA and RIAA lawyers, the same who now run the US Justice Department
    http://www.wired.com/threatlevel/2009/04/obama-taps-fift/
    http://www.uefi.org/about/
    You have no access to EFI, it does exactly what it pleases, your OS X and programs you install have no control over it or even can tell what it's doing.
    If EFI allows you to do something, it's because it is, it has the power to stop you as it sits between your OS and hardware.
    Every wonder why you can't boot off certain OS X install disks? It's because of EFI.
    Apple sent out a firmware update and disallowed any booting off 10.5 disks, try it!
    Not only that, Apple has scrambled the airport wifi signals so you can't use sniffing software on another Mac to determine if EFI is making outbound connections.
    Also Apple has turned off the Airports blinking light, or if you like the blinking, it blinks all the time without any regard to if there is a transmission going over it or not.
    To add further insult, new wired keyboard from Apple require software installed, firmware in the keyboard can record your keystrokes.
    The pieces to a fully secure, fully monitored, computing system is slowly being lowered into place.
    In fact the iSight camera can be turned on remotely without the green light appearing for covert surveillance.
    Apple has hired NSA expert David Rice to lead it's computer security team, you KNOW the NSA has backdoors
    on the Internet
    http://www.wired.com/science/discoveries/news/2006/04/70619
    in Windows
    http://slashdot.org/story/99/09/03/0940241/nsa-backdoor-creates-security-hole-in -windows
    Do you really think the Mac has been ignored?
    It just works better in EFI that's all.

  • Flash Player installation and update questions and answers

    How do I verify that I have the latest version of Flash Player?
    If you receive a message that tells you that Flash Player is out of date or a new version of Flash Player is available, you can verify this by visiting the Flash Player Help page with your browser.
    Simply click the "Check Now" button and you'll be presented with a short message and detailed information regarding your Flash Player installation.
    Where should I download the latest version of Flash Player?
    Because malware authors will often employ misleading tactics to make malware look like something you should trust, it's important to get your Flash Player updates directly from Adobe.
    Please verify that your Flash Player downloads and updates come from only the adobe.com or macromedia.com domains.  You can always download the latest version of Flash Player directly from https://get.adobe.com/flashplayer
    I've selected the automatic update option in Flash Player, why do I continue to get update notifications?
    Periodically, users are presented with the Flash Player update dialog notifying them that a new version of Flash Player is available for download from adobe.com.
    The automatic update mechanism is used for some updates, security patches that address zero-day vulnerabilities and when users, who have selected to be updated automatically, have not updated within 45 days after a regularly scheduled update release of Flash Player.
    What should I expect when I receive notification that Flash Player has an update available?
    When a major update to Flash Player becomes available you will be presented with a Flash Player update dialog
    After reviewing new features, pressing the Download button will open your default browser and load the Install Adobe Flash Player page.
    Clicking the "Update now" or "Install Now" button will then take you to the next page which will start the download process and give instructions for completing the Flash Player install.
    Finally, once the installation is complete your browser will display a page confirming a successful installation.
    If you encounter installation problems, we recommend you review our Windows and Mac OS installation help documents. Further questions and information can be found on the Flash Player installation forums.
    Why does Adobe Flash Player installer include the option to download additional software?
    Adobe offsets the ongoing development costs of Flash Player, which is made available for free, by offering users the option to download select software from Adobe partners.
    What options do I have when installing or updating Flash Player?
    You have a few different options available when updating Flash Player. We recommend that you choose "Allow Adobe to install updates (recommended)" when initially setting up Flash Player
    or by going into the Flash Player control panel and choosing this option in the Advanced tab.
    Once selected, most updates will occur in the background without requiring any interaction. For those regularly scheduled major update releases, you will be presented with an update notification dialog
    If you decide not to update, you will receive an automatic update within 45 days if you have the "Allow Adobe to install updates" option selected. Please note that when this update occurs, only Flash Player will be installed.
    If you want to be notified about every Flash Player update, select "Notify me to install updates" when initially installing Flash Player or from the Advanced tab in the Flash Player control panel.
    Finally, if you'd prefer not to receive any updates, select "Never check for updates (not recommended)". We do not recommend this option as we believe keeping your system up to date improves both security and stability when using Flash Player.
    For network Administrators we offer additional update options, including the ability to host your own internal Flash Player update server. Please see our Flash Player distribution page and Flash Player Administrator guide for details.

    Sunil, I just want to verify you are pointing me to the link under "Progress bar hangs during download / Unable to connect to server / Unable to download metafile."
    If yes, then that is the file I originally downloaded based on a March post I saw here.
    I just tried it again, and it (by "it" I mean the Flash Player Plug-in (All other browsers from download.macromedia.com) installed 11.6.
    After the installation process completed, the dialog box notified me it was version 11.6, and when I went back to, the "find version" page, 11.6 was confirmed.
    I did not download the exe for Internet Explorer, as I almost never use that browser.

  • Acrobat 9.5.2 update questions

    Nov. 15, 2012 - As Adobe sends there update notices, I updated yesterday morning and lost all functionality.  Couldn't open a PDF, kept getting messages that my license had expired.  Called Customer Support and after an hour on the phone, we uninstalled my Acrobat 9.0 Standard (download version) and then reinstalled it from my Adobe Order History online. 
    Then was told to update with 9.5.1 (not 9.5.2 which was what the upgrade was yesterday).  Now, 9.51. will not install because of a message that reads: &quot;The upgrade patch cannot be installed by Windows Installer because the program to be upgraded is missing, or the upgrade patch may update a different version of the program.
    This is case no. 183809469 - a few questions regarding the install this morning:
    Also, I was instructed to download Acrobat to my desktop (???), then it of course installed in my Programs Folder.  Now I have a new 334 mb Adobe folder on my desktop and a new 884 mb folder under Programs, which I believe is new 9.0 program (its dated today).  Can I delete the one on the desktop now?
    Also have an original 334mb folder for Acrobat 9.0 on my C:/drive. which is from my 2009 install.  Can I delete this now?

    I hope you did not delete all the download files. If nothing else you should store a copy on a CD or DVD to archive the files. You can then also record the software key in case you need to do future installs. Do not expect for the download to be available in years to come, so you need to have the archive in case you have issues requiring a reinstall.
    When the update from the Help menu does not do the job, you can download them from the web site provided. Be aware that most of the updates are not cummulative and you will need to install them in order.

  • A Tiger Software Update Question from the iBook Forum

    I just finished reading this question,
    http://discussions.apple.com/thread.jspa?messageID=12901184#12901184
    in the iBook G4 forum and am very curious myself if this could be a problem with the update. If someone knows why this is happening, would you please help the poor guy with two dead iBooks?
    Thanks,
    Randy

    I'm sorry, I didn't mean that the other member's question was solved, only my part in it. That must have been confusing. I should go back to mark it unsolved.
    I subscribe to the iBook G4 forum and when this question came up, I looked through other forums to try to find an answer for him/her. The Tiger forum seemed like the logical place to post the question. It looks like the right person came to the rescue! Thanks. Discussions members have helped me out by networking like this, so it's great to be able to return the many favors.
    Randy

  • Patch 8833297 - 11.1.0.7.1 Patch Set Update question.

    Hi
    The O.S oul5x64
    database version 11.1.0.7.0
    after applied this patch
    Patch 8833297 - 11.1.0.7.1 Patch Set Update
    and went thru the post installation procedure.
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE 11.1.0.7.0 Production
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    and sql*plus was still showing 10.1.0.7
    Question:
    Should i see the new version 11.1.0.7.1 or it is normal ?
    Thanks in advance!

    No, version does not change.
    Does PSU Released For Oracle 10gR2 (10.2.0.4)and 11g R1 (11.10.7) Change The Database Version/Fifth Digit ? ID 861152.1+
    Nicolas.

  • Quick windows update question

    I searched and couldn't find exactly what I was looking for.
    So I installed windows xp SP3, and so far it's going good. My question is will any of the normal windows updates mess up anything at this point.

    Ruka:
    You installed SP3 update and Windows is running fine so the answer is that windows updates will also work fine in the present and the future.
    Axel F.

  • Quick dynamic update question

    Hi all,
    We've just got Color at work and I'm pretty impressed with it. Next they'll be bundling PFTrack or Boujou for free! Just a quick question though..
    If I send an edit from FCP to Color, do some grading (including keyframing), and then get a revised EDL through or have to alter the cut in FCP will Color be clever enough to automatically or otherwise update the clip timings? (assuming I'm still working in the original timeline)

    Qualified yes.
    Apple manual:
    Page 79.
    But there are a lot of release notes regarding re-rendering material. Beware.
    JPO

Maybe you are looking for

  • Problem during implementation of SP5 in PI 7.1 EHP 1

    Hi, we try to implement SP5 in our new installt PI System (7.1 EHP1) with the JSPM. The validation phase aborts and in the  JSPM_MAIN_1_01.LOG there is the following enty: Aug 16, 2010 9:59:28 AM [Error]: Validation finished with error. See log /usr/

  • Facetime on an ipad

    My son received an ipad 2 for christmas and would like to Facetime, I have no clue what I need for him to do this other than a wifi connection. If someone could give me a play by play on how to set this up, that would be great! Thanks!!

  • Print preview splitpane

    Hello everybody I have a splitpane which has a list on the left panel and a editorpane on right. Whenever an item is clicked in the list , some corresponding text would be displayed on the right panel. i am working on providing print and preview opti

  • Why does lastlog say ive never logged in?

    So I was checking out some threads on noost forums and I came across a thread about somebody who got a message when they tried to shut down saying that they need to input the root password to log out multiple users.  This was strange becase there was

  • Write a query / pl/sql statement for desired results

    Here is the table data: FSSETY FSUSER FSOBNM FSA FSCHNG FSDLT FSIOK FSICPY FSATN1 1 DSTEIN P0030A N N N Y N Y 1 FINAB001 P0030A Y Y Y Y Y Y 1 FINAB001 P01012 Y Y Y Y Y Y 1 DSTEIN P01012 Y Y Y Y Y Y 1 DSTEIN P01013 Y Y Y Y Y Y 1 FINAB001 P01013 Y Y Y