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: getComponentAt() return defaultIcon

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Location
    sweden
    Posts
    29
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default getComponentAt() return defaultIcon

    Im trying to get the defaultIcon from getComponentAt()

    mediaPanel.getComponentAt(arg0.getX(), arg0.getY())

    And i get the putput:
    javax.swing.JLabel[,2,0,151x228,alignmentX=0.0,alignmentY=0.0,border=,flags=8388608,maximumSize=,minimumSize=,preferredSize=,defaultIcon=https://dl.dropboxusercontent.com/u/16670644/Projekt/TempPic.png,disabledIcon=,horizontalAlignment=CENTER,horizontalTextPosition=TRAILING,iconTextGap=4,labelFor=,text=,verticalAlignment=CENTER,verticalTextPosition=CENTER]

    Now i'm trying to catch the defaultIcon as a string via:
    String returnString = mediaPanel.getComponentAt(arg0.getX(), arg0.getY());
    String tempString = returnString.substring(indexOf("defaultIcon")+12);
    String defaultIcon = tempString.substring(0,indexOf(","));
    But i cant convert a component to a string, i tried parse it but without luck.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,589
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: getComponentAt() return defaultIcon

    Have you read the API doc?
    What does the getComponentAt() method return?
    Is there a method that returns the default Icon?
    How can the two be connected?

    What you have posted looks like it is trying to parse the String returned by the toString() method.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Location
    sweden
    Posts
    29
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: getComponentAt() return defaultIcon

    Icon returnString = ((JLabel) mediaPanel.getComponentAt(arg0.getX(), arg0.getY())).getIcon();
    System.out.println(returnString);

    I did this and it works.

Similar Threads

  1. can i return two values from a return method?
    By tonu in forum Object Oriented Programming
    Replies: 4
    Last Post: January 1st, 2014, 10:02 AM
  2. Replies: 1
    Last Post: July 29th, 2013, 06:22 AM
  3. return help
    By Kalle in forum What's Wrong With My Code?
    Replies: 7
    Last Post: February 21st, 2012, 04:33 PM
  4. Return Object does not return the expected output
    By Nour Damer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 13th, 2011, 07:24 AM
  5. how to return value ..
    By gr8mind in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 11th, 2011, 04:27 AM