Results 1 to 12 of 12
  1. #1
    hrayr is offline Member
    Join Date
    Jul 2011
    Posts
    9
    Rep Power
    0

    Question paintComponent does not work if its called by the recursive function???

    Hello,

    When I execute this code the output is as follow:
    1; set_points;2;1; set_points;2;1; set_points;2 and paintComponenent only ones and at the end of the function and the image change only one time.
    How can I do that it enter in paintComponenent just after it enter in set_points ?


    Java Code:
    drow d;
    
    function(){
    System.out.println("1");
    set_list()
    System.out.println(2");
    ...
    function()
    ...
    }
    Java Code:
    public class drow extends JPanel {
    ...........
        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 =(Graphics2D) g;
    	
        System.out.println("paintComponent");
            
        }
        public void set_points(LinkedList <point> p){
            Points =p;      
            super.repaint();
            System.out.println("set_points");
          }
    Last edited by hrayr; 04-26-2012 at 10:45 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: hrayr5@hotmail.com

    Please edit your post above. To get the best help, the title of your thread here should be a summary of your problem, something that make sense and something that attracts the interest of experts in this particular problem. Also you should never publish your email address here.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: paintComponent does not work if its called by the recursive function???

    Are you calling Thread.sleep(...) on the Swing event thread? If so, then this will freeze your program and prevent it from drawing or doing any updating to its display or user interaction.

  4. #4
    hrayr is offline Member
    Join Date
    Jul 2011
    Posts
    9
    Rep Power
    0

    Default Re: paintComponent does not work if its called by the recursive function???

    I have edites the code. I wont to do three to stop the execution of the code but to o the changes in the Swing. However the code execute after a sleep but the swing does not update till the end of the execution of the hole code.
    Even without the thread it change anything

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: paintComponent does not work if its called by the recursive function???

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    hrayr is offline Member
    Join Date
    Jul 2011
    Posts
    9
    Rep Power
    0

    Default Re: paintComponent does not work if its called by the recursive function???

    1. I did not understand how timers work, can you tell me how it works?
    2. During execution the function I see "set_list" but not "paintComponent", and paintComponent is called only after the enf of thr function. How can I solve this probem?


    Java Code:
    drow d;
    Thread th;
    th = new Thread();
    function(){
    set_list()
    
    ...
    function()
    ...
    }
    Java Code:
    public class drow extends JPanel {
    ...........
        @Override
        public void paintComponent(Graphics g) {
             
            Graphics2D g2 =(Graphics2D) g;
        super.paintComponent(g);
    
       System.out.println("paintComponent");  
        }
    
        public void set_list(LinkedList <point> p){
            System.out.println("set_list");
            Points =p;     
            super.repaint();
          }

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: paintComponent does not work if its called by the recursive function???

    Thanks for not telling us about your cross-posts. That is very inconsiderate of you, making us waste.

  8. #8
    hrayr is offline Member
    Join Date
    Jul 2011
    Posts
    9
    Rep Power
    0

    Default Re: paintComponent does not work if its called by the recursive function???

    Quote Originally Posted by Fubarable View Post
    Thanks for not telling us about your cross-posts. That is very inconsiderate of you, making us waste.

    I did not wont to make you waste.
    I accept the help from everybody, if you can help me
    it would be good if not may be they can do this :)
    Last edited by hrayr; 04-26-2012 at 08:59 PM.

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: paintComponent does not work if its called by the recursive function???

    Quote Originally Posted by hrayr View Post
    I did not wont to make you waste.
    I accept the help from everybody, if you can help me
    it would be good if not may be they can do this :)
    You haven't done much volunteering in a forum, have you? If you had, you'd understand how frustrating it is to work trying to help someone on your own time, only to find out later that the question was already answered in a cross-post. Again, if you have any consideration for us at all, you will post links to all cross-posts if you have any. Else no one will want to help you.

  10. #10
    hrayr is offline Member
    Join Date
    Jul 2011
    Posts
    9
    Rep Power
    0

    Default Re: paintComponent does not work if its called by the recursive function???

    Quote Originally Posted by Fubarable View Post
    You haven't done much volunteering in a forum, have you? If you had, you'd understand how frustrating it is to work trying to help someone on your own time, only to find out later that the question was already answered in a cross-post. Again, if you have any consideration for us at all, you will post links to all cross-posts if you have any. Else no one will want to help you.
    Here are the cross posts, however I have not get the answers.

    paintComponent call in the recursive function | Java.net

    java - paintComponent does not work if its called by the recursive function? - Stack Overflow

    Now can you help me with my two questions?

    Thank you

  11. #11
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: paintComponent does not work if its called by the recursive function???

    In what thread are you calling set_list()?

    Also, set_list is a strange name for a method, and drow is a confusing name for a class. See the link in my sig.
    Get in the habit of using standard Java naming conventions!

  12. #12
    hrayr is offline Member
    Join Date
    Jul 2011
    Posts
    9
    Rep Power
    0

    Default Re: paintComponent does not work if its called by the recursive function???

    I have change the first post.
    thanks for the link I will change them also

Similar Threads

  1. mailprogram (hotmail error)
    By Fabken in forum New To Java
    Replies: 1
    Last Post: 08-07-2011, 12:39 AM
  2. javamail smtp ssl yahoomail,hotmail
    By Jhovarie in forum Threads and Synchronization
    Replies: 0
    Last Post: 02-24-2011, 01:21 AM
  3. How to access yahoo/gmail/hotmail address book
    By shahinengg in forum AWT / Swing
    Replies: 3
    Last Post: 11-23-2009, 11:14 PM
  4. To access hotmail contact list using java
    By bharat_kasodariya in forum Advanced Java
    Replies: 1
    Last Post: 02-26-2009, 02:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •