Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » I meet control paint trouber , pls help me!
I meet control paint trouber , pls help me! [message #445174] Wed, 27 October 2004 12:23 Go to next message
Eclipse UserFriend
Originally posted by: liankun_mail.21cn.com

I meet control paint trouber while i put a table into sashform control .
When i make the shell maximum , the table control will not refresh
correctly. whether or not i use the sashform correctly?

The source code is as follows, and the table control is added by method
"PPP".

/*
* Created on 2004-10-25
*/
package org.jeff.swt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;


/**
* @author JeffLian.
*/
public class T08 {

public static void main(String[] args) {

final Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());

Composite parent1 = new Composite(shell, SWT.NONE);
parent1.setLayout(new FillLayout());

Composite parent = new Composite(parent1, SWT.BORDER);

GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
parent.setLayout(layout);

Composite pane = new Composite(parent, SWT.BORDER);
pane.setLayoutData(new GridData(GridData.FILL_BOTH));
pane.setLayout(new FillLayout());

Composite aa = new Composite(pane, SWT.NONE);
createPartControl(aa);

shell.setBounds(20, 30, 500, 500);
shell.open();
while (!shell.isDisposed()){
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();

}

public static void createPartControl(Composite parent) {
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
parent.setLayout(layout);

Composite control = new Composite(parent, SWT.BORDER);
control.setLayoutData(new GridData(GridData.FILL_BOTH));

GridLayout controlLayout = new GridLayout();
controlLayout.horizontalSpacing = 0;
controlLayout.verticalSpacing = 0;
controlLayout.marginHeight = 0;
controlLayout.marginWidth = 0;

control.setLayout(controlLayout);

Composite contentArea = new Composite(control, SWT.NONE);
GridData clientData = new GridData(GridData.FILL_BOTH);
contentArea.setLayoutData(clientData);

StackLayout contentLayout = new StackLayout();
contentArea.setLayout(contentLayout);

Composite ppp = new Composite(contentArea, SWT.NONE);
PPP(ppp);

contentLayout.topControl = ppp;
if (parent != null) return;
}

public static void PPP(Composite parent) {
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
parent.setLayout(layout);

Composite pane1 = new Composite(parent, SWT.BORDER);
pane1.setLayoutData(new GridData(GridData.FILL_BOTH));

pane1.setLayout(new GridLayout());

Label label = new Label(pane1, SWT.PUSH);
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
label.setText("sdfsdf");

SashForm form = new SashForm(pane1, SWT.VERTICAL);
form.setLayoutData(new GridData(GridData.FILL_BOTH));
form.setLayout(new FillLayout());

Composite child1 = new Composite(form, SWT.NONE);
child1.setLayout(new FillLayout());
//table = new CTable(child1, new CellDisplay(), new Renderer());
new Label(child1, SWT.NONE).setText("Label in pane 1");

Composite child2 = new Composite(form, SWT.NONE);
child2.setLayout(new FillLayout());
new Button(child2, SWT.PUSH).setText("Button in pane2");

Composite child3 = new Composite(form, SWT.NONE);
child3.setLayout(new FillLayout());

Composite ccc = new Composite(child3, SWT.BORDER);
ccc.setLayout(new FillLayout());

Composite ddd = new Composite(ccc, SWT.BORDER);
ddd.setLayout(new FillLayout());

Table table = new Table(ddd, SWT.FULL_SELECTION);

table.setItemCount(10);
table.setHeaderVisible(true);
table.setLinesVisible(true);

TableColumn col1 = new TableColumn(table, SWT.CENTER);
col1.setText(" col1");
col1.setWidth(90);
TableColumn col2 = new TableColumn(table, SWT.CENTER);
col2.setText(" col2");
col2.setWidth(90);

for (int i = 0; i < 10; i++){
TableItem item = new TableItem(table, SWT.NONE);
item.setText(new String[] { "row", "row" + i });
item.setImage(0, null);
}

form.setWeights(new int[] { 30, 40, 30 });

if (form != null) return;

}
}
Re: I meet control paint trouber , pls help me! [message #445222 is a reply to message #445174] Thu, 28 October 2004 14:17 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Delete the line "table.setItemCount(10)". When a table is not virtual, this
adds 10 items to the table. Then you append 10 more items that are scrolled
out of view. It that the problem?

"JeffLian" <liankun_mail@21cn.com> wrote in message
news:clo3nc$odn$1@eclipse.org...
> I meet control paint trouber while i put a table into sashform control .
> When i make the shell maximum , the table control will not refresh
> correctly. whether or not i use the sashform correctly?
>
> The source code is as follows, and the table control is added by method
> "PPP".
>
> /*
> * Created on 2004-10-25
> */
> package org.jeff.swt;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.custom.SashForm;
> import org.eclipse.swt.custom.StackLayout;
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.widgets.*;
>
>
> /**
> * @author JeffLian.
> */
> public class T08 {
>
> public static void main(String[] args) {
>
> final Display display = new Display();
> Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
>
> Composite parent1 = new Composite(shell, SWT.NONE);
> parent1.setLayout(new FillLayout());
>
> Composite parent = new Composite(parent1, SWT.BORDER);
>
> GridLayout layout = new GridLayout();
> layout.marginHeight = 0;
> layout.marginWidth = 0;
> layout.verticalSpacing = 0;
> parent.setLayout(layout);
>
> Composite pane = new Composite(parent, SWT.BORDER);
> pane.setLayoutData(new GridData(GridData.FILL_BOTH));
> pane.setLayout(new FillLayout());
>
> Composite aa = new Composite(pane, SWT.NONE);
> createPartControl(aa);
>
> shell.setBounds(20, 30, 500, 500);
> shell.open();
> while (!shell.isDisposed()){
> if (!display.readAndDispatch()) display.sleep();
> }
> display.dispose();
>
> }
>
> public static void createPartControl(Composite parent) {
> GridLayout layout = new GridLayout();
> layout.marginHeight = 0;
> layout.marginWidth = 0;
> layout.verticalSpacing = 0;
> parent.setLayout(layout);
>
> Composite control = new Composite(parent, SWT.BORDER);
> control.setLayoutData(new GridData(GridData.FILL_BOTH));
>
> GridLayout controlLayout = new GridLayout();
> controlLayout.horizontalSpacing = 0;
> controlLayout.verticalSpacing = 0;
> controlLayout.marginHeight = 0;
> controlLayout.marginWidth = 0;
>
> control.setLayout(controlLayout);
>
> Composite contentArea = new Composite(control, SWT.NONE);
> GridData clientData = new GridData(GridData.FILL_BOTH);
> contentArea.setLayoutData(clientData);
>
> StackLayout contentLayout = new StackLayout();
> contentArea.setLayout(contentLayout);
>
> Composite ppp = new Composite(contentArea, SWT.NONE);
> PPP(ppp);
>
> contentLayout.topControl = ppp;
> if (parent != null) return;
> }
>
> public static void PPP(Composite parent) {
> GridLayout layout = new GridLayout();
> layout.marginHeight = 0;
> layout.marginWidth = 0;
> layout.verticalSpacing = 0;
> parent.setLayout(layout);
>
> Composite pane1 = new Composite(parent, SWT.BORDER);
> pane1.setLayoutData(new GridData(GridData.FILL_BOTH));
>
> pane1.setLayout(new GridLayout());
>
> Label label = new Label(pane1, SWT.PUSH);
> label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
> label.setText("sdfsdf");
>
> SashForm form = new SashForm(pane1, SWT.VERTICAL);
> form.setLayoutData(new GridData(GridData.FILL_BOTH));
> form.setLayout(new FillLayout());
>
> Composite child1 = new Composite(form, SWT.NONE);
> child1.setLayout(new FillLayout());
> //table = new CTable(child1, new CellDisplay(), new Renderer());
> new Label(child1, SWT.NONE).setText("Label in pane 1");
>
> Composite child2 = new Composite(form, SWT.NONE);
> child2.setLayout(new FillLayout());
> new Button(child2, SWT.PUSH).setText("Button in pane2");
>
> Composite child3 = new Composite(form, SWT.NONE);
> child3.setLayout(new FillLayout());
>
> Composite ccc = new Composite(child3, SWT.BORDER);
> ccc.setLayout(new FillLayout());
>
> Composite ddd = new Composite(ccc, SWT.BORDER);
> ddd.setLayout(new FillLayout());
>
> Table table = new Table(ddd, SWT.FULL_SELECTION);
>
> table.setItemCount(10);
> table.setHeaderVisible(true);
> table.setLinesVisible(true);
>
> TableColumn col1 = new TableColumn(table, SWT.CENTER);
> col1.setText(" col1");
> col1.setWidth(90);
> TableColumn col2 = new TableColumn(table, SWT.CENTER);
> col2.setText(" col2");
> col2.setWidth(90);
>
> for (int i = 0; i < 10; i++){
> TableItem item = new TableItem(table, SWT.NONE);
> item.setText(new String[] { "row", "row" + i });
> item.setImage(0, null);
> }
>
> form.setWeights(new int[] { 30, 40, 30 });
>
> if (form != null) return;
>
> }
> }
>
>
Re: I meet control paint trouber , pls help me! [message #445229 is a reply to message #445222] Fri, 29 October 2004 05:53 Go to previous message
Eclipse UserFriend
Originally posted by: liankun_mail.21cn.com

Thanks, But i test the code according as your said , it has the same
problems.
And i write some notation in my source code line 118 .You can test it
according to my notation. Ths!

The new source code is as follows:

/*
* Created on 2004-10-29
*/
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

/**
* @author JeffLian.
*/
public class T09 {
public static void main(String[] args) {

//create shell
final Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());

Composite parent1 = new Composite(shell, SWT.NONE);
parent1.setLayout(new FillLayout());

Composite parent = new Composite(parent1, SWT.BORDER);

GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
parent.setLayout(layout);

Composite pane = new Composite(parent, SWT.BORDER);
pane.setLayoutData(new GridData(GridData.FILL_BOTH));
pane.setLayout(new FillLayout());

Composite aa = new Composite(pane, SWT.NONE);
createPartControl(aa);

shell.setBounds(20, 30, 500, 500);
shell.open();
while (!shell.isDisposed()){
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();

}

public static void createPartControl(Composite parent) {
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
parent.setLayout(layout);

Composite control = new Composite(parent, SWT.BORDER);
control.setLayoutData(new GridData(GridData.FILL_BOTH));

GridLayout controlLayout = new GridLayout();
controlLayout.horizontalSpacing = 0;
controlLayout.verticalSpacing = 0;
controlLayout.marginHeight = 0;
controlLayout.marginWidth = 0;

control.setLayout(controlLayout);

Composite contentArea = new Composite(control, SWT.NONE);
GridData clientData = new GridData(GridData.FILL_BOTH);
contentArea.setLayoutData(clientData);

contentArea.setLayout(new FillLayout());

Composite ppp = new Composite(contentArea, SWT.NONE);
PPP(ppp);

if (parent != null) return;
}

public static void PPP(Composite parent) {
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
parent.setLayout(layout);

Composite pane1 = new Composite(parent, SWT.BORDER);
pane1.setLayoutData(new GridData(GridData.FILL_BOTH));

pane1.setLayout(new GridLayout());

Label label = new Label(pane1, SWT.PUSH);
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
label.setText("sdfsdf");

SashForm form = new SashForm(pane1, SWT.VERTICAL);
form.setLayoutData(new GridData(GridData.FILL_BOTH));
form.setLayout(new FillLayout());

Composite child1 = new Composite(form, SWT.NONE);
child1.setLayout(new FillLayout());
//table = new CTable(child1, new CellDisplay(), new Renderer());
new Label(child1, SWT.NONE).setText("Label in pane 1");

Composite child2 = new Composite(form, SWT.NONE);
child2.setLayout(new FillLayout());
new Button(child2, SWT.PUSH).setText("Button in pane2");

Composite child3 = new Composite(form, SWT.NONE);
child3.setLayout(new FillLayout());

Composite ccc = new Composite(child3, SWT.BORDER);
ccc.setLayout(new FillLayout());

Composite ddd = new Composite(ccc, SWT.BORDER);
ddd.setLayout(new FillLayout());

/**-------------------------------------------------
* Here, Whe i use button control to replace table,
* the button control will refresh correctly while the shell
maximum,
* But when i use table control, why the table control will not
* refresh correctly while the shell maximum ?
*
* [attention please:] Here table's parent composite is
* the composite "ddd" by design.
*
* whether or not this is the table control 's
bug?
-------------------------------------------------**/
//new Button(ddd, SWT.PUSH).setText("Button in pane3");
Table table = new Table(ddd, SWT.FULL_SELECTION);

table.setHeaderVisible(true);
table.setLinesVisible(true);

TableColumn col1 = new TableColumn(table, SWT.CENTER);
col1.setText(" col1");
col1.setWidth(90);
TableColumn col2 = new TableColumn(table, SWT.CENTER);
col2.setText(" col2");
col2.setWidth(90);

for (int i = 0; i < 10; i++){
TableItem item = new TableItem(table, SWT.NONE);
item.setText(new String[] { "row", "col"});
}

form.setWeights(new int[] { 30, 40, 30 });

}
}






"Steve Northover" <steve_northover@ca.ibm.com> ะด
Previous Topic:ideal size of classes in Eclipse/Java
Next Topic:TableViewer
Goto Forum:
  


Current Time: Sun Oct 25 08:38:36 GMT 2020

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

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

Back to the top