I have written the following code and I cannot for the life of me figure out what is going wrong. When I run the program, nothing happens but when I exit the GUI, the data is writtencorrectly via System.out.println to my netbeans console. Please tell me what Im doing wrong
Ya, I realized I didnt call all the methods I should. Anyways here is a new piece of code, and Ive called all the right methods in the constructor. When I run the program, yes the JFrame is displayed but the data that is read from the database does not get get listed in the jtable. The data is properly put into the set of row objects, as I used a system.out.println statement to find out. So Im thinking that for some reason the table.addRow(row) is not displaying the data to the jtable. Or is there something else Im missing
okay i think Ive got that figured out. The rows that were aready present in the jTable were the ones showing up, and while the populated rows were being added, they were outside the lower boundary of the JTable, and so I couldnt see them. So basically I deleted the empty rows that were in the JTable component. But I cant get the insert, update or delete buttons to make changes to the Table, at least i dont see any changes
Your question is about a JTable, so instead of writing an entire application you first need to learn how to use a table.
So you start by creating a JTable with hard coded data in one or two columns and display this on a frame.
Then you create an "Add Row" button to add a new row of data to the table. Again, this data will be hard coded.
Then you create a "Remove Row button.
Then if you have problems you can post your simple code. This simple code is called a SSCCE and should be created when you are learning a new concept.
Finally once you get you basic functions working in the SSCCE, then you can make your code dynamic with SQL. Then all that changes is the code in your "Add Row" button and your "Remove Row" button so if the code stops working you know what you modified and know where the problem is.
Ya, it is a lot of code, basically I pasteed everything that was generated by Netbeans and stuff, but basically the thing is that when I have an sql table, and I modify the table, I want to find a way of displaying the updated table each time in the jtable. Should I delete all rows of the jtable by setting setRowCount to 0, and then repopulating or is there a better way
basically the thing is that when I have an sql table, and I modify the table, I want to find a way of displaying the updated table each time in the jtable. Should I delete all rows of the jtable by setting setRowCount to 0, and then repopulating or is there a better way
That is one way.
Another way is to update the database and the JTable at the same time.
There is no automatic way to have the JTable updated when the database is updated.
[Okaiy, I have just listed the methods that are supposed to make the jtable show the correct info, but the jtable isnt showing the right info. When I modif the sql table through code, the sql table is changed, but then to display the latest table, I need to read from the table and add rows to the jatable. But for some reason, its not working that way, Ive got a for loop in the first method (the insert method) that removes all the rows and then I call the display method to read and display the table, but its not working. And I dont know why
How is the userList populated, as that is what the TableDisp (which should be tableDisp, or even better displayTable) method uses to populate the JTable.
There's nowhere, after you edit or change the data in the database, that you reload the userList.
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss