Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] (no subject)


Hi all,

  I found out a bit strange behaviour if I add image on the 2nd column, 1st column with checkbox 
will contain a lot of space as it show in the pic.... Am I miss out some things ?

Here is the bug report :

Thanks guys


Inline image 1

This is the sample code :

package swt_table;


import java.util.ArrayList;

import org.eclipse.swt.SWT;

import org.eclipse.swt.graphics.Image;

import org.eclipse.swt.widgets.Display;

import org.eclipse.swt.widgets.Event;

import org.eclipse.swt.widgets.Listener;

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 swt_with_image extends Shell {

   private Table table;

   private TableColumn tblclmnNewColumn;

   private TableColumn tblclmnNewColumn_1;

   private TableColumn tblclmnNewColumn_2;


   /**

    * Launch the application.

    * @param args

    */

   public static void main(String args[]) {

      try {

         Display display = Display.getDefault();

         swt_with_image shell = new swt_with_image(display);

         shell.open();

         shell.layout();

         while (!shell.isDisposed()) {

            if (!display.readAndDispatch()) {

               display.sleep();

            }

         }

      } catch (Exception e) {

         e.printStackTrace();

      }

   }


   /**

    * Create the shell.

    * @param display

    */

   public swt_with_image(Display display) {

      super(display, SWT.SHELL_TRIM);

      createContents();


      

      table.addListener (SWT.SetData, new Listener () {


         TableItem itblitm_row ;

         

         @Override

         public void handleEvent(Event e) {


            itblitm_row = ( TableItem )e.item ;

            

            switch( e.index ){

               

            case 0 :

               itblitm_row.setImage( 1, new Image( Display.getCurrent() ,"0.jpg" ));

               break ;

               

            case 1 :

               itblitm_row.setImage( 1, new Image( Display.getCurrent() ,"1.jpg" ));

               break ;

            }

            

         }

         

      });

      

      table.setItemCount(2);

   }


   /**

    * Create contents of the shell.

    */

   protected void createContents() {

      setText("SWT Application");

      setSize(450, 300);


      

      table = new Table(this, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.MULTI );

      table.setBounds(10, 10, 414, 241);

      table.setHeaderVisible(true);

      table.setLinesVisible(true);

      

      tblclmnNewColumn = new TableColumn(table, SWT.NONE);

      tblclmnNewColumn.setWidth(100);

      tblclmnNewColumn.setText("New Column");

      

      tblclmnNewColumn_1 = new TableColumn(table, SWT.NONE);

      tblclmnNewColumn_1.setWidth(100);

      tblclmnNewColumn_1.setText("New Column");

      

      tblclmnNewColumn_2 = new TableColumn(table, SWT.NONE);

      tblclmnNewColumn_2.setWidth(100);

      tblclmnNewColumn_2.setText("New Column");

   }


   @Override

   protected void checkSubclass() {

      // Disable the check that prevents subclassing of SWT components

   }

}


Back to the top