Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » problem with the cell size
problem with the cell size [message #462078] Wed, 05 October 2005 20:16 Go to next message
Eclipse UserFriend
Originally posted by: jaguaralcon.hotmail.com

I has a proble with the following code.
Can you help me.

package phantom.prueba;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
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.Widget;

import phantom.core.GCustom;

/**
* @author qjaime
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class prueba_tabla2 {

public static Display myDisplay;
static final String NAME = "Directorio de Clientes";
Shell shell;
GridLayout layout = new GridLayout();
GridData tData = null;

Widget[] control = new Widget[3];


public prueba_tabla2()
{

myDisplay = new Display();
shell = new Shell(myDisplay,SWT.CLOSE);


Table gDatos = new Table(shell,SWT.NONE);
TableColumn tcTelefono = new TableColumn(gDatos, SWT.NONE);
TableColumn tcNumero = new TableColumn(gDatos, SWT.NONE);
TableColumn tcExtencion = new TableColumn(gDatos, SWT.NONE);
tData = new GridData(GridData.FILL_BOTH);
GCustom gcustom = new GCustom(gDatos);

gDatos.setHeaderVisible(true);
gDatos.setLinesVisible(true);
tcTelefono.setText("Tipo");
tcNumero.setText("Numero");
tcExtencion.setText("Ext");

tData.horizontalIndent = 10;
gDatos.setLayoutData(tData);

tcTelefono.pack();
tcNumero.pack();
tcExtencion.pack();

/* control[0]=combo;
control[1]=boton;
control[2]=check; */

gcustom.setEditor(0,GCustom.COMBO);
gcustom.setEditor(1,GCustom.COMBO);
gcustom.setEditor(2,GCustom.BUTTON);
gcustom.setItem();
gcustom.setItem();
gcustom.setItem();

shell.setLayout(layout);
shell.setText(NAME);
shell.setSize(400,400);
shell.setImage(new Image(myDisplay,"image/so.gif"));

shell.open();
while (!shell.isDisposed())
if (!myDisplay.readAndDispatch())
myDisplay.sleep();
}


public static void main(String[] args) {
new prueba_tabla2();
}
}
Re: problem with the cell size [message #462080 is a reply to message #462078] Wed, 05 October 2005 20:49 Go to previous message
Eclipse UserFriend
Originally posted by: jaguaralcon.hotmail.com

It's code by painting they widgets in table
package phantom.core;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;

public class GCustom {
public static final int COMBO = 1;
public static final int BUTTON = 2;
public static final int CHECK = 3;

/* Widget[] control ;*/
int[] control;
String[] data;
Table gDatos;

//public void setEditor(int columna,Widget control)
public void setEditor(int columna,int control)
{
if ((columna >0 ) && (columna < gDatos.getColumnCount()))
{
this.control[columna] = control;
}
}



public void setItem()
{
TableItem item = new TableItem(gDatos,SWT.NONE);

TableEditor editor;
editor = new TableEditor (gDatos);
editor.minimumHeight = 50;
// editor.setItem();
for (int i = 0; i < control.length; i++) {
switch (control[i]) {
case BUTTON:
editor = new TableEditor (gDatos);
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.minimumHeight = 20;
Button boton = new Button(gDatos,SWT.PUSH);
editor.setEditor (boton, item, i);
break;
case COMBO:
editor = new TableEditor (gDatos);
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.minimumHeight = 20;
Combo combo = new Combo(gDatos, SWT.BORDER |
SWT.READ_ONLY);
combo.setSize(40,40);
editor.setEditor (combo, item, i);
break;
case CHECK:
editor = new TableEditor(gDatos);
// editor.
default:
break;
}
}
}

public GCustom(Table gDatos)
{
this.gDatos = gDatos;
control = new int[gDatos.getColumnCount()];
data = new String[gDatos.getColumnCount()];
//control = new Widget[gDatos.getColumnCount()];
}

static public void Custom()
{

}

}
Previous Topic:TableColumn hiding
Next Topic:label being cut off in wizard
Goto Forum:
  


Current Time: Wed Sep 30 00:21:14 GMT 2020

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

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

Back to the top