Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » challenge: Setting with of last table column (I am not finding a way to set proper width of last column in Jface tableviewer)
challenge: Setting with of last table column [message #1547934] Mon, 05 January 2015 18:46
Krishnakant Mane is currently offline Krishnakant ManeFriend
Messages: 9
Registered: December 2013
Junior Member
Hello all,
here is the problem.
I am using a composit with form layout for a few widgets.
Amongst it is another composit which contains a JFace TableViewer.

Here is the code with all other unnecessary lines removed.
TableColumnLayout tbl = new TableColumnLayout();
//constructor for my screen which extends Composit....
//Now the inner composit is set using a form layout in this parent composit.
layout = new FormData();

layout.top = new FormAttachment(lblOrgDetails,10);
layout.left = new FormAttachment(1);
layout.right = new FormAttachment(99);
layout.bottom = new FormAttachment(92);
Composite tblContainer = new Composite(this,SWT.NONE );
tblContainer.setLayoutData(layout);
tblContainer.setLayout(tbl);
tblnettrialbal = new TableViewer(tblContainer, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION|SWT.LINE_SOLID);

Now I make a few columns and also give the waitage as per the column layout stratergy.

//made 5 columns and also set the lable brovider provider and the content provier.
//also given the arrayList as the input.
//now these TableViewerColumns get their weightage.
tbl.setColumnData(colSrNo.getColumn() , new ColumnWeightData(4, ColumnWeightData.MINIMUM_WIDTH,true ));
tbl.setColumnData(colaccname.getColumn() , new ColumnWeightData(34, ColumnWeightData.MINIMUM_WIDTH,true ));
tbl.setColumnData(colgrpname.getColumn() , new ColumnWeightData(19, ColumnWeightData.MINIMUM_WIDTH,true ));
tbl.setColumnData(coldr.getColumn() , new ColumnWeightData(16, ColumnWeightData.MINIMUM_WIDTH,true ));
tbl.setColumnData(colcr.getColumn() , new ColumnWeightData(17,17*shellwidth / 100 ));

Yet the last column still becomes a bit big.
Secondly for no reason the last column gets a horizontal scrollbar which should not have come, because the data is just a few digits long (8 ) to be precise.
If I increase or decrease the weightage of the last column (or any column for that matter ) still the scrollbar comes on the last column.
I also noted that the total width of the columns in picsells is more than the table width.
This happens because at some point the width of the table shrinks.
I know this because I initially put a message box to see what the width is and then after data populates I see that the width of the table has gone down a few picksells.
Can any one tell me how to correct this issue.
I also packed the table and the composit, it did not work though.
Happy hacking.
Krishnakant.

Previous Topic:can Jface table cell have selection event
Next Topic:Set font of ControlDecoration tooltip
Goto Forum:
  


Current Time: Mon Nov 19 16:37:51 GMT 2018

Powered by FUDForum. Page generated in 0.01743 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top