Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

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
0
eugene007
Asked:
eugene007
  • 2
1 Solution
 
eugene007Author Commented:
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.
0
 
eugene007Author Commented:
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();
}
0
 
CEHJCommented:
Post a 0-pointer to CS and they'll give you your points back:

http://www.experts-exchange.com/Community_Support/
0
 
GhostModCommented:
PAQd, 60 points refunded.

GhostMod
Community Support Moderator
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now