home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Microsoft ASP / _SETUP.1 / ASPWizard.jar / asp / wizard / SqlTableModelTestFrame.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-20  |  4.6 KB  |  112 lines

  1. package asp.wizard;
  2.  
  3. import asp.util.ResourceUtil;
  4. import asp.wizard.util.UiUtil;
  5. import com.sun.java.swing.JButton;
  6. import com.sun.java.swing.JDialog;
  7. import com.sun.java.swing.JFrame;
  8. import com.sun.java.swing.JScrollPane;
  9. import com.sun.java.swing.JTable;
  10. import java.awt.Container;
  11. import java.awt.Dialog;
  12. import java.awt.Frame;
  13. import java.awt.GridBagConstraints;
  14. import java.awt.GridBagLayout;
  15. import java.awt.Window;
  16. import java.sql.ResultSet;
  17. import java.sql.SQLException;
  18.  
  19. public class SqlTableModelTestFrame extends JDialog {
  20.    JButton _btnClose;
  21.    ReadOnlyJTable _tblResultSet;
  22.    SqlTableModel _mdlResultSet;
  23.    static SqlTableModelTestFrame _sqlTableModelTestFrame = null;
  24.    // $FF: synthetic field
  25.    static Class class$asp$wizard$WVPanelDbQuery;
  26.  
  27.    public static SqlTableModelTestFrame getInstance() {
  28.       if (_sqlTableModelTestFrame == null) {
  29.          JFrame frame = new JFrame();
  30.          _sqlTableModelTestFrame = new SqlTableModelTestFrame(frame);
  31.       }
  32.  
  33.       return _sqlTableModelTestFrame;
  34.    }
  35.  
  36.    public SqlTableModelTestFrame(Frame parent) {
  37.       this(parent, "Test SQL");
  38.    }
  39.  
  40.    public SqlTableModelTestFrame(Frame parent, String title) {
  41.       super(parent, title);
  42.       this._btnClose = new JButton();
  43.       this._tblResultSet = new ReadOnlyJTable();
  44.       this._mdlResultSet = new SqlTableModel();
  45.       this.initLayout();
  46.       this.initEventListeners();
  47.       this.initModels();
  48.       ((Dialog)this).setModal(true);
  49.    }
  50.  
  51.    protected void initLayout() {
  52.       GridBagLayout gbl = new GridBagLayout();
  53.       GridBagConstraints gbc = new GridBagConstraints();
  54.       JScrollPane scrollPane = null;
  55.       Container c = ((JDialog)this).getContentPane();
  56.       c.setLayout(gbl);
  57.       this._tblResultSet.setAutoResizeMode(0);
  58.       this._tblResultSet.getTableHeader().setReorderingAllowed(false);
  59.       gbc.fill = 1;
  60.       gbc.gridy = 1;
  61.       gbc.weightx = (double)1.0F;
  62.       gbc.weighty = (double)1.0F;
  63.       scrollPane = JTable.createScrollPaneForTable(this._tblResultSet);
  64.       c.add(scrollPane, gbc);
  65.       String btnText = ResourceUtil.getResourceString("asp.wizard.res", class$asp$wizard$WVPanelDbQuery != null ? class$asp$wizard$WVPanelDbQuery : (class$asp$wizard$WVPanelDbQuery = class$("asp.wizard.WVPanelDbQuery")), "button.resultsetclose");
  66.       String btnMnemonic = ResourceUtil.getResourceString("asp.wizard.res", class$asp$wizard$WVPanelDbQuery != null ? class$asp$wizard$WVPanelDbQuery : (class$asp$wizard$WVPanelDbQuery = class$("asp.wizard.WVPanelDbQuery")), "button.resultsetclose");
  67.       this._btnClose.setText(btnText);
  68.       this._btnClose.setMnemonic(btnMnemonic.charAt(0));
  69.       gbc.fill = 13;
  70.       gbc.gridy = 2;
  71.       gbc.weightx = (double)0.0F;
  72.       gbc.weighty = (double)0.0F;
  73.       c.add(this._btnClose, gbc);
  74.       ((Window)this).pack();
  75.    }
  76.  
  77.    protected void initEventListeners() {
  78.       this._btnClose.addActionListener(new 1(this));
  79.    }
  80.  
  81.    private void initModels() {
  82.       this._tblResultSet.setModel(this._mdlResultSet);
  83.    }
  84.  
  85.    public void update(ResultSet rs) {
  86.       try {
  87.          this._mdlResultSet.update(rs);
  88.          rs.close();
  89.       } catch (SQLException e) {
  90.          AspWizardExceptionHandler.showMessage(0, ((Throwable)e).getMessage());
  91.       }
  92.  
  93.    }
  94.  
  95.    public void setVisible(boolean visible) {
  96.       if (visible) {
  97.          UiUtil.centerComponentInScreen(this);
  98.       }
  99.  
  100.       super.setVisible(visible);
  101.    }
  102.  
  103.    // $FF: synthetic method
  104.    static Class class$(String class$) {
  105.       try {
  106.          return Class.forName(class$);
  107.       } catch (ClassNotFoundException forName) {
  108.          throw new NoClassDefFoundError(((Throwable)forName).getMessage());
  109.       }
  110.    }
  111. }
  112.