• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTable not getting updated

 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Ranchers

I am preparing a small solution. Below is how the functionality works.

1. Login Screen
2. Successful Login will take to a MDI Form
3. Click the menu, a JInternalFrame will open in the JDestopPane.
4. JInternalFrame has a JTable.
5. JInternalFrame has a JButton available for adding new data.
6. When JButton is clicked, a new JInternalFrame is popped up with some JTextField and JButton to save the data.
7. After saving the data (after insert query), a JDialog is opened to upload Logo (update query for BLOB), There are two buttons in the JDialog, one is for uploading the image, another one is uploading it later.
8. The logo is displayed in the JDialog and if the JButton, for upload is pressed, update the database and reload the JTable in the JInternalFrame is called.

My challenge is in point 8. The function is called properly, but the table is not getting refreshed.

Below provided my code, can you please help to understand where i went wrong.

JButton in JDialog for uploading the Logo


Code in the JInternalFrame to populate JTable

>
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aravind Prasad wrote: . . . Below is how the functionality works.

1. Login Screen
2. Successful Login will take to a MDI Form
3. Click the menu, a JInternalFrame will open in the JDestopPane.
4. JInternalFrame has a JTable.
5. JInternalFrame has a JButton available for adding new data.
6. When JButton is clicked, a new JInternalFrame is popped up with some JTextField and JButton to save the data.
7. After saving the data (after insert query), a JDialog is opened to upload Logo (update query for BLOB), There are two buttons in the JDialog, one is for uploading the image, another one is uploading it later.
8. The logo is displayed in the JDialog and if the JButton, for upload is pressed, update the database and reload the JTable in the JInternalFrame is called. . . .

Ignore 95% of that. Focus on how to pass things to the database. That is all the functionality you want. And the way to get that is to remove all the GUI code and run your commands from the command line. No buttons no internal frames only command line.
Go through the Java Tutorials about databases. Run your code until you can reliably pass an UPDATE command and have the database correctly updated. Then you can add a GUI.
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But Boss

The data is saving properly in the database. The issue is with JTable. I have an updateTable Function, even if i am calling the function, it is not refreshing the data. That is my issue. Infact i have tried also repaint(), but still failing.

I have described the functioanlity such that, you might be able to assume the path/parent frame where the JDialog is opening.

Thanks/Regards

Aravind
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
|I think you will find the Java Tutorials link I gave pearler has a section in about JTables.
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are doing some incorrect things in the code:
a) Class names should begin with uppercase - 'companyConfigs' is poor naming convention
b) You create an ArrayList with 'new ArrayList()' and immediately in the next line assign the variable to something else. Why? Just declare the variable and assign it. Why create the new list unnecessarily?
c) The if clause is empty - how do you know code is not entering there?
d) Most importantly, you create an 'companyConfigs' instance in the button click with which you invoke the 'updateTable' method - and then, inside the 'updateTable' method, you again create another instance of 'companyConfigs' - why? no wonder you don't see the data. I am sure the code is getting into the 'if' clause.

My suggestion would be to take a step back, understand OOPS concepts, classes etc. and revisit this.
 
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic