jinnyishere's Profile User Rating: -----

Reputation: 46 Craftsman
Group:
Authors
Active Posts:
127 (0.07 per day)
Joined:
06-July 09
Profile Views:
8,704
Last Active:
User is offline Mar 01 2014 11:14 AM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Intel
Favorite Gaming Platform:
Playstation
Your Car:
Who Cares
Dream Kudos:
275

Latest Visitors

Icon   jinnyishere has not set their status

Posts I've Made

  1. In Topic: Swing Tutorial Part IV

    Posted 22 Mar 2013

    View PostJohn-acme, on 19 October 2012 - 11:04 AM, said:

    String select = (String)list.getSelectedValue();
    


    why code above can work..? as I know if you want to access another class variable's value, need a reference or accessor method..? and list is in SelectList class..

    Would you mind explain to me? thanks.


    Hi, I know it's been a year but better late than never.

    If you look at the following:

    //Here we create an array of Strings

    String[] months = {"Jan.", "Feb.", "March", "April", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec"};

    //Now, adding the Strings to the list
    list = new JList(months);


    We have just created a JList, name " list ".

    Now in order to get the selected value from the list, we use the " getSelectedValue() " method from JList. That method returns an object, so we have to cast it into a String.

    "Note: I didn't create the method getSelectedValue(), it's already defined in the JList class"

    Hope that helps..

    ~Jay

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Interests:
Math, Java, JavaFX, C++, Hacking, games, badminton, tennis, drawing, swimming, movies, and robotics...
Programming Languages:
Objective-C, Java, C#, PHP, JavaScript, HTML/CSS, C++, JavaFX, Assembly, MicroController

Contact Information

E-mail:
Private
Website URL:
Website URL  http://www.appsharenow.com

Comments

Page 1 of 1
  1. Photo

    jinnyishere Icon

    28 May 2010 - 17:59
    testing...
Page 1 of 1