/* Feb 1, 1999 */ /* ***************************************************************************** Copyright 2000 by Erica Andrews (cylikon@hotmail.com). All rights reserved. ./ButchWhipAppeal/ ./IcedPinky/ NO portion of this software may be used in ANY way by anyone other than myself without my express written consent. If it is downloaded for testing, it must be deleted from your system within 24 hours. Any other use constitutes piracy and fraudulent misuse of this software, punishable in a court of law. Copyright 2000 by Erica Andrews. All rights reserved. ***************************************************************************** */ import java.io.*; import java.util.*; import java.sql.*; import java.awt.*; import java.awt.Font; import java.awt.event.*; import java.rmi.*; import sun.jdbc.rowset.*; public class MySQLGUI2 extends Frame implements WindowListener,MouseListener { TextArea textscreen; Button doit; Label label; Panel panel1; Panel panel2; public MySQLGUI2 () { setTitle("MySQL Query Powered By Java"); setLayout(null); setBackground(Color.cyan); setForeground(Color.black); setBounds(new Rectangle(5,5,790,570)); textscreen = new TextArea ( 5, 80 ); textscreen.setBackground(Color.blue); textscreen.setForeground(Color.white); textscreen.setBounds(new Rectangle(10,175,775,340)); doit = new Button("Show ALL Sites!"); doit.setForeground(Color.black); doit.setBackground(Color.pink); doit.addMouseListener( this ); doit.setBounds(new Rectangle(600,95,185,70)); label = new Label("MySQL Query Powered By Java"); label.setAlignment(Label.CENTER); label.setForeground(Color.white); label.setBackground(Color.blue); label.setFont(new Font("Helvetica", Font.BOLD, 26)); label.setBounds(new Rectangle(2,25,790,60)); add (label); add (doit); add (textscreen ); addWindowListener ( this ); resize ( 790, 570); pack(); show (); } // end GUI constructor // ************** Listener Events ****************** //**** WindowListener methods public void windowActivated ( WindowEvent e ) { } public void windowDeactivated ( WindowEvent e ) { } public void windowOpened ( WindowEvent e ) { this.resize( 790, 570); } public void windowClosed ( WindowEvent e ) { } public void windowClosing ( WindowEvent e ) { this.hide (); this.dispose (); System.exit(0); } public void windowIconified ( WindowEvent e ) { } public void windowDeiconified ( WindowEvent e ) { } //**** MouseListener methods public void mouseClicked ( MouseEvent e ) { } public void mousePressed ( MouseEvent e ) { doit.setBackground(Color.red); label.setForeground(Color.red); label.setBackground(Color.white); label.setText("SEARCHING..."); } public void mouseReleased ( MouseEvent e ) { DoQuery(); } public void DoQuery() { // - showing the SELECT query statement in the Textarea "textscreen" try { RMIMySQL2 obj = (RMIMySQL2) Naming.lookup("//127.0.0.1:1473/CachedRowExample"); CachedRowSet cr = new CachedRowSet(); cr = obj.RMIResultSet(); int x = 0; // for counting the results while (cr.next()) { String id = cr.getString(1).trim(); String itsgroup = cr.getString(2).trim(); String title = cr.getString(3).trim(); String url = cr.getString(4).trim(); String thedate = cr.getString(5).trim(); textscreen.appendText("ID: "+id+" "); textscreen.appendText("GROUP: "+itsgroup+" "); textscreen.appendText("TITLE: "+title+" "); textscreen.appendText("URL: "+url+" "); textscreen.appendText("DATE INDEXED: "+thedate+"\n"); x++; // increment x after each row } // end of while statement obj.ResultSetCleanUp(); // release all old rows from the CachedRowSet textscreen.appendText("\n\n\n QUERY FOUND "+x+" RESULTS."); // show number of results } catch (Exception exc) { textscreen.appendText("A problem occurred: "+exc); } // --- end of try/catch doit.setBackground(Color.pink); label.setForeground(Color.white); label.setBackground(Color.blue); label.setText("MySQL Query Powered By Java"); } //---------- end of method DoQuery for MouseReleased public void mouseEntered ( MouseEvent e ) { doit.setBackground(Color.green); } public void mouseExited ( MouseEvent e ) { doit.setBackground(Color.pink); } public static void main(String args[]) { new MySQLGUI2(); } } // end of Class