Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 285513 Details for
Bug 571103
TabColumn.pack() crashes JVM is no TableItems are present.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Example program to show the issue
TableColumnPackIssue.java (text/x-java), 3.14 KB, created by
Ron Anderson
on 2021-02-10 19:30:28 EST
(
hide
)
Description:
Example program to show the issue
Filename:
MIME Type:
Creator:
Ron Anderson
Created:
2021-02-10 19:30:28 EST
Size:
3.14 KB
patch
obsolete
>import org.eclipse.swt.SWT; >import org.eclipse.swt.events.SelectionAdapter; >import org.eclipse.swt.events.SelectionEvent; >import org.eclipse.swt.layout.GridData; >import org.eclipse.swt.layout.GridLayout; >import org.eclipse.swt.widgets.Button; >import org.eclipse.swt.widgets.Composite; >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 TableColumnPackIssue { > > public static void main(String[] args) { > Display display = new Display(); > Shell shell = new Shell(display, SWT.TITLE | SWT.CLOSE | SWT.RESIZE); > shell.setText("TableColumnPackIssue"); > > GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); > GridLayout gl = new GridLayout(1, true); > shell.setLayout(gl); > shell.setLayoutData(gd); > > final Table table = new Table(shell, SWT.CHECK | SWT.BORDER > | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.VIRTUAL); > gd = new GridData(SWT.FILL, SWT.FILL, true, true); > gd.heightHint = table.getItemHeight() * 5; > table.setLayoutData(gd); > table.setHeaderVisible(true); > table.setLinesVisible(true); > for (int col = 0; col < 5; col++) { > TableColumn tc = new TableColumn(table, SWT.RIGHT); > tc.setText(String.format("Column %d", col + 1)); > } > > table.addListener(SWT.SetData, new Listener() { > > @Override > public void handleEvent(Event event) { > TableItem item = (TableItem) event.item; > int index = table.indexOf(item); > String[] labels = new String[table.getColumnCount()]; > for (int col = 0; col < labels.length; col++) { > labels[col] = String.format("%d, %d", index + 1, col + 1); > } > > item.setText(labels); > item.setChecked(index == 0); > } > }); > table.setItemCount(5); > table.clearAll(); > for (TableColumn tc : table.getColumns()) { > tc.pack(); > } > > Composite comp = new Composite(shell, SWT.NONE); > gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); > gl = new GridLayout(1, true); > comp.setLayoutData(gd); > comp.setLayout(gl); > > Button clear = new Button(comp, SWT.PUSH); > clear.setText("Clear"); > clear.addSelectionListener(new SelectionAdapter() { > @Override > public void widgetSelected(SelectionEvent e) { > table.removeAll(); > table.clearAll(); > table.setItemCount(0); > for (TableColumn tc : table.getColumns()) { > tc.pack(); > } > } > }); > > shell.pack(); > shell.setMinimumSize(shell.getSize()); > shell.open(); > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) { > display.sleep(); > } > } > display.dispose(); > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 571103
: 285513