/* * DBSnapshotGridDemo.java * * Copyright 2000 Eliad Technologies, Inc. All Rights Reserved. * * This software is the proprietary information of Eliad Technologies, Inc. */ package example02; import java.awt.*; import java.awt.event.*; import javax.swing.*; import com.eliad.swing.*; /** * This class displays data from a database inside a JSmartGrid. * @author Daniel Rosenblatt * @version 1.0 */ public class DBSnapshotGridDemo extends JFrame { private JSmartGrid grid_; public DBSnapshotGridDemo() throws ClassNotFoundException, java.sql.SQLException { super("Database Grid Example"); addWindowListener ( new WindowAdapter () { public void windowClosing (WindowEvent evt) { System.exit(0); } } ); DBSnapshotGridModel model = new DBSnapshotGridModel("jdbc:odbc:Sales", "sun.jdbc.odbc.JdbcOdbcDriver"); model.setQuery("SELECT * FROM DemoQuery"); grid_ = new JSmartGrid(model); grid_.setResizable(JSmartGrid.HORIZONTAL,true); JScrollPane js = new JScrollPane(grid_); getContentPane().add(js, BorderLayout.CENTER); ((JComponent)getContentPane()).setPreferredSize(new Dimension(500, 400)); pack(); } public static void main(String[] args) { try { DBSnapshotGridDemo sg = new DBSnapshotGridDemo(); Dimension big=Toolkit.getDefaultToolkit().getScreenSize(); Dimension small=sg.getSize(); sg.setLocation((big.width-small.width)/2, (big.height-small.height)/2); sg.setVisible(true); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (java.sql.SQLException e) { e.printStackTrace(); } } }