• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to initiate a TableModelEvent.INSERT and TableModelEvent.DELETE in a TableModelListener

 
martin naughton
Ranch Hand
Posts: 30
Debian MyEclipse IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Guys,

I am trying to do a interactive JTable were the user can create update and delete the JTable rows using the keyboard. Instead of clicking on a row and then clicking on another button to do the action.
I have been looking around the internet to see what action i can do on my mouse or keyboard that will trigger the TableModelEvent to be a INSERT or DELETE. anything i do in the JTable come in the action listener as UPDATE. If i select the whole row and press delete on my keyboard the listener sees it as update.


I trying to distinguish between create update and delete for my data base entires. For INSERT and DELETE do i have to make the objects and trigger the listener or is there any physical action i can do to trigger the listener with these commands?

thanks for your time
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Martin!

I am trying to do a interactive JTable were the user can create update and delete the JTable rows using the keyboard.


Champion, I can tell you that you are having a very nobel attitude, trying to create a very interactive application and everything, but... we are not required to create or delete records. What you have to do is build an application that only updates the position of the record that is reserved to the client id. So, the user only has to somehow provide an 8-digit number and update the chosen record properly. There's no need to waste time on what we are not required to do! And we can also lose points for that. There is also no need to create any MouseListener or KeyboardListener. Stick to simplicity and you'll do well!
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Martin,

Some remarks:
  • use a code-tag if you post a code snippet, will improve the readibility of your post (and snippet).
  • I agree completely with Roberto's point of view: keep it as simple and possible + stick to the (functional) requirements.
  • Of course you can add stuff that's not required, just for the learning experience. But if you want to make an interactive table, you also would expect to have an editable JTable, so everything can be done without pressing other buttons. But creating such a fully-fledged editable JTable is not out-of-the-box: I remember a previous project with a GUI framework (based on Swing), the code for the editable JTable was enormous and during testing a whole lot of bugs were filed against this framework component.
  • I think this tutorial will be a good starting point. And if you have specific Swing questions (which are about custom functionalities and thus not related to SCJD) I'll think you could better ask your question in another forum, because we are certainly not Swing-gurus, and there you might get a more appropriate (and helpful) answer.

  • Kind regards,
    Roel
     
    martin naughton
    Ranch Hand
    Posts: 30
    Debian MyEclipse IDE VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Roberto Perillo wrote:
    we are not required to create or delete records.

    the user only has to somehow provide an 8-digit number and update the chosen record properly.


    Thanks guys for getting back to me. I thought i had to do create and delete records in the URLybird because the methods in the DataMain interface had create update delete. I have these methods implemented with JUnit testing and working fine.

    Are the create and delete only for the future proof of the product as they said in the URLYbird that this product is only the start before they convert over to the web system? So create and delete will be used in URLybird 2.0 as you might say?

    My jtable work great with update already so i thought i would move on to delete and create.


    thanks for your help not suer what i would do with out your help.

     
    Roel De Nijs
    Sheriff
    Posts: 10662
    144
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Martin,

    I thought i had to do create and delete records in the URLybird because the methods in the DataMain interface had create update delete. I have these methods implemented with JUnit testing and working fine.

    I did exactly the same: implement all methods from DataMain, and used JUnit to test all these methods in all different situations (with wrong parameters, throwing exceptions,...)

    So create and delete will be used in URLybird 2.0 as you might say?

    That could be possible and you have to think about the non-functional requirements (keeping it simple and understandable for a junior developer) when adding extra functionalities to the application. Also I think you should take into account that your application gives the user a consistent user experience (look and feel). So a user can quickly learn how to work with your application. So in my application a junior developer can easily add the "new room" functionality for example. Because it can be done in the same way as the existing "booking a room" functionality (giving the user the same look and feel).
    I use a toolbar with buttons for each possible function (limited to only "booking a room") and a seperate dialog with disabled/enabled fields depending on which action was invoked (which button was clicked)

    Kind regards,
    Roel
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic