Вы находитесь на странице: 1из 15

import java.applet.

Applet;
import java.awt.Frame;
import java.awt.List;
import java.awt.*;
import java.net.*;
import java.util.*;
import java.awt.event.*;
import java.io.*;

//------------------------------------------------------------------------------------------------//
// Wed 16 Dec 2009 07:20:53 AM EST //
// 12/26/09 //
//------------------------------------------------------------------------------------------------//

class frame12
{

//frame12 frame12 frame12 frame12 x2t frame12 frame12 frame12 frame12 frame12 frame1

//-------------------------------------//
// end of get url function //
//-----------------------------------------------------------//
// define GLOBALS //
//-----------------------------------------------------------//

public static String HTML_1 = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" ;
public static String HTML_2 = "<html>" ;
public static String HTML_3 = " <head>" ;
public static String HTML_4 = " <title>empty-1</title>" ;
public static String HTML_5 = " <meta name=\" author\" content=\" mbspringer\"
>" ;
public static String HTML_6 = " <meta name=\" generator\" content=\" screem
0.16.1\" >" ;
public static String HTML_7 = " <meta name=\" description\" content=\" template
empty-1\" >" ;
public static String HTML_8 = " <meta name=\" keywords\" content=\" template
empty-1\" >" ;
public static String HTML_9 = " <meta http-equiv=\" content-type\" content=\"
text/html; charset=ISO-8859-1\" >" ;
public static String HTML_10 =" <meta http-equiv=\" Content-Script-Type\"
content=\" text/javascript\" >" ;
public static String HTML_11 =" <meta http-equiv=\" Content-Style-Type\"
content=\" text/css\" >" ;
public static String HTML_12 =" </head>" ;
public static String HTML_14 =" <body>" ;
public static String HTML_15 =" </body>" ;
public static String HTML_16 ="</html>" ;
public static String HTML_17 ="" ;

//-----------------------------------------------------------//

public static boolean deebug = false ;


public static int lines_found = 0 ;
public static int FONT_SIZE = 12 ;
public static int MINIMUM_LINKS = 0 ;
public static List l_Input_File_List ;
public static List l_Upper_Window ;
public static List l_Output_list ;
public static List l_Mail_Html_List ;
public static List l_Lower_Window ;
public static TextField location_bar ;
public static TextField counter_field ;
public static String BASE_URL="" ;

public static String OUTPUT_COPY="" ;


public static TextArea OUTPUT_AREA;
//-------------------------------------------------

public static Color lightGreen = new Color(144,238,144);

//-----------------------------------------------------------//
// define GLOBAL text fields for user input and progress //
//-----------------------------------------------------------//

public static TextField link_limit ;


public static TextField links_found ;
public static TextField emails_found ;
public static TextField topic ;

public static int emails=0 ;

public static String BEGINNING = "http://search.go2net.com/crawler?general=";


public static String ENDING =
"&method=2&target=&region=0&rpp=30&timeout=120&hpe=30&format=power&eng=AltaVista&en
g=Excite&eng=Infoseek&eng=Lycos&eng=WebCrawler&eng=Yahoo&eng=Thunderstone&eng=Look
Smart&eng=MiningCo";

//-----------------------------------------------------------//
// END OF GLOBALS DEFINITION //
//-----------------------------------------------------------//

public static void main (String args[])


{
// Extraction_Thread t1 = new Extraction_Thread();
// t1.start();
//comp2d.setColor(lightGreen);

MyFrame mf;

//-----------------------------------------------------------//
// define labels for textfields under buttons //
//-----------------------------------------------------------//
Label lab_05 = new Label("lines found " , Label.RIGHT) ;
Label lab_06 = new Label("links " , Label.RIGHT) ;
Label lab_07 = new Label("emails " , Label.RIGHT) ;
Label lab_08 = new Label("topic " , Label.RIGHT) ;

//-----------------------------------------------------------//
// define labels //
// AND PROGRAM TITLE BAR //
//-----------------------------------------------------------//
Label lab_01 = new Label("") ;
Label lab_02 = new Label("") ;
Label lab_03 = new Label("") ;
Label lab_04 ;//= new Label("Extractor") ;

lab_01.setBackground( Color.lightGray) ;
lab_02.setBackground( Color.lightGray) ;
lab_03.setBackground( Color.lightGray) ;
lab_04 = new Label(" frame12.java ") ;
lab_04.setFont( new Font ("TimesRoman" , Font.PLAIN , frame12.FONT_SIZE ));

l_Upper_Window = new List() ;


l_Output_list = new List() ;
l_Mail_Html_List = new List() ;
l_Lower_Window = new List() ;
l_Input_File_List = new List() ;

location_bar = new TextField(" location_bar");


counter_field = new TextField("counter_field");

emails_found = new TextField("emails_found");


link_limit = new TextField(" link_limit ");
links_found = new TextField(" ");
topic = new TextField("topic");

OUTPUT_COPY = " cut and paste.........\n\n\n" ;


OUTPUT_AREA = new TextArea() ;
OUTPUT_AREA.setText(OUTPUT_COPY ) ;
//-----------------------------------------------------------//
// //
// create a new frame mf = new MyFrame (); //
//-----------------------------------------------------------//
mf = new MyFrame ();
mf.setBackground( Color.magenta) ;
//-----------------------------------------------------------//
// //
// give the new frame a size mf.setSize (600, 300); //
//-----------------------------------------------------------//
mf.setSize (800, 450);

//------------------------------------------------------------------//
// declare the buttons //
// //
//Button button_01 , button_02 , button_03 , button_04 , button_05; //
//------------------------------------------------------------------//
Button button_01 , button_02 , button_03 , button_04 , button_05 , button_06;
Button button_07 , button_08 , button_09 , button_10 , button_11 , button_12;

//-----------------------------------------------------------//
// declare the outer most panel //
//-----------------------------------------------------------//
Panel p_Full_Screen = new Panel ();

//-----------------------------------------------------------//
// declare the outer most panel characteristics //
//-----------------------------------------------------------//
p_Full_Screen.setBackground( Color.magenta) ;
p_Full_Screen.setFont( new Font ("TimesRoman" , Font.PLAIN , frame12.FONT_SIZE ));

//------------------------------------------------------------//
// the outer most layout manager is border layout //
// north gets split horizontally for buttons and location bar //
// and padding //
//------------------------------------------------------------//
Panel p_Split_North = new Panel ();

//-----------------------------------------------------------//
// the uppermost horizontal split is split again //
// for five buttons //
// //
//-----------------------------------------------------------//
Panel p_Split_Top_North = new Panel ();

//-----------------------------------------------------------//
// the center of the outer most layout manager is //
// split into 2 horizontal pieces for l_Upper_Win //
// and l_Lower_Win //
//-----------------------------------------------------------//
Panel p_Split_Center = new Panel ();

//-----------------------------------------------------------//
// create the outer most panel //
//-----------------------------------------------------------//
p_Full_Screen.setLayout( new BorderLayout( 5 , 5 )) ;

//-----------------------------------------------------------//
// create the grid that splits north in 3 //
// as in north , center , south //
//-----------------------------------------------------------//
p_Split_North.setLayout( new BorderLayout( 5 , 5 )) ;

//-----------------------------------------------------------//
// create the grid that splits the top of the last grid //
// into eight horizontal pieces for the 8 buttons //
// and 4 textfields for data and four labels //
//-----------------------------------------------------------//
p_Split_Top_North.setLayout( new GridLayout( 2, 8 , 5 , 5 )) ;

//--------------------------------------------------------------------------//
// create the grid that splits the center of the outer most //
// layout manager into 2 horizontal pieces for l_Upper_Win // //
// and l_Lower_Win //
//--------------------------------------------------------------------------//
p_Split_Center.setLayout( new GridLayout( 2 , 1 , 5 , 5 )) ;

//-----------------------------------------------------------//
// add the first button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( button_01 = new Button( "Extract URL" ) ) ;

//-----------------------------------------------------------//
// add the first button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( button_07 = new Button( "Open File" ) ) ;

//-----------------------------------------------------------//
// add the second button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( button_02 = new Button( "pause" ) ) ;

//-----------------------------------------------------------//
// add the third button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( button_03 = new Button( "resume") ) ;

//-----------------------------------------------------------//
// add the fourth button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( button_04 = new Button( "Help" ) ) ;

//-----------------------------------------------------------//
// add the fifth button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( button_05 = new Button( "Exit") ) ;

//-----------------------------------------------------------//
// add the sixth button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( button_06 = new Button( "About" ) ) ;

//-----------------------------------------------------------//
// add the sixth button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( button_08 = new Button( "button_08" ) ) ;

//-----------------------------------------------------------//
// now we do the text boxes and labels //
//-----------------------------------------------------------//
/
//-----------------------------------------------------------//

button_01.setBackground( Color.yellow) ;
button_02.setBackground( Color.yellow) ;
button_03.setBackground( Color.yellow) ;
button_04.setBackground( Color.yellow) ;
button_05.setBackground( Color.yellow) ;
button_06.setBackground( Color.yellow) ;
button_07.setBackground( Color.yellow) ;
bbutton_08.setBackground( Color.yellow) ;

//-----------------------------------------------------------//
// add the first labe. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( lab_05 ) ;
//-----------------------------------------------------------//
// add the second button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( frame12.link_limit ) ;

//-----------------------------------------------------------//
// add the first labe. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( lab_08 ) ;

//-----------------------------------------------------------//
// add the second button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( frame12.topic ) ;

//-----------------------------------------------------------//
// add the third button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( lab_06 ) ;

//-----------------------------------------------------------//
// add the fourth button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( frame12.links_found ) ;

//-----------------------------------------------------------//
// add the fifth button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( lab_07 ) ;

//-----------------------------------------------------------//
// add the sixth button. grids load left to right //
// top to bottom //
//-----------------------------------------------------------//
p_Split_Top_North.add( frame12.emails_found ) ;

//-----------------------------------------------------------//
// add the title bar to the uppermost panel //
// in the second border layout //
//-----------------------------------------------------------//
p_Split_North.add("North" ,lab_04 );

//-----------------------------------------------------------//
// add the buttons to the "center" panel of the second //
// border layout manager which subdivides //
// "North" in the outermost layout manager //
//-----------------------------------------------------------//
p_Split_North.add( "Center" ,p_Split_Top_North);

//-----------------------------------------------------------//
// add the location bar to lower split //
//-----------------------------------------------------------//
p_Split_North.add( "South" ,location_bar);

//-----------------------------------------------------------//
// add just filled grid to north in p_Full_Screen //
//-----------------------------------------------------------//
p_Full_Screen.add ("North", p_Split_North);

//-----------------------------------------------------------//
// add lists to p_Split_Center //
//-----------------------------------------------------------//
// p_Split_Center.add( l_Upper_Window ) ;
p_Split_Center.add( OUTPUT_AREA ) ;
//-----------------------------------------------------------//
// the following line makes the URL's invisible //
// by inserting an unused list into the layout manager //
//-----------------------------------------------------------//
/// p_Split_Center.add( l_Lower_Window ) ;

//-----------------------------------------------------------//
// the following line makes the URL's visible //
// by inserting the output list into the layout manager //
//-----------------------------------------------------------//
p_Split_Center.add( l_Output_list ) ;

//-----------------------------------------------------------------//
// add just filled p_Split_Center to north in p_Full_Screen //
//-----------------------------------------------------------------//
p_Full_Screen.add ("Center", p_Split_Center);

//-----------------------------------------------------------//
// add labels to east , west and south in p_Full_Screen //
//-----------------------------------------------------------//
p_Full_Screen.add ("East" , lab_01);
p_Full_Screen.add ("West" , lab_02);
p_Full_Screen.add ("South", counter_field);

//-----------------------------------------------------------//
// add just filled p_Full_Screen to mf //
//-----------------------------------------------------------//
mf.add ( p_Full_Screen);
//-----------------------------------------------------------//
// show the frame //
//-----------------------------------------------------------//
mf.setVisible(true);
}
}

