Results 1 to 8 of 8
  1. #1
    hitmen is offline Member
    Join Date
    Oct 2008
    Posts
    58
    Rep Power
    0

    Default Placing a JProgressBar over my JPEG image

    Can anyone teach me how to do this?

    I wish to overlap 2 components. Does anybody havd any sample code?

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

    Default

    You don't really need to overlap anything here. I'd just draw the image in a JPanel by overriding its paintComponent method, and then place the JProgressBar in this JPanel using your usual layout managers. As for sample code, plenty to be found on this forum, the forums.sun.com forum, and other sites. One of my favorites is this one: JavaRanch - Background Image On J Panel

  3. #3
    hitmen is offline Member
    Join Date
    Oct 2008
    Posts
    58
    Rep Power
    0

    Default

    I am asking if you have a example on implmenting ttwo components that overlap. The problem is that my progressbar and my JFrame keep avoiding each other. I cant get them to overlap

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

    Default

    A JProgressBar is derived from JComponent just like a JButton or JPanel or JComboBox. Again, you place this on a JPanel just as you would place a JButton, or other JPanel or JComboBox on a JPanel. There really is no difference here, and so I cannot understand what difficulties you are currently having. What layout manager is the JPanel that is supposed to hold the JProgressBar using?

  5. #5
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    7

    Default

    Quote Originally Posted by hitmen View Post
    I am asking if you have a example on implmenting ttwo components that overlap. The problem is that my progressbar and my JFrame keep avoiding each other. I cant get them to overlap
    Why would you want them to overlap?
    I die a little on the inside...
    Every time I get shot.

  6. #6
    hitmen is offline Member
    Join Date
    Oct 2008
    Posts
    58
    Rep Power
    0

    Default

    My JPEG is my background image. I want the JProgressBar to overlap it. It cant just be alone at the bottom.

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

    Default

    Again, I suggest you try what I've suggested above.

    To reiterate:

    1) Create a JPanel and override its paintComponent method. Draw your image in this method as per my link above.
    2) Add your JProgressBar to this JPanel, positioning it with whatever layout manager works best for you. If you're not clear on this, then read the layout manager section of the Sun Swing tutorial.
    3) Add this JPanel to a JFrame or JApplet and view to your heart's content.

    This will work. If you don't understand it, then please ask what specifically about it doesn't make sense.
    Last edited by Fubarable; 03-08-2009 at 07:53 AM.

  8. #8
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    7

    Default

    You can like literally copy the code that's on the site fubarable posted.
    I die a little on the inside...
    Every time I get shot.

Similar Threads

  1. Image Coversion .indd to .jpeg
    By vipin.arora@hcl.in in forum AWT / Swing
    Replies: 4
    Last Post: 02-12-2009, 08:52 AM
  2. Placing Files In Folder
    By ramesh.8189 in forum New To Java
    Replies: 0
    Last Post: 02-06-2009, 01:36 PM
  3. [SOLVED] Netbeans Desktop App & JProgressBar
    By SebScoFr in forum NetBeans
    Replies: 3
    Last Post: 11-28-2008, 12:00 AM
  4. To open an image file such as Jpeg file using JAva Program
    By itmani2020 in forum Advanced Java
    Replies: 10
    Last Post: 07-11-2008, 10:57 AM
  5. Simplest way to read and display a jpeg image
    By Hasan in forum New To Java
    Replies: 1
    Last Post: 05-31-2007, 04:42 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
  •