Results 1 to 3 of 3
  1. #1
    ankit1801 is offline Member
    Join Date
    Mar 2011
    Posts
    20
    Rep Power
    0

    Default problem with repaint()

    i have a class testPanel which extends JPanel and have over ridden paintComponent. it takes 2 Arraylists as arguments.
    after that, i called this in a method using the following code:
    Java Code:
    JFrame Myframe1 = new JFrame();
    		Myframe1.setLayout(null);
    
    
    
    		Myframe1. setSize(900,900);
    		Myframe1.setVisible(true);
    		testPanel p1 = new testPanel(reactions,species);
    		Myframe1.add(p1);
    		Myframe1.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    		p1.repaint();
    but when i call p1.repaint(), it isnt working. is there any corrections? or i need to use other method to call paintComponent?

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    What is happening? Errors, nothing, etc? Be more specific. You haven't provided much information. Whats the panels code look like? Try adding @Override above the paintComponent method to make sure you overrode it correctly.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default

    Quote Originally Posted by ankit1801 View Post
    i have a class testPanel which extends JPanel and have over ridden paintComponent. it takes 2 Arraylists as arguments.
    Are you saying you've given your paintComponent method two parameters?

    Then you haven't overridden paintComponent, you've simply written another method.

Similar Threads

  1. Repaint problem
    By citizenXL in forum New To Java
    Replies: 4
    Last Post: 10-28-2009, 03:02 PM
  2. repaint problem
    By amith in forum Java 2D
    Replies: 2
    Last Post: 07-01-2008, 12:10 AM
  3. Problem in repaint
    By Preethi in forum AWT / Swing
    Replies: 16
    Last Post: 03-18-2008, 08:10 PM
  4. Repaint problem
    By swimberl in forum Java 2D
    Replies: 1
    Last Post: 02-16-2008, 09:12 PM
  5. Repaint problem
    By swimberl in forum Java 2D
    Replies: 0
    Last Post: 01-06-2008, 03:28 AM

Posting Permissions

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