I'm self-teaching Java GUIs and am trying to implement an older text-based program I made into something with an actual menu. In using WindowBuilder on Eclipse for formatting and internet resources to help, but I've hit a bit of a roadblock.
I've got a one-dimensional vector that can hold any number of strings. I'd like to display it in a table, but I'm not quite sure if I'm doing it right. All of my back-end stuff works fine, I'm just really struggling with the GUI. Any tips/corrections/resources you're willing to offer are greatly appreciated! I've been bumbling around for hours and I fear I've hit a wall. To be honest I'm having trouble testing the GUI within WindowBuilder as well, but that's another story. The relevant code in my GUI class is as follows:
Vector<String> demo = new Vector<String>();
//nonsense elements just for the sake of debugging
demo.addElement("Line1");
demo.addElement("Line2");
demo.addElement("Line3");
demo.addElement("Line4");
demo.addElement("Line5");
demo.addElement("Line6");
table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableItem item;
for(int i = 0; i < demo.size(); i++)
{
// Create a new TableItem for each line in the vector (each row)
item = new TableItem(table, SWT.NONE);
for (int j = 1; j <= demo.size(); j++) {
// Populate the item
item.setText(j - 1, demo.get(j));
}
}