home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-02 | 3.8 KB | 120 lines |
- import java.awt.*;
- import java.awt.event.*;
- import java.io.StringReader;
-
- import ice.htmlbrowser.*;
-
- public class DocView extends Frame
- implements WindowListener, ActionListener {
-
- protected Document doc = null;
- protected TextArea ta = null;
- protected TextField db = null;
- protected Button btnUpdate = null;
-
- public static void main(String[] args) {
- new DocView();
- }
-
- public DocView()
- {
- super("HTML Document Test");
-
- setSize( 650, 500 );
- setBackground( new Color( 192, 192, 192 ) );
- setResizable( true );
-
- addWindowListener( this );
-
- makeGUI();
- this.show();
- }
-
-
-
- public void actionPerformed(ActionEvent event) {
- String command = event.getActionCommand();
- if(command.equals("Update")) btClicked();
- }
-
- private void btClicked() {
- doc.htmlClear();
-
- try {
- doc.setDocumentBaseString(db.getText());
- }
- catch (java.net.MalformedURLException m) {
- String msg ="<b>Bad URL for document base "+db.getText()+"</b><br>";
- doc.htmlAppend(msg);
- doc.htmlWait(false);
- }
-
- doc.htmlAppend(ta.getText());
- doc.htmlWait(false);
- }
-
- Panel containerPanel = new Panel();
-
- private void makeGUI()
- {
- containerPanel.setLayout( null );
-
- doc = new Document();
-
- doc.setBounds( new Rectangle( new Dimension( 431, 195 ) ) );
- doc.setLocation( 77, 10 );
- containerPanel.add( doc );
- doc.setBackground( new Color( 192, 192, 192 ) );
- doc.setForeground( new Color( 0, 0, 0 ) );
- doc.setEnabled( true );
- doc.setVisible( true );
-
- ta = new TextArea( "", 0, 20 );
- ta.setBounds( new Rectangle( new Dimension( 431, 195 ) ) );
- ta.setLocation( 77, 225 );
- containerPanel.add( ta );
- ta.setBackground( new Color( 192, 192, 192 ) );
- ta.setForeground( new Color( 0, 0, 0 ) );
- ta.setEnabled( true );
- ta.setVisible( true );
-
- Label dbl = new Label("Document base:");
- dbl.setBounds( new Rectangle( new Dimension( 150, 15 ) ) );
- dbl.setLocation( 77, 435 );
- containerPanel.add( dbl );
- dbl.setVisible( true );
-
- db = new TextField("http://",140);
- db.setBounds( new Rectangle( new Dimension( 281, 30 ) ) );
- db.setLocation( 77+150, 430 );
- containerPanel.add( db );
-
- db.setBackground( new Color( 192, 192, 192 ) );
- db.setForeground( new Color( 0, 0, 0 ) );
- db.setEnabled( true );
- db.setVisible( true );
-
-
- btnUpdate = new Button( "Update" );
- btnUpdate.setBounds( new Rectangle( new Dimension( 106, 23 ) ) );
- btnUpdate.setLocation( 532, 397 );
- containerPanel.add( btnUpdate );
- btnUpdate.setBackground( new Color( 192, 192, 192 ) );
- btnUpdate.setForeground( new Color( 0, 0, 0 ) );
- btnUpdate.setEnabled( true );
- btnUpdate.setVisible( true );
- btnUpdate.addActionListener(this);
- add( containerPanel );
- }
-
- public void windowClosing( WindowEvent event ) { dispose(); }
- public void windowOpened( WindowEvent event ) {}
- public void windowIconified( WindowEvent event ) {}
- public void windowDeiconified( WindowEvent event ) {}
- public void windowClosed( WindowEvent event ) { System.exit(0);}
- public void windowActivated( WindowEvent event ) {}
- public void windowDeactivated( WindowEvent event ) {}
- }
-
-
-