home *** CD-ROM | disk | FTP | other *** search
- package netscape.applet;
-
- import java.awt.Button;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.Frame;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Insets;
- import java.awt.TextArea;
- import java.awt.Window;
-
- class ConsoleFrame extends Frame {
- Console console;
- TextArea text;
- Button reset;
- Button hide;
-
- ConsoleFrame(Console console) {
- this.console = console;
- ((Frame)this).setTitle("Java Console");
- GridBagLayout gb = new GridBagLayout();
- ((Container)this).setLayout(gb);
- this.text = new TextArea(20, 60);
- this.text.setEditable(false);
- GridBagConstraints c1 = new GridBagConstraints();
- c1.fill = 1;
- c1.weightx = (double)1.0F;
- c1.weighty = (double)1.0F;
- c1.gridwidth = 0;
- gb.setConstraints(this.text, c1);
- ((Container)this).add(this.text);
- HorizontalRule hr = new HorizontalRule();
- GridBagConstraints c2 = new GridBagConstraints();
- c2.fill = 2;
- c2.weightx = (double)1.0F;
- c2.insets = new Insets(1, 1, 0, 0);
- c2.gridwidth = 0;
- gb.setConstraints(hr, c2);
- ((Container)this).add(hr);
- this.reset = new Button("Clear");
- GridBagConstraints c3 = new GridBagConstraints();
- c3.insets = new Insets(4, 0, 2, 4);
- c3.anchor = 13;
- gb.setConstraints(this.reset, c3);
- ((Container)this).add(this.reset);
- this.hide = new Button("Close");
- GridBagConstraints c4 = new GridBagConstraints();
- c4.insets = new Insets(4, 0, 2, 4);
- c4.anchor = 13;
- gb.setConstraints(this.hide, c4);
- ((Container)this).add(this.hide);
- ((Window)this).pack();
- }
-
- public boolean handleEvent(Event evt) {
- if (evt.id != 201 && (evt.target != this.hide || evt.id != 1001)) {
- if (evt.target == this.reset && evt.id == 1001) {
- this.console.reset();
- return true;
- } else {
- return super.handleEvent(evt);
- }
- } else {
- this.console.hide();
- return true;
- }
- }
-
- public boolean keyDown(Event evt, int key) {
- if (key >= 48 && key <= 57) {
- MozillaAppletContext.debug = key - 48;
- System.err.println("# Applet debug level set to " + MozillaAppletContext.debug);
- return true;
- } else if (key != 100 && key != 68) {
- if (key != 103 && key != 71) {
- if (key != 102 && key != 70) {
- return super.keyDown(evt, key);
- } else {
- System.err.println("# Performing finalization...");
- System.runFinalization();
- return true;
- }
- } else {
- System.err.println("# Performing a garbage collection...");
- System.gc();
- return true;
- }
- } else {
- MozillaAppletContext.dumpState(System.err);
- return true;
- }
- }
-
- void reset() {
- this.text.setText("");
- }
- }
-