Sorry about that. You didn't mention if you are writing an Eclipse RCP
application or just a standalone SWT application. Below is a snippet
that implements an RCP view with a simple embedded Swing JTable, using
the code included with the article. If you're writing a standalone SWT
application, you should be able to take just the code from
createPartControl() and added it to a shell or some other composite.
Once you get it running, you should also be able to replace the JTable
with another component of your choice. Make sure you take a look at the
javadoc as well. The sample code still has some issues, as you can see
from some of the other posts in this newsgroup.
public class JTableView extends ViewPart {
private EmbeddedSwingComposite embeddedComposite;
public void createPartControl(Composite parent) {
embeddedComposite = new EmbeddedSwingComposite(parent, SWT.NONE) {
protected JComponent createSwingComponent() {
/* Creating components */
int nrows = 1000, ncolumns = 10;
Vector rows = new Vector();
for (int i = 0; i < nrows; i++) {
Vector row = new Vector();
for (int j = 0; j < ncolumns; j++) {
row.addElement("Item " + i + "-" + j);
}
rows.addElement(row);
}
Vector columns = new Vector();
for (int i = 0; i < ncolumns; i++) {
columns.addElement("Column " + i);
}
JTable table = new JTable(rows, columns);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.createDefaultColumnsFromModel();
JScrollPane scrollPane = new JScrollPane(table);
return scrollPane;
}
};
embeddedComposite.populate();
}
public void setFocus() {
embeddedComposite.setFocus();
}
}