GUI Designer and JTable

I am trying to learn to use the GUI builder. I have a simple test with a button and JTable in a JScrollPane on a form. However, I cannot get anything to show up inside the JTable. I have the simple main() below (irrelevant code removed for simplicity). No matter what I do I cannot get anything to show up in the table.

What's the trick to setting up a tablemodel so I can view the data in a jtable created from the GUI Designer??

public class TestGuiDesigner(){
public static void main(String[] args) {
//Create instance of main GUI test class
TestGuiDesigner testGui=new TestGuiDesigner();
FileModel fm=new FileModel("M:
Software");
//Setup a tablemodel with data for table
testGui.dataTable.setModel(fm);
testGui.dataTable.createDefaultColumnsFromModel();

JFrame frm=new JFrame("Testing GIU Designer");
frm.getContentPane().add(testGui.mainPanel);
frm.pack();

}

private JTable dataTable;
private JButton btnOK;
private JPanel mainPanel;
private JScrollPane jsp;

}

3 comments
Comment actions Permalink

Hi WP,

> I am trying to learn to use the GUI builder.

First try to get it running using plain Java (no GUI builder).

> What's the trick to setting up a tablemodel so I can view the data in
> a jtable created from the GUI Designer??

Please take a look at SUN's Java Tutorial or the book Java Foundation
Classes from O'Reilly (or any other Swing-related book.

Tom


WP wrote:

I am trying to learn to use the GUI builder. I have a simple test with a button and JTable in a JScrollPane on a form. However, I cannot get anything to show up inside the JTable. I have the simple main() below (irrelevant code removed for simplicity). No matter what I do I cannot get anything to show up in the table.

What's the trick to setting up a tablemodel so I can view the data in a jtable created from the GUI Designer??

public class TestGuiDesigner(){
public static void main(String[] args) {
//Create instance of main GUI test class
TestGuiDesigner testGui=new TestGuiDesigner();
FileModel fm=new FileModel("M:
Software");
//Setup a tablemodel with data for table
testGui.dataTable.setModel(fm);
testGui.dataTable.createDefaultColumnsFromModel();

JFrame frm=new JFrame("Testing GIU Designer");
frm.getContentPane().add(testGui.mainPanel);
frm.pack();

}

private JTable dataTable;
private JButton btnOK;
private JPanel mainPanel;
private JScrollPane jsp;

}

0
Comment actions Permalink

I have got it working in plain java....that's the frustrating part. I am trying to recreate a simple demo program in Idea usign the GUI designer and I can't get it working.

Does you previous reponse imply that there are no special steps required? Based on my experience there must be.

0
Comment actions Permalink

IMHO, the best way to hack into IDEA UI builder is to modify the setting to let it inject the UI source into your source. After looking into the generated source code, i'm sure u'll figure it out.

The general rule is do not create UI component(IDEA does it for u), just declear it and bundle it.

0

Please sign in to leave a comment.