Wie kann ich die Zeilenhoehe anpassen?

gloomer

Grünschnabel
Hi @ all,

ich habe folgendes Problem: Ich bin gerade dabei eine Tabelle in SWT zu Programmieren. Aendere ich in einer Zelle die Fontsize, so wird der Text auch in der Spalte darueber angezeigt. Gibt es eine Moeglichkeit, wie ich die Zeilenhoehe dieser Zeile anpassen kann?

Hier der bisherige Quelltext:


Code:
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.graphics.Color;
  import org.eclipse.swt.graphics.Font;
  import org.eclipse.swt.layout.RowLayout;
  import org.eclipse.swt.widgets.Button;
  import org.eclipse.swt.widgets.Composite;
  import org.eclipse.swt.widgets.Display;
  import org.eclipse.swt.widgets.Shell;
  import org.eclipse.swt.widgets.Table;
  import org.eclipse.swt.widgets.TableColumn;
  import org.eclipse.swt.widgets.TableItem;
  
  
  public class test {
  
     public test() {
  	   Display display = new Display();
  	   Shell shell = new Shell(display);
  			  shell.setLayout(new RowLayout());
  	  
  
  	   Table table = new Table (shell, SWT.MULTI);
  	   table.setLinesVisible (true);
  	   int cols = 5;
  	   // Spalten anlegen
  	   for (int i=0; i<cols; i++) {
  		   TableColumn column = new TableColumn (table, SWT.NULL);
  	   }
  
  	   // Zeilen anlegen
  	   int count = 5;
  	   for (int i=0; i<count; i++) {
  		   TableItem item = new TableItem (table, SWT.NULL);
  		   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");
  	   }
  	   
  	   TableItem item2 = new TableItem (table, SWT.NULL);
  	   item2.setFont(0, new Font(display, "Verdana", 15, SWT.BOLD));
  	   item2.setText(0, "Hallo Welt");
  	   item2.setText(1, "Hallo Welt");
  	   
  	   
   
  	   
  	   // Spaltenbreiten setzen
  	   for (int i=0; i<cols; i++) {
  		   table.getColumn(i).pack();
  	   }
  	   
  	   
  	   
  	   shell.open();	// Fenster öffnen
  	   
  	   while (!shell.isDisposed())
  	   {
  		   if (!display.readAndDispatch())
  		   {
  			   display.sleep();
  		   }
  	   }
  			  display.dispose();
     }
  
     public static void main(String[] args) {
  	   new test();
     }
  }
 
Zurück