• 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

Add, Edit and Delete JTable with Database

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I currently have all the code working to fill my database and to display it, although I would like to have it displaying in a JPanel but I cannot figure it out so a JFrame will do. The question I am here to ask though is anybody able to help me with a Add,Edit and Delete button for the JTable so I can add rows to the table and database, edit existing rows and delete rows also. Can Anybody help me with the code for this ? Thanks.

Here is the code for my current class.

 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Since you are using a database, I would suggest using a JDialog displaying the necessary fields representing the customer for insert and update.

Your main window can look like using BorderLayout as example:
JTable in BorderLayout.CENTER
Add, update, delete buttons in BorderLayout.SOUTH

When the button is clicked, JDialog (for insert/update) or confirm box (for delete) pops up, does its stuff and refreshes the data in the JTable's model.


The above is just one way to display the components.

 
Jordan Kinsella
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, thanks for the reply. I'm not the best at programming and I don't really understand a lot what you mean. I am able to post any code needed. I created the buttons on the JTable all I need to do is enter the code for the buttons to function. Thanks.
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The key to setting up the GUI is the layout. If you draw it out on paper will help.


 
It is difficult to free fools from the chains they revere - Voltaire. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic