Results 1 to 2 of 2
  1. #1
    beam2008 is offline Member
    Join Date
    Dec 2008
    Posts
    1
    Rep Power
    0

    Default help?! paint on top of swing components on JPanel

    I have a JLabel(L1) on a JPanel(P2) with a JScrollPane all on another JPanel(P1), which also has several other JPanels on it.

    I want to be able to click and drag L1 anywhere on P1. To do this I need to paint over everything which mean I need P1 to paint.

    I'm assuming to override the paintComponent method would be easiest.
    If I try to just paint (g.drawString(str,x,y)) then everything I paint is underneath all the components. I can use (super.getGraphics().drawString(str,x,y,z)) but that either doesn't show up or flashes.

    I need something like (super.getGraphics().drawString(str,x,y,z)) but doesn't flash.

    P.S. If anybody knows how to paint directly onto the screen instead of only inside frames it would be helpful to have an example of how to do it.
    Last edited by beam2008; 12-04-2008 at 03:07 PM. Reason: accident smileys

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

Similar Threads

  1. add remove swing components
    By willemjav in forum New To Java
    Replies: 6
    Last Post: 10-09-2008, 07:37 PM
  2. Tab order on swing components
    By ashvin@projectdemo.biz in forum AWT / Swing
    Replies: 1
    Last Post: 05-31-2008, 10:06 AM
  3. Where is it best to declare swing components?
    By MacNstuff in forum AWT / Swing
    Replies: 1
    Last Post: 02-06-2008, 12:59 AM
  4. Removing components from JPanel
    By Echilon in forum New To Java
    Replies: 0
    Last Post: 12-30-2007, 04:05 PM
  5. HTML on Swing Components
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-27-2007, 09:51 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
  •