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 3 of 3

Thread: Jlabel issues

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Jlabel issues

    I have two JLabels. One of them is a large image.

    When I click on the smaller label, it is 'glued' to the mouse. Meaning it moves to where ever the mouse pointer takes it.
    When the mouse is clicked again, the label is 'unglued' and stays where it was dropped.

    The idea is that this small label needs to be dropped onto the large label.
    The problem is that the small label is behind the large label. I cant seem to bring it to the front.

    I'm not using a layout manager (setLayout(null)).

    Any ideas?

    Thanks.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,607
    My Mood
    Hungover
    Thanks
    145
    Thanked 658 Times in 563 Posts

    Default Re: Jlabel issues

    I believe this is what you're looking for: Container (Java Platform SE 6)

    But you might be better off using a GlassPane.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. The Following User Says Thank You to KevinWorkman For This Useful Post:

    Wadashe (February 27th, 2012)

  4. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Jlabel issues

    The Container works... thanks!

    I'm pretty new to the swing side of Java. The only way I could get the small label to move with the mouse was to call setLayout(null).

    I'll look int the GlassPane.

    Thanks again.

Similar Threads

  1. JLabel
    By Poseidon in forum AWT / Java Swing
    Replies: 2
    Last Post: February 18th, 2012, 04:39 PM
  2. JLabel image?
    By frozen java in forum AWT / Java Swing
    Replies: 2
    Last Post: September 28th, 2011, 08:44 AM
  3. Everything but JLabel is displaying
    By Jacksontbh in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 3rd, 2011, 11:30 PM
  4. JLabel placement issues
    By fride360 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 11th, 2011, 01:20 PM
  5. A problem with JLabel!
    By niklas in forum AWT / Java Swing
    Replies: 5
    Last Post: December 19th, 2010, 05:51 AM