com.holub.database
Class JTableExporter

java.lang.Object
  extended by com.holub.database.JTableExporter
All Implemented Interfaces:
Table.Exporter

public class JTableExporter
extends Object
implements Table.Exporter

A class that demonstrates using an Exporter to create a UI. The following code creates and populates a table, then creates a JTable that holds a representation of the Table.

        Table people = TableFactory.create( "people",
                                   new String[]{ "First", "Last"                } );
        people.insert( new String[]{ "Allen",   "Holub"         } );
        people.insert( new String[]{ "Ichabod", "Crane"         } );
        people.insert( new String[]{ "Rip",             "VanWinkle" } );
        people.insert( new String[]{ "Goldie",  "Locks"         } );

        javax.swing.JFrame frame = new javax.swing.JFrame();
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

        JTableExporter tableBuilder = new JTableExporter();
        people.export( tableBuilder );

        frame.getContentPane().add(
                        new JScrollPane( tableBuilder.getJTable() ) );
        frame.pack();
        frame.setVisible( true );
 

See Also:
CSVExporter
©2004 Allen I. Holub. All rights reserved.

This code may be used freely by yourself with the following restrictions:

  1. Your splash screen, about box, or equivalent, must include Allen Holub's name, copyright, and URL. For example:

    This program contains Allen Holub's SQL package.
    (c) 2005 Allen I. Holub. All Rights Reserved.
    http://www.holub.com


    If your program does not run interactively, then the foregoing notice must appear in your documentation.
  2. You may not redistribute (or mirror) the source code.
  3. You must report any bugs that you find to me. Use the form at http://www.holub.com/company/contact.html or send email.
  4. The software is supplied as is. Neither Allen Holub nor Holub Associates are responsible for any bugs (or any problems caused by bugs, including lost productivity or data) in any of this code.

Nested Class Summary
static class JTableExporter.Test
          A unit test for the JTableExporter class Run it with java com.holub.database.JTableExporter\$Test.
 
Constructor Summary
JTableExporter()
           
 
Method Summary
 void endTable()
           
 JTable getJTable()
          Return the Concrete Product of this builder---a JTable initialized with the table data.
 void startTable()
           
 void storeMetadata(String tableName, int width, int height, Iterator columnNames)
           
 void storeRow(Iterator data)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JTableExporter

public JTableExporter()
Method Detail

startTable

public void startTable()
                throws IOException
Specified by:
startTable in interface Table.Exporter
Throws:
IOException

storeMetadata

public void storeMetadata(String tableName,
                          int width,
                          int height,
                          Iterator columnNames)
                   throws IOException
Specified by:
storeMetadata in interface Table.Exporter
Throws:
IOException

storeRow

public void storeRow(Iterator data)
              throws IOException
Specified by:
storeRow in interface Table.Exporter
Throws:
IOException

endTable

public void endTable()
              throws IOException
Specified by:
endTable in interface Table.Exporter
Throws:
IOException

getJTable

public JTable getJTable()
Return the Concrete Product of this builder---a JTable initialized with the table data.