Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Painting swing components to an arbitrary position?

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Painting swing components to an arbitrary position?

    Hi, first post, but I'll try to repay the favor by hanging around and helping others if someone solves this problem for me

    I'm working on a project for a conferenceware program and I now need to know how to draw a JComponent to any spot on the screen. My first lead from Google was the CellRendererPane, which worked fine.... If I had of wanted to draw a rectangle. The paintComponent method didn't do anything, much less tell me if something was wrong. So I went searching again and stumbled across SwingUtilities.paintComponent. This one told me something was wrong, but gave me nothing to fix it. It threw a NullPointerException about a CellRendererPane, which left me wondering if it would have worked anyway.

    tl;dr: Anyone have some sample code I can have a look at? This may need to include some initialisation code that would be easy to miss (at this stage I'm just constructing the components and chucking it through the methods). Any help at all would be appreciated, as I really don't want to have to write this thing from scratch


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Painting swing components to an arbitrary position?

    Have you taken a look at this yet?

Similar Threads

  1. How to get Mouse Position even if it is not within our application?
    By Freaky Chris in forum Java Programming Tutorials
    Replies: 2
    Last Post: January 4th, 2012, 10:57 AM
  2. How can i make the components resizable?
    By ces_31 in forum AWT / Java Swing
    Replies: 4
    Last Post: October 1st, 2009, 10:46 AM
  3. The Frame to be Center Position
    By r12ki in forum AWT / Java Swing
    Replies: 3
    Last Post: October 1st, 2009, 10:36 AM
  4. [SOLVED] find the position of the field separator in the String---need help ASAP
    By rajesh.mv in forum Java Theory & Questions
    Replies: 6
    Last Post: August 17th, 2009, 10:33 AM
  5. Change JFrame components problem
    By bruno88 in forum AWT / Java Swing
    Replies: 0
    Last Post: June 30th, 2009, 01:25 PM

Tags for this Thread