Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ListSelectionListener getting cell value and assigning it to a variable

 
Liam McTavish
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic