This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes ListSelectionListener getting cell value and assigning it to a variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ListSelectionListener getting cell value and assigning it to a variable" Watch "ListSelectionListener getting cell value and assigning it to a variable" New topic
Author

ListSelectionListener getting cell value and assigning it to a variable

Liam McTavish
Greenhorn

Joined: Aug 23, 2012
Posts: 2
i have set up a selectionListener on a JTable to select an id of a particular row. ID is a column in the row (col 0). i checked this within the ListCustPanel class that follows by having it printout the selectedID, it worked. but ive added the method getSelectedID() to get the selectedID for other classes that use the Panel, and it seems that the variable never gets assigned. whats the problem here?



so what im trying to say is i have another JFrame class as such, and im getting a null pointer exception from where i use the getSelectedID() method:
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1076
    
  10

Liam McTavish wrote:

this means, no row has been selected by the user yet. This code is present in the constructor of the frame. How would the user select a row before the JFrame, JPanel are constructed and shown to the user?


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ListSelectionListener getting cell value and assigning it to a variable
 
Similar Threads
JTable switching
JTable will not clear
Get data filter in JTable
JTable question
JTable not reflecting cell edit