Results 1 to 3 of 3
  1. #1
    Alerhau's Avatar
    Alerhau is offline Senior Member
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    158
    Rep Power
    4

    Default Painting things on a JPanel class from another class?

    The title says most of it. Is this possible?

    Paint class:
    ...
    public void paintComponent(Graphics g) {

    }
    ...

    The class I wanna paint from:
    ...
    public af() {

    }
    ...
    Currently Developing a Game Called Loaie, You Can Download It From "The Loaie Website".

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Painting things on a JPanel class from another class?

    Yes it is possible, so long as your JPanel class has a reference to the object that does the painting (and the class of that object contains a method to do the painting to a Graphics object), and thus it can pass its Graphics object (from within the paintComponent method) to the painting method of said object

  3. #3
    Alerhau's Avatar
    Alerhau is offline Senior Member
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    158
    Rep Power
    4

    Default Re: Painting things on a JPanel class from another class?

    Aaah, could I please get 1 - 4 lines of code for how to do it? (-:
    Currently Developing a Game Called Loaie, You Can Download It From "The Loaie Website".

Similar Threads

  1. Adding a jpanel to a customized Jpanel Class
    By trishtren in forum AWT / Swing
    Replies: 7
    Last Post: 04-05-2011, 06:52 PM
  2. Problem painting on JPanel
    By Boatski in forum AWT / Swing
    Replies: 0
    Last Post: 12-01-2010, 04:36 AM
  3. JPanel not always painting everything
    By ekted in forum AWT / Swing
    Replies: 0
    Last Post: 11-26-2009, 11:24 AM
  4. Replies: 3
    Last Post: 04-20-2009, 11:31 PM
  5. Jpanel painting problem
    By kcakir in forum AWT / Swing
    Replies: 3
    Last Post: 04-15-2009, 10:21 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
  •