/* * QuerySpanGridDemo.java * * Copyright 2000 Eliad Technologies, Inc. All Rights Reserved. * * This software is the proprietary information of Eliad Technologies, Inc. */ package example08; import java.awt.*; import java.awt.event.*; import javax.swing.*; import com.eliad.swing.*; import com.eliad.util.*; /** * This class demonstrates the definition of a procedural span model. * @author Daniel Rosenblatt * @version 1.0 */ public class QuerySpanGridDemo extends JFrame { private JSmartGrid grid_; private QuerySpanGridModel model_; public QuerySpanGridDemo() { super("Query Span Example"); addWindowListener ( new java.awt.event.WindowAdapter () { public void windowClosing (java.awt.event.WindowEvent evt) { System.exit(0); } } ); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); JMenuItem exitMenuItem = new JMenuItem("Exit"); exitMenuItem.addActionListener( new ActionListener () { public void actionPerformed (ActionEvent evt) { System.exit(0); } } ); fileMenu.add(exitMenuItem); JMenu toolsMenu = new JMenu("Tools"); menuBar.add(toolsMenu); final JCheckBoxMenuItem spanMenuItem = new JCheckBoxMenuItem("Span On/Off"); spanMenuItem.addActionListener( new ActionListener () { public void actionPerformed (ActionEvent evt) { model_.setSpanned(spanMenuItem.getState()); } } ); toolsMenu.add(spanMenuItem); setJMenuBar(menuBar); try { model_ = new QuerySpanGridModel("jdbc:odbc:Sales", "sun.jdbc.odbc.JdbcOdbcDriver"); model_.setQuery("SELECT * FROM DemoQuery"); grid_ = new JSmartGrid(model_,model_.getSpanModel()); JScrollPane js = new JScrollPane(grid_); grid_.setColumnHeader(new JSmartGridHeader(grid_,grid_.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); } } public static void main(String[] args) { QuerySpanGridDemo sg = new QuerySpanGridDemo(); Dimension big=Toolkit.getDefaultToolkit().getScreenSize(); Dimension small=sg.getSize(); sg.setLocation((big.width-small.width)/2, (big.height-small.height)/2); sg.setVisible(true); } }