//-----------------------------------------------------------//
// END OF MAIN //
//-----------------------------------------------------------//

//-----------------------------------------------------------//
// START OF CHECK BUTTONS //
//-----------------------------------------------------------//

class MyFrame extends Frame


{

public boolean action (Event evt, Object obj )

{
//-------------------------------------//
// check if extract URL //
//-------------------------------------//

if ("Extract URL".equals (obj))

{ try {
FileReader file = new
// (frame12.location_bar).getText() ;
FileReader((frame12.location_bar).getText() );
BufferedReader buff = new
BufferedReader(file);
boolean eof = false;
while (!eof) {
String line = buff.readLine();
if (line == null)
eof = true;
else
frame12.OUTPUT_COPY = frame12.OUTPUT_COPY + line+"\n";
frame12.lines_found = frame12.lines_found +1;
frame12.OUTPUT_AREA.setText(frame12.OUTPUT_COPY);
frame12.links_found.setText("" + frame12.lines_found );

//--- if debug is true


if ( frame12.deebug == true) { System.out.println(line);}
}
buff.close();
} catch (IOException e) {

System.out.println("Error -- " + e.toString());


}

//-------------------------------------//
// end of check if extract URL //
/
//-------------------------------------//

//-------------------------------------//
// check if Open File //
/
//-------------------------------------//

if ("Open File".equals (obj))

{
{

// getDirectory
Frame f = new Frame();
String title = new String();
String defDir = new String() ;
String fileType = new String();

FileDialog fd = new FileDialog(f, title, FileDialog.LOAD);


fd.setFile(fileType);
fd.setDirectory(defDir);
fd.setLocation(50, 50);
fd.show();
frame12.location_bar.setText( fd.getDirectory() +fd.getFile());
}

//-------------------------------------//
// end of check if extract URL //
/
//-------------------------------------//

//-------------------------------------//
// start of resume //
//-------------------------------------//
if ("resume".equals (obj))

{ // frame12.t1.resume() ;
}

//-------------------------------------//
// end of resume //
//-------------------------------------//
//-------------------------------------//
// start of pause //
//-------------------------------------//

if ("pause".equals (obj))

{ // frame12.t1.suspend() ;
}

//-------------------------------------//
// end of pause //
//-------------------------------------//
//-------------------------------------//
// start of exit //
//-------------------------------------//

if ("Exit".equals (obj))

{ System.exit( 0) ;
}

//-------------------------------------//
// end of exit //
//-------------------------------------//
// check if About //
//-------------------------------------//

if ("About".equals (obj))

MyFrame mf ;
mf = new MyFrame() ;
MyDialog d;
MyWindow w;
Button btnOKDialog;
Button btnOKWindow;

w = new MyWindow (mf);


w.setBounds (450, 60, 300, 300);
TextArea taAbout = new TextArea("Wed 16 Dec 2009 07:20:53 AM EST\n frame1 \n
protoware\n\nmark burns springer\ndeacons folly\nnorth harwich, ma. 02645\n\n
mbspringer133@gmail.com",12 , 30 , TextArea.SCROLLBARS_NONE);
taAbout.setBackground(Color.yellow);
taAbout.setFont (new Font ("Helvetica", Font.BOLD, frame12.FONT_SIZE));
w.add ("Center", taAbout);
btnOKWindow = new Button ("Click to close");
w.add ("South", btnOKWindow);
w.setVisible(true);
}

//-------------------------------------//
// end of About //
//-------------------------------------//
// check if Help //
/
//-------------------------------------//

if ("Help".equals (obj))

{
MyFrame mf ;
mf = new MyFrame() ;
MyDialog d;
MyWindow w;
Button btnOKDialog;
Button btnOKWindow;

w = new MyWindow (mf);


w.setBounds (300, 40, 450, 500);

TextArea taHelp = new TextArea("Wed 16 Dec 2009 07:20:53 AM EST\n frame1 HELP
updated: April 30 1999\n___________________\n\nWhat this program does\n\n Opens a file,\nReads
the contents line by line\ndisplays the lines in a lst
box\n\n\n\n\n\nmbspringer133@gmail.com\n\n\nmark burns springer\ndeacons folly\nnorth harwich,
ma. 02645" ,6 , 20 , TextArea.SCROLLBARS_BOTH);
taHelp.setBackground(Color.yellow);
taHelp.setFont (new Font ("Helvetica", Font.PLAIN, frame12.FONT_SIZE));
w.add ("Center", taHelp);
btnOKWindow = new Button ("Click to close");
btnOKWindow.setFont (new Font ("Helvetica", Font.BOLD, frame12.FONT_SIZE));
w.add ("South", btnOKWindow);
w.setVisible(true);
}

//-------------------------------------//
// END OF HELP //
/
//-------------------------------------//
rreturn (true);

//-------------------------------------------------------------------//
} // <======== end of public boolean action (Event evt, Object obj ) //
//-------------------------------------------------------------------//

//-------------------------------------------------------------------//
// start of public boolean handleEvent (Event evt) //
//-------------------------------------------------------------------//
public boolean handleEvent (Event evt)
{

//-------------------------------------//
// start of list //
/
//-------------------------------------//

if (evt.id == Event.LIST_SELECT)

{
// frame12.select_Item( evt );
}

//-------------------------------------//
// end of list //
/
//-------------------------------------//

if (evt.id == Event.WINDOW_DESTROY)
{
System.exit (0);
}
return (super.handleEvent (evt));
}

//-------------------------------------------------------------------//
} // <======== end of public boolean handleEvent (Event evt) //
//-------------------------------------------------------------------//

//
//--------------------------------------------------------
/
//

class MyDialog extends Dialog


{
public MyDialog (Frame fr, String s, boolean bModal)
{
super (fr, s, bModal);
}
public boolean handleEvent (Event evt)
{
Label l;

switch (evt.id)
{
case Event.WINDOW_DESTROY: // Close from System Menu
this.dispose ();
break;

case Event.ACTION_EVENT:
if ("Click to close".equals (evt.arg)) // Dialog's OK Button
{
this.dispose ();
}
break;
}
return (super.handleEvent (evt));
}
}

//
//----------------------------
/
//

class MyWindow extends Window


{
public MyWindow (Frame fr)
{
super (fr);
}

public boolean handleEvent (Event evt)


{
Label l;

switch (evt.id)
{
case Event.WINDOW_DESTROY: // Close from System Menu
this.dispose ();
break;

case Event.ACTION_EVENT:
if ("Click to close".equals (evt.arg)) // Window's OK Button
{
this.dispose ();
}
break;
}
return (super.handleEvent (evt));
}
}

Вам также может понравиться