Link to home
Start Free TrialLog in
Avatar of eugene007
eugene007

asked on

TableModel

Currently I am working on a GUI dealing with JTable.
I am having a problem with one of my JTable.

In my HospitalGUI.java the following code:

JPanel p3 = new JPanel(new GridLayout(2,1));
tableProcedure = new JTable();

where I am suppose to set the tablemodel.

I have also created my own table model with the file name procedureDefaultModel.java.

The problem I am facing is to create the tablemodel for procedure.

HealthService is the controller class. Health service is link to an abstract class MedicalFacility. MedicalFacility has two sub classes Hospital and HealthClinic. The Hospital is link to the procedure.

As for my other table models it works fine, but for procedureDefaultModel im having problems.

How do I solve this problem?

You can download the code from www.mutaiyas.com/db/GUI.zip

Your help is kindly appreciated.

Regards

Eugene
Avatar of eugene007
eugene007

ASKER

I have tested it this way:

JPanel p3 = new JPanel(new GridLayout(2,1));
MedicalFacility m = new Hospital("GH",0.5);
prdm = new procedureDefaultModel(m);  
tableProcedure = new JTable(prdm);

in my HospitalGUI.java

and I can view all the columns in my GUI.

However this is static. Its a problem.
I found the solution:

In my HospitalGUI.java I did this:

JPanel p3 = new JPanel(new GridLayout(2,1));        
prdm = new procedureDefaultModel(null);  
tableProcedure = new JTable(prdm);

and in my procedureDefaultModel.java

public int getRowCount()
{      
     if(mf==null)
     return 0;
     return ((Hospital)mf).getProcedures().size();
}
Avatar of CEHJ
Post a 0-pointer to CS and they'll give you your points back:

https://www.experts-exchange.com/Community_Support/
ASKER CERTIFIED SOLUTION
Avatar of GhostMod
GhostMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial