Why dont we call method paint?? and declare it instead

usually i have seen from previous examplies in my bok that we declare methods somewhere and then we call them sending arguments but in case of paint i saw only declaration as follows
public void paint(Graphics g){
after declaring why is there no code like this:paint(g1);
why no call and still paint does the work .its confusing

Two answers to that:
1) JVM calls paint on its own whenever it detects a need to redraw the screen. This can occur when something is added to it, when a frame is partially covered, moved, resized, etc...
2) paint can sometimes be called programmatically using the repaint() method. This is preferable to calling paint because it finds the correct Graphics object and makes sure that everything that needs a repaint gets its paint method called...
Steve

Similar Messages

  • HT1933 WHY DONT APPLE CHARGERS LAST LONG AND WHAT CAN I DO TO MAKE IT LADT LONGER ?

    WHY DONT APPLE CHARGERS LAST LONG AND WHAT CAN I DO TO MAKE IT LADT LONGER ?

    Not sure what the issue is.
    I have never had an issue with a  charger, nor has anyone I know personally.
    All of my old chargers still work just fine.
    If yours are failing within the waranty period, then you should be able to get a free replacement.

  • Why dont you take ios 7 and take out a feature so the ipod 4 can have enough space to take it I suggest when you touch your screen and the keyboard appears and make the old way.

    Why dont you take ios 7 and take out a feature so the ipod 4 can have enough space to take it I suggest when you touch your screen and the keyboard appears and make the old way.

    We're all users like yourself, if you would like to leave feedback to Apple go to Contact Us at the bottom of this page then go to Feedback and leave your concern. iOS 7 requires 512MB of RAM. Only the iPod 5 has 512MB RAM. The iPod 4 only has 256MB RAM. Hope this helps, Good luck.

  • Why update-1 called as V1 and update-2 called as V2?

    Will any one tell me Why update-1 called as V1 and update-2 called as V2?

    V is from the German word Verbuchung which stands for Update in Englisih. So Update 1 id V1 and Update 2 is V2
    Thanks
    Prince Jose

  • Method paint and DVBTextLayoutMAnager

    Its good idea use method paint when i'm using DVBTextLayoutMAnager??
    Thanks a lot

    Two answers to that:
    1) JVM calls paint on its own whenever it detects a need to redraw the screen. This can occur when something is added to it, when a frame is partially covered, moved, resized, etc...
    2) paint can sometimes be called programmatically using the repaint() method. This is preferable to calling paint because it finds the correct Graphics object and makes sure that everything that needs a repaint gets its paint method called...
    Steve

  • Why cant I call a getResultSet method more than 1

    Why cant I call the getRSS method more than 1 time from my page?
    I have a class called methods class, here is the code:
    public class methodsClass {
        public java.sql.Connection objConn = null;
        public String query = null;
        public java.sql.PreparedStatement statement = null;
        public java.sql.ResultSet objRS = null;
        /** Creates a new instance of methodsClass */
        public methodsClass() {}
         public ResultSet getRSS(String sql)
            String strSQL = sql;
            try
                Class.forName("oracle.jdbc.driver.OracleDriver");
                objConn = java.sql.DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:CCD","system", "Abcd1234");
                statement = objConn.prepareStatement(strSQL,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                objRS = statement.executeQuery();
            catch (Exception e)
                System.err.println("Error in getRSS method");
                e.printStackTrace();
            return objRS;
        public void killConn()
            try
                    objRS.close();
                    System.out.println("Resultset is closed");
                    statement.close();
                    System.out.println("Statement is closed");
                    objConn.close();
                    System.out.println("Connection is closed");
                catch(Exception e)
                System.err.print("Unable to kill all objects");
                e.printStackTrace();
    //END OF CLASS***************************************** I call the method from the following jsp:
    <%
    String eqCat = "Tracked Vehicle";
    String strSQL = "SELECT DISTINCT * FROM robert WHERE eqcategory = '"+eqCat+"'";
    methodsClass mc = new methodsClass();
    ResultSet objRS = mc.getRSS(strSQL);
    java.lang.System.out.println(strSQL);
    %>
         <select name="selectBox">
         <% while(objRS.next()){
             out.println("<option value='"+objRS.getString("eqtype")+"'>"+objRS.getString("eqtype")+"</option>");
               mc.killConn();
    %> The above works fine.
    If I try to call the getRSS function again on this page I get the following error:javax.servlet.ServletException: Exhausted Resultset
    I tried to call it like so:
    newNameSQL = "Select * from robert where eqtypes = 'someVariable'";
    newNameRS = mc.getRSS(strSQL);
    <%=newNameRSS.getString("something");%>I cant understand why I get this error, I am closing the rs,conn and statement in the killConn method.
    TIA!

    I did that but still the same error. The problem is when I attempt to open up another resultset on the same page I get the Exhausted ResultSet error. I have even eliminated the class file altogether by doing this:
      String eqCat = "Tracked Vehicle";
      String strSQL = "SELECT DISTINCT eqtype FROM robert WHERE eqcategory = '"+eqCat+"'";
      Class.forName("oracle.jdbc.driver.OracleDriver");
      Connection objConn = java.sql.DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:CCD","system", "Abcd1234");
      PreparedStatement statement = objConn.prepareStatement(strSQL,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
      ResultSet objRS = statement.executeQuery();
      System.out.println(strSQL);
    //The above works fine and then below I add this and the error comes back
         <select name="cs_popup_name_1" onchange="CSURLPopupShow(/*CMP*/'cs_form_name_1', /*CMP*/'cs_popup_name_1', 'Main');">
         <% while(objRS.next()){
            String eq = objRS.getString("eqtype");
             out.println("<option value='"+eq+"'>"+eq+"</option>");
    objRS.close();
    objConn.close();
    statement = null;
    strSQL = null;
    strSQL = "SELECT * FROM robert";
      Class.forName("oracle.jdbc.driver.OracleDriver");
      objConn = java.sql.DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:CCD","system", "Abcd1234");
      statement = objConn.prepareStatement(strSQL,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
      ResultSet rs = statement.executeQuery();
      System.out.println(strSQL);
    //If I leave the field below commented out I get no errors, but if I comment it out I get the error
    <a href="#" onmouseover="showImg('<%=rs.getString("img1")%>')">                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How do i Call an a method on and object that is a parameter

    I have thee code as below.
    I want to call the method setValue and set the value and pass it a String. i want it called on the jobject param1.
    What do i need to call todo that given the below code.
    JNIEXPORT jobject JNICALL
    Java_PassObjectAndDoSomething_nativeMethod(JNIEnv *env, jobject obj, jobject param1) {
        jstring jstr;
        jclass cls2 = (*env)->GetObjectClass(env, param1);
        jmethodID mid3 = (*env)->GetMethodID(env, cls2, "setValue", "(Ljava/lang/String;)V");
        if (mid3 == NULL) {
            return NULL;
        jstr = (*env)->NewStringUTF(env, "My brand new JString");
        if (jstr == NULL) {
             return NULL;
        /*This causes errors when called*/
        (*env)->CallObjectMethod(*env, param1, mid3, jstr);
        return param1;
    }

    daniel_p wrote:
    /*This causes errors when called*/Presumably you mean a system exception and not java exception of some sort.
    (*env)->CallObjectMethod(*env, param1, mid3, jstr);Why is the asterisk in front of the env parameter in CallObjectMethod()?
    return param1;Since you passed that in it is obviously pointless to return it. But that has nothing to do with your problem.

  • Spry and Permission denied to call method XMLHttpRequest.open

    hi all,
    I'm using Spry to call an RSS feed and display on a webpage.
    I'm running this locally on my computer for testing measures and it
    works fine in IE but i'm getting a message saying "Permission
    denied to call method XMLHttpRequest.open" when using FF.
    I googled around a bit and found that it has to do something
    with FF's cross domain security, but nothing much more than that. I
    was just wondering if anyone would be able to point me to a good
    resource that explains the issue more and how to fix it, keeping it
    in mind that i want to fix it using Dreamweaver's Spry
    options.

    5h4k42u1u wrote:
    > if i'd use the spry tables with an RSS feed, it'll work
    with IE but not with
    > FF, but then when i try it with a local XML file, it'll
    work with FF but not
    > IE? In fact, why does it have trouble at all with the
    local file, there should
    > be no cross domains to worry about, right?
    You're right that there should be no problem with a local
    file, but
    without seeing the XML file and your code, it's impossible to
    say what's
    causing the problem. I think your best bet is to post a more
    detailed
    question in the Spry forum.
    http://www.adobe.com/go/labs_spry_pr1_forum
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Repaint dont call the paint

    Hi all,
    I tried to make a little game loop and draw something to my screen. I have class which is a core of the application - GameScreen. The repaint() method in while loop was execute but the repaint() didn`t call the paint method. Is somebody there who knows where the bug is?
    thnx a lot
    here is the code of the GameScreen class:
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Graphics;
    public class GameScreen extends Canvas implements Runnable
         private RoadRun theMidlet;
         private boolean running = true;
         public GameScreen(RoadRun midlet)
              theMidlet = midlet;
              Thread t = new Thread(this);
              t.run();
         protected void paint(Graphics graphics)
    //here i am drawing
    System.out.println("paint method was running");
         public void run()
              while(running)
                   repaint();
    System.out.println("writte something to screen for check");
    }

    You have to use repaint() with serviceRepaints() for immediate repaint and use t.start() instead of t.run().
    Edited by: Gericop on 2008.08.01. 0:29

  • My dad and i use the same apple id, when he recieves a call, hes phone and my phone ring at the same time, why?

    my dad and i use the same apple id, when he recieves a call, hes phone and my phone ring at the same time, why?  and how do i fix this

    Settings > FaceTime > iPhone Cellular Calls > OFF

  • Windows vista not recognizing my iphone4s when i open itunes, keep getting trust / dont trust message on phone and always press trust. Not sure why it's started doing it. Can not synch iphone at all or add new music....aaahhh

    windows vista not recognizing my iphone4s when i open itunes, keep getting trust / dont trust message on phone and always press trust. Not sure why it's started doing it. Can not synch iphone at all or add new music....as itunes does not pick up the phone I have connected anymore. My ipod synchs fine still and thats over 6 years old!

    Hi rubicon7,
    Welcome to the Support Communities!
    The article below may be able to help you with this.
    Click on the link to see more details and screenshots. 
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/TS1538
    If the issue is not resolved, you may need to uninstall iTunes and all of it's components, and reinstall the latest version as explained in this article:
    Issues installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/HT1926
    I hope this information helps ....
    Have a great day!
    - Judy

  • When I start firefox, i get this message ( The instruction at "0x7b9c77a9" referenced memory at "0x7b9c77a9". The memory could not be "read" ) hs anyone any idea why? I have scanned with AVG and something simply called 'Trojan Remover' and they both fin

    when I start firefox, i get this message ( The instruction at "0x7b9c77a9" referenced memory at "0x7b9c77a9". The memory could not be "read" ) hs anyone any idea why? I have scanned with AVG and something simply called 'Trojan Remover' and they both find nothing.... any advice would be greatly welcomed.. thanks
    == This happened ==
    Every time Firefox opened
    == this morning 22/07/10

    Lyall,
    I have seen this before, a long time ago (several years), and I cannot
    remember how/if we resolved it.
    If this is an impotant issue to you, I suggest that you open a case with
    BEA support.
    Regards,
    Peter.
    Got a Question? Ask BEA at http://askbea.bea.com
    The views expressed in this posting are solely those of the author, and BEA
    Systems, Inc. does not endorse any of these views.
    BEA Systems, Inc. is not responsible for the accuracy or completeness of
    the
    information provided
    and assumes no duty to correct, expand upon, delete or update any of the
    information contained in this posting.
    Lyall Pearce wrote:
    The title says it all really.
    I see other posts getting replies.
    This is a rather important issue, I have seen another post with a similar problem.
    While not being a show-stopper it certainly raises concerns.
    The application works ok until the application exits (in both development and
    executable form)
    Apparently this did not happen with Tux 7.1
    It does with 8, I do not have 7.1 so I have no workaround.
    ..Lyall

  • Dynamic creation of class and calling methods

    I've got and interface called Transformation and then two implementations called TxA and TxB, where TxA and TxB have their own attribtues and setter and getters for these attributes.
    The question is, I need to create instances of TxA and TxB and called the setter and getters where I at runtime I only know the attribute to set, how can I create and instance and call the right getters and setters methods?
    Thanks in advance

    Smart money says your design sucks and needs to be rethought entirely. Can we get specifics?
    Drake

  • Can we call a method before and after Export operations in ADF 11g

    Hi,
    My problem is I have to execute a method before and after the export operation.Is this posible in ADF 11g
    Regards,
    Felix

    Hi,
    in response to a similatr post of yours, I replied
    1. Drop af:exportCollectionActionListener on a command button
    2. set the command button to display = false
    3. In your Java code, call
    ActionEvent ae = new ActionEvent(button);
    ae.queue();
    Everything you put before
    ActionEvent ae = new ActionEvent(button);
    ae.queue();
    will fires as a pre-trigger, everything after as a post trigger
    Frank

  • Why is my ipod so slow and laggy? i have lots of space on it, my history is deleted, i dont have multiple apps running! I have an iPod 4th Gen for about 2 years now and I don't know what to do.... Please help

    why is my ipod so slow and laggy? i have lots of space on it, my history is deleted, i dont have multiple apps running! I have an iPod 4th Gen for about 2 years now and I don't know what to do.... Please help

    Periodically double click the home button and close all the apps in the recently used dock. Then power off and then back on the iPod. This frees up memory. The 4G only has 256 MB of memory.
    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.
    - 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          

Maybe you are looking for

  • How to manage multiple sizes of the same image?

    I recently took up LightRoom for all the good things it does. One of the things I need to do, however, is to create and manage multiple sizes of the same image needed for different purposes. I always found this cumbersome. I totally expected that the

  • Sync deleted all of my contacts, how can I get them back?

    I recently got an iPhone 4s. I synced it to iTunes for the first time to transfer all the music and apps from my iPod touch to my iPhone. In the process all of my contacts, messages, and notes were deleted. I checked for a backup but there hasn't bee

  • Nokia 5200 - Videos from PC to Phone... help!

    I want to get some videos from my PC to my phone's card, and be able to play them. I tried just dragging the videos I wanted straight to the file, but that did not work when I tried to play them back. =( As for the Nokia PC Suite, when I asked it to

  • How to force RH9 to use only one master stylesheet for all Word imports?

    I have set a stylesheet (css) as the default for my RH9 WebHelp project in project settings. When I import Word documents into the project, the edit import setting dialog does not show this stylesheet in the list of available stylesheets for the impo

  • Error when synchronizing an oracle 9ias instance

    Hi, I've got a farm with 2 oracle 9ias instances( with a File Repository ). Both 9ias instance belong to a cluster. When i try to synchronize one of the oracle 9ias instances, i've got the following error : <MESSAGE> <HEADER> <TSTZ_ORIGINATING>2004-0