Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Bind data to swing tables  RSS feed

 
Ranch Hand
Posts: 174
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table which is binded data and going to display them using swing UI.
this is the way I bound them.



here CcmConceptData  is my data type and  i get data through ccmAttributeModel( an instance of CcmAttributeModel class). I call initDataBindings() method inside the same class constructor like this way,



initGui() for display the swing components with table.I can't imagine why even these column names didn't bind to the table !!! When I debug the progrm I see that ccmAttributeModel.loadData() gets the data too.But data is not shown in the table.(not even the column names) Also it doesn't give any error messages.It just show empty frame.
Please some one help me to get out from these issue !!!
 
Rancher
Posts: 506
15
Java Notepad
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When I debug the progrm I see that ccmAttributeModel.loadData() gets the data too.



Where are the debug statements placed?



In the above code initDataBindings() is using ccmAttributeModel.loadData() -and- then ccmAttributeModel() assigned in the constructor CcmAttributeDialog() as this.ccmAttributeModel = ccmAttributeModel; -after- initDataBindings(). What is happening here?

What is initGui() doing?
 
chamini prashakthi
Ranch Hand
Posts: 174
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Prasad Saya wrote:In the above code initDataBindings() is using ccmAttributeModel.loadData() -and- then ccmAttributeModel() assigned in the constructor CcmAttributeDialog() as this.ccmAttributeModel = ccmAttributeModel; -after- initDataBindings(). What is happening here?

What is initGui() doing?



Here I passed data to my dialog through CcmAttributeModel .I create instance of CcmAttributeModel as ccmAttributeModel at the starting poin and then changed my constructor like this .




initGui() does is the positioning some of my swing componets and the above table too.
But still it doesn't show my data ???
 
chamini prashakthi
Ranch Hand
Posts: 174
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah now the columns are shown in the table.But nonthe data !!!

 
Prasad Saya
Rancher
Posts: 506
15
Java Notepad
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chamini prashakthi wrote:Ah now the columns are shown in the table.But not the data !!!



How did it happen? What is this returning: ccmAttributeModel.loadData()

Also in: final JTableBinding<CcmConceptData, List<CcmConceptData>, JTable> tb = SwingBindings
        .createJTableBinding(UpdateStrategy.READ_WRITE, ccmAttributeModel.loadData(), getCcmAttributeTable());


Try changing the UpdateStrategy.READ_WRITE to UpdateStrategy.READ. It looks like the READ_WRITE is not supported as per the API javadocs (though it might be translated to READ).
 
chamini prashakthi
Ranch Hand
Posts: 174
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Prasad Saya wrote:

How did it happen? What is this returning: ccmAttributeModel.loadData()

Also in: final JTableBinding<CcmConceptData, List<CcmConceptData>, JTable> tb = SwingBindings
        .createJTableBinding(UpdateStrategy.READ_WRITE, ccmAttributeModel.loadData(), getCcmAttributeTable());


Try changing the UpdateStrategy.READ_WRITE to UpdateStrategy.READ. It looks like the READ_WRITE is not supported as per the API javadocs (though it might be translated to READ).



whether I change UpdateStrategy to UpdateStrategy.READ It shows the same as previous.The table with only the column names.No data.

And ccmAttributeModel.loadData() is return the all the data as a list from my data provider class. it is sure that ccmAttributeModel.loadData() returns the all data as a list here.But the problem I can't see those data in the table 
 
Prasad Saya
Rancher
Posts: 506
15
Java Notepad
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are the path values correct in the BeanProperty.create() methods? Are the column names showing for the empty table?
 
chamini prashakthi
Ranch Hand
Posts: 174
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Prasad Saya wrote:Are the path values correct in the BeanProperty.create() methods? Are the column names showing for the empty table?


yeh I found the issue.

this is the way that i defined my table shoud be shown:



but when I put  gbcTableCcmAttribute.ipady= 20; to table it shows some data.My problem was the size of my table. But how to resize it now ?
 
Prasad Saya
Rancher
Posts: 506
15
Java Notepad
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try setting the JScrollPane's setPreferredSize(new Dimension(xxx, yyy))
 
chamini prashakthi
Ranch Hand
Posts: 174
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Prasad Saya wrote:Try setting the JScrollPane's setPreferredSize(new Dimension(xxx, yyy))



Yes It was worked. thankz Prasad Saya,
I have another question from you.Can we define the tablescrollpane.setPreferredSize(x,y) here the size of y on to the table data length
 
Prasad Saya
Rancher
Posts: 506
15
Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can we define the tablescrollpane.setPreferredSize(x,y) here the size of y on to the table data length



The x and y are width and height of the scrollpane (with table in it). What do you mean by "table data length"?
 
chamini prashakthi
Ranch Hand
Posts: 174
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Prasad Saya wrote:

Can we define the tablescrollpane.setPreferredSize(x,y) here the size of y on to the table data length



The x and y are width and height of the scrollpane (with table in it). What do you mean by "table data length"?



Hi, I meaned that Shrink JScroll Pane to same Height as JTable. How ever I found the solution.Big thanks for you !!!
 
Prasad Saya
Rancher
Posts: 506
15
Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!