Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Managing events within an applet

Posted on 1998-09-01
2
Medium Priority
?
172 Views
Last Modified: 2010-03-30
What is the best way to handle events and so on within an applet?
I want to program an applet which holds some components like a JTable, a JComboBox, JPanels, JMenues and so on.
Besides database access should be implemented.
So, what would be the best place to implement the database access?
Presently I implemented an abstract class DBAccess and two subclasses DBAccessDQL for quering the database and DBAccessDML to manipulate data within the database.
But would it be good to implement the database access withing the table's model since this is the class which needs the data from the database?
Of course, the JComboBox needs data from the database, too. So, should I implement database access ability to an extended class of JComboBox too?

The table should handle everything like adding a portfolio tho the table or adding stocks to some portfolios and so on. This must be done within the applet of course, but in the database too! When a portfolio will be added the JComboBox must be aware of this.
How can I handle sth. like this and whta would be the best way?

I thought of sth. like this:
I have a JTable and a DefaultTableModel. To manipulate data I want to program a dialog specific to the table. These three classes could be packaged together to a JavaBean...but I don't know if this would be clever!?
But, of course, other components must be notified about changes within the table.

I don't want to let the main class (applet) a lot of work. I think it would be better to let the component's do the work.
0
Comment
Question by:dirku
2 Comments
 
LVL 8

Accepted Solution

by:
diakov earned 200 total points
ID: 1223123
For the database, I think might want to use the following architecture:
- DBConnectionManager which is responsible for opening, tuning, commiting, closing, the connection to the databases. Also when a database exception occurs it is not necessary your application to stop working, so the ConnectionManager class should do the cleanup and reopen the connections if necessary.
Then you can implement different class definitions for managing the information model of your database. You might need
- DBCreateModel(optional) which is responsible for creating the appropriate tables;
- DBQuery - your suggestion
- DBManipulate - your suggestion

As for the GUI elements you can define DBContentManager which has both knowledge about the database information model and the visual components and it can be responsible for filling the appropriate values and notifying for changes. For example, you can have a static method:
fillComponent(Component c) and in it there is a sequence of if's where you determine which component was the caller and then call the fillComboBox1() method. You can also directly call the methods :-) So you will have all the content filling methods grouped in a class, all the GUI components are clean from knowledge about the database, and the database classes themselves are not full of references to GUI elements.

If you have comments, please post them.

Cheers,
  Nikolay
0
 

Author Comment

by:dirku
ID: 1223124
Hadn't enough time to do what you suggested. I will grade you hoping I can contact you again when I have some more questions.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question