Bilder in einem SWT Table

elsausb

Mitglied
Hallo,

hat jemand eine Ahnung, ob und wie ich Bilder (gib, jpg ..) in einem Table bekomme? Bin für jede Anregung dankbar.

Gruß
Chris
 
Danke Tom,

ich hab das jetzt noch auf einen viel einfacheren Weg realisiert!

Code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
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 PictureMain {

public static void main (String [] args) {
  Display display = new Display ();
  Shell shell = new Shell (display);
  //Create Table
  Table table = new Table (shell, SWT.BORDER);
  table.setLinesVisible (true);
  table.setHeaderVisible (true);
  //Create the Image
  Image image = new Image(display, "C:/test.jpg");
  //Manipulate the Image (draw Text)!
  GC gc = new GC(image); 
  gc.drawText("I've been drawn on",0,0,true);
  gc.dispose(); 
    
  String[] titles = {"Description", "Resource", "In Folder", "Location"};
  for (int i=0; i<titles.length; i++) {
    TableColumn column = new TableColumn (table, SWT.NULL);
    column.setText (titles [i]);
  } 
  int count = 10;
  for (int i=0; i<count; i++) {
    TableItem item = new TableItem (table, SWT.NULL);
    //Use the internal setImage function of the table widget
    item.setImage(0, image);
    item.setText (1, "y");
    item.setText (2, "!");
    item.setText (3, "this stuff behaves the way I expect");   
  }
  for (int i=0; i<titles.length; i++) {
    table.getColumn (i).pack ();
  } 
  table.setSize (table.computeSize (SWT.DEFAULT, 400));
  shell.pack ();
  shell.open ();
  while (!shell.isDisposed ()) {
    if (!display.readAndDispatch ()) display.sleep ();
  }
  display.dispose ();
}
}
 

Neue Beiträge

Zurück