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

Thread: exchange 2 JLabels Location

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    12
    Thanks
    0
    Thanked 6 Times in 2 Posts

    Default exchange 2 JLabels Location

    Hi friends ..

    i have been trying to do a thing like exchange 2 JLabels Location using MouseListener or MouseLocation without any success
    These 2 labels Contain ImageIcons. and have the same width & height...

    is there anybody who can explain me with a code how to exchange their position ??


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: exchange 2 JLabels Location

    Why not leave the labels where they are and just exchange their contents?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    May 2013
    Posts
    12
    Thanks
    0
    Thanked 6 Times in 2 Posts

    Default Re: exchange 2 JLabels Location

    i tried to use img.addMouseListener()..etc

    but the add methods for ImageIcon doesnt seem to exist

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: exchange 2 JLabels Location

    add methods for ImageIcon doesnt seem to exist
    Look in the API doc for the class to see what methods exist for the class and its super classes.

    An ImageIcon object can't be added to a container object. It isn't able to receive events from the mouse or keyboard. Only classes that extend Component can receive GUI events.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    May 2013
    Posts
    12
    Thanks
    0
    Thanked 6 Times in 2 Posts

    Default Re: exchange 2 JLabels Location

    ah ok ...

    is it possible to drag a Label containing Image from a panel1 to another Label containing in panel2 ... making a type of exchange of Labels ? or its not possible due to the Panels ??

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: exchange 2 JLabels Location

    I think that there are GUI building programs that would do that. It is not part of Java SE.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Java Application which will distribute mails from an exchange server
    By Rednaxela in forum Java Theory & Questions
    Replies: 3
    Last Post: January 9th, 2012, 10:20 PM
  2. DH Key Exchange and Blowfish
    By creepish in forum Java Networking
    Replies: 1
    Last Post: December 5th, 2010, 02:30 PM