<http://forum.pspad.com/read.php?f=2&i=10082&t=10016>
----------------------------------------------------------------
Thanks, heres a sample if you want to see what I mean. Other than that -
great tool!
// JDBCBrowser.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class JDBCBrowser extends JPanel
implements WindowListener,
ActionListener{
public JMenuBar m_MenuBar;
public JToolBar m_ToolBar;
private JFrame m_Frame;
/**
* This manages consistant display of exception messages.
* It should go to bcc.util for better reuse
* Pass frame as needed
* return code from showMessageDialog would be useful
*/
private void reportException(Exception e, Frame theFrame) {
System.out.println("Exception: " + e.getMessage() );
JOptionPane.showMessageDialog(theFrame,
e.getMessage(), theFrame.getTitle() + " error",
JOptionPane.ERROR_MESSAGE);
} // end reportException()
/**
* Required to support interface ActionListener.
*
* @param ActionEvent e
*/
public void actionPerformed( ActionEvent e) {
AbstractButton item;
// note menu items are also 'AbstractButton' derivatives
item = (AbstractButton)e.getSource();
String cmd = item.getActionCommand();
// now make an if else chain to manage the commands
if( cmd == "quit" || cmd == "fileExit" ) {
// Window window = windowEvent.getWindow();
serializeControls();
setVisible(false);
// dispose();
System.exit(0);
}
} // end of actionPerformed method
String choseOutputFile( String sExtension ) {
return outfile;
} // end of choseOutputFile()
// inner class for file filter
class ExportFilter extends javax.swing.filechooser.FileFilter {
public String getDescription() {
return m_sDesc;
}
} // end inner filter class
/**
* The following window events are required to support the
* implementation of the WindowListener interface
* this panel acts as a windowlistener of the main frame
*/
public void windowOpened( WindowEvent e ) {}
public void windowIconified( WindowEvent e ) {}
public void windowDeiconified( WindowEvent e ) {}
public void windowDeactivated( WindowEvent e ) {}
/**
* This is where it all begins.
* construct the thing and initialize it
*/
public JDBCBrowser(String sCaption) {
m_Frame.setVisible(true);
} // end ctor
/**
* set up the menu and tool bars
*/
public void initGui(String sCaption) {
JMenu mnuHelp = new JMenu("Help");
// create the children
mnuHelp.add(new HelpAction("Contents", this, "Contents",
null));
mnuHelp.add(new HelpAction("About", this, "helpAbout",
null));
m_MenuBar.add(mnuFile);
m_MenuBar.add(mnuEdit);
m_MenuBar.add(mnuTools);
m_MenuBar.add(mnuHelp);
} // end initGui()
public JTree createTree() {
// JTree m_Tree;
// Hashtable
m_htTreeRoot;
// DefaultMutableTreeNode m_rootNode;
// DefaultTreeModel m_treeModel;
m_rootNode = new DefaultMutableTreeNode();
m_treeModel = new DefaultTreeModel(m_rootNode);
m_Tree = new JTree(m_treeModel);
return m_Tree;
} // end createTree()
protected Connection createDBConn() {
// local dlg data
String UserID = m_txtUserID.getText();
// note getPassword returns chr[], not a String!
String PWD = new String(m_txtPwd.getPassword()); // deprecated
--
getText();
String jdbcUrl =
(String)m_cboJdbcUrl.getSelectedItem();
String jdbcProvider =
(String)m_cboJdbcProvider.getSelectedItem();
String jdbcCatalog = (String)m_cboCatalog.getSelectedItem();
return m_conn;
}
public void loadTree() {
} // end loadTree()
public void executeSQLCmd() {
}
class HelpAction extends AbstractAction {
// This is our sample action. It must have an actionPerformed()
method,
// which is called when the action should be invoked.
public HelpAction(String text,
WindowListener listener,
String actionCmd,
Icon icon) {
super(actionCmd,icon);
}
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
}
}
} // end class HelpAction
public static void main(String s[]) {
try {
UIManager.setLookAndFeel("com.stefankrause.xplookandfeel.XPLookAndFeel");
} catch(Exception e){ System.out.println(e.getMessage() ); }
System.out.println(
"\nThe current look and feel is "
+ UIManager.getLookAndFeel().getName());
JDBCBrowser example = new JDBCBrowser("BCC JDBC Data Browser");
}
boolean deSerializeControls() {
boolean bReturn = false;
return bReturn;
} // end deSerializeControls
void serializeControls() {
} // end serializeControls();
int setTraceLevel() {
} // end tracelevel()
public void updateTraceWnd( String str ) {
// JTextArea
m_txtTraceWnd.append("\n");
m_txtTraceWnd.append(str);
}
} // end class JDBCBrowser
--
PSPad freeware editor http://www.pspad.com