Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Change TreeViewer column header height
Change TreeViewer column header height [message #663765] Wed, 06 April 2011 08:48 Go to next message
Eclipse UserFriend
Hi,

I have a command which opens a FontDialog to choose the font of my TreeViewer. The TreeViewer cells expanding when a bigger font size is chosen. Unfortunately not the column headers. The size remains and the text is cut. There is a method Tree.getHeaderHeight() : int but no setter for this. Can I set the header column height?

Regards,
Oliver
Re: Change TreeViewer column header height [message #664110 is a reply to message #663765] Thu, 07 April 2011 09:56 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

There is no setter method to set the height of the header. But, the header's height is computed based on the text/image set to it. So, when you change the font size of the table, the header's height also changes. It works on my Windows machine. On which platform are you seeing this?

I modified Snippet38 to try this out. Does it work for you?

public class Snippet38 {

public static void main (String [] args) {
final Display display = new Display ();
final Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
final Table table = new Table (shell, SWT.H_SCROLL|SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION|SWT.CHECK);
table.setLinesVisible (true);
table.setHeaderVisible (true);
final String[] titles = {"titleioioio", "C", "!", "Description", "Resource", "In Folder", "Location"};
for (int i=0; i<titles.length; i++) {
TableColumn column = new TableColumn (table, SWT.NONE);
column.setText (titles [i]);
}
int count = 10;
for (int i=0; i<count; i++) {
TableItem item = new TableItem (table, SWT.NONE);
item.setText (0, "x");
item.setText (1, "y");
item.setText (2, "!");
item.setText (3, "this stuff behaves the way I expect");
item.setText (4, "almost everywhere");
item.setText (5, "some.folder");
item.setText (6, "line " + i + " in nowhere");
}
table.pack();
for (int i=0; i<titles.length; i++) {
table.getColumn (i).pack ();
}
Button button = new Button(shell, SWT.PUSH);
button.setText("change font");
button.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
FontDialog d = new FontDialog(shell);
FontData data = d.open();
table.setFont(new Font(display, data));
for (int i = 0; i < titles.length; i++) {
table.getColumn(i).pack();
}

}

public void widgetDefaultSelected(SelectionEvent e) {

}
});

shell.pack ();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}

Re: Change TreeViewer column header height [message #1792442 is a reply to message #664110] Wed, 18 July 2018 03:09 Go to previous messageGo to next message
Eclipse UserFriend
It's not work on Mac os.
Re: Change TreeViewer column header height [message #1792446 is a reply to message #664110] Wed, 18 July 2018 03:12 Go to previous message
Eclipse UserFriend
It's not work on Mac os.
Previous Topic:Is there a statement of support for Microsoft Edge in SWT Browser.
Next Topic:How to change caret color?
Goto Forum:
  


Current Time: Sun Jul 27 02:22:58 EDT 2025

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

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

Back to the top