• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get data from a JTextField over to a JTable?

 
Jeffery Colins
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to get the data entered in a JTextField into a JTable but not clear on how. The LeftPanel is where the button is located and the RightPanel is where the JTable is. I want the actionPerformed to update the row of the JTable but I can't figure out how. There is another class that controls the GUI but did not think it was necessary to include. Also, I am aware that I am getting an error at the addRow line, can't seem to alleviate it. Any help is appreciated and sorry if I left some info out, I am a greenhorn here...

 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeffery Colins wrote:There is another class that controls the GUI but did not think it was necessary to include.


But it's exactly the controller part of your application which should be controlling communication between components! A straightforward way to deal with the requirement is to have the controller listen to that JButton, and when the JButton's action listener is triggered, the controller would get the data from the JTextField and update the JTable with it.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeffery Colins wrote: Also, I am aware that I am getting an error at the addRow line, can't seem to alleviate it...

Is addRow() your custom method? It is not part of the standard JTable API (hint)
 
Jeffery Colins
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting lost between controller, views and models and how they communicate with each other. Any tips on how to get a clear picture on how they communicate? Like a super simple example out there? Even if it is from a book.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!