This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Editing the jtable after item change using Jcombobox is not working  RSS feed

 
salman fazal
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I'm making a project about school management system , i have a jframe to set marks and inside the jframe i have a jtable which is connected to sql database , in the jframe I have a JCombobox with 6 different subjects and in my database i have created 6 tables for the subjects and if any of the subjects are clicked then the jTable will connect to database and change the table to that subject , after it is changed if you double click on any row and insert a value then it will automatically update the table in the database , but my problem is that if I select the first option from the jcombox which is English and edit the values then it works fine , but if I select any other option e.g Math or Science , then I try to edit the table then it edits the English table , I commented the English option in the code to see what happens and I saw that it edits only the first option and if you try to change the subjects and edit than it edits the first subject in the combobox , so how can I solve this ? please help

CODE:
 
Campbell Ritchie
Marshal
Posts: 56193
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Why have you only got one top‑level class? That is called the God class anti‑pattern (it has several other names) and is regarded as really poor design. You want different classes which do different things. You also want the application working at the command line before you even think of putting a GUI atop it.
There is something wrong with your having a combobox and using the equals method. That would make it impossible to introduce a new subject e.g. Religious Studies, PE. If you have a list of subject, either you do the same thing for each, i.e. record marks, in which case you need one Listener class, which uses the name of the subject, OR you are going to do different things with each in which case you want different listener classes.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!