/* * HeaderGridDemo.java * * Copyright 2000 Eliad Technologies, Inc. All Rights Reserved. * * This software is the proprietary information of Eliad Technologies, Inc. */ package example03; import java.awt.*; import java.awt.event.*; import javax.swing.*; import com.eliad.swing.*; import com.eliad.util.*; /** * This class shows a simple JSmartGrid displaying the results of a query in a database * with appropriate column headers. * @author Daniel Rosenblatt * @version 1.0 */ public class HeaderGridDemo extends JFrame { private JSmartGrid grid_; /** Creates a new TableGrid */ public HeaderGridDemo() { super("Database Grid Example With Headers"); addWindowListener ( new WindowAdapter () { public void windowClosing (WindowEvent evt) { System.exit(0); } } ); try { HeaderGridModel model = new HeaderGridModel("jdbc:odbc:Sales", "sun.jdbc.odbc.JdbcOdbcDriver"); model.setQuery("SELECT * FROM DemoQuery"); grid_ = new JSmartGrid(model); grid_.setAutoCreateRowHeader(true); JScrollPane js = new JScrollPane(grid_); grid_.setColumnHeader(new JSmartGridHeader(grid_,JSmartGrid.HORIZONTAL,model.getColumnHeaderModel(),null,null)); getContentPane().add(js, BorderLayout.CENTER); ((JComponent)getContentPane()).setPreferredSize(new Dimension(500, 400)); pack(); } catch (Exception e) { System.out.println(e); } } /** Creates and displays a DBHeaderGrid frame */ public static void main(String[] args) { HeaderGridDemo sg = new HeaderGridDemo(); Dimension big=Toolkit.getDefaultToolkit().getScreenSize(); Dimension small=sg.getSize(); sg.setLocation((big.width-small.width)/2, (big.height-small.height)/2); sg.setVisible(true); } }