diff --git a/plugin/oji/MRJ/testing/TrivialApplet/MyApplet.mcp b/plugin/oji/MRJ/testing/TrivialApplet/MyApplet.mcp new file mode 100644 index 000000000000..847310e56bf5 Binary files /dev/null and b/plugin/oji/MRJ/testing/TrivialApplet/MyApplet.mcp differ diff --git a/plugin/oji/MRJ/testing/TrivialApplet/TrivialApplet.html b/plugin/oji/MRJ/testing/TrivialApplet/TrivialApplet.html new file mode 100644 index 000000000000..452f02b9d834 --- /dev/null +++ b/plugin/oji/MRJ/testing/TrivialApplet/TrivialApplet.html @@ -0,0 +1,68 @@ + + +TrivialApplet + + + + + + +

+ + + +

+ +
+ +The source. + +
+ +

+ + + + + +

+ +
+ + + diff --git a/plugin/oji/MRJ/testing/TrivialApplet/TrivialApplet.java b/plugin/oji/MRJ/testing/TrivialApplet/TrivialApplet.java new file mode 100644 index 000000000000..9595f747e0cf --- /dev/null +++ b/plugin/oji/MRJ/testing/TrivialApplet/TrivialApplet.java @@ -0,0 +1,183 @@ +/* + Trivial applet that displays a string - 4/96 PNL +*/ + +import java.awt.*; +import java.awt.event.*; +import java.applet.Applet; +import java.net.URL; +import java.net.MalformedURLException; + +import netscape.javascript.JSObject; + +class AboutBox extends Frame { + AboutBox(Menu aboutMenu, ActionListener[] actionListeners) { + super("About This Applet"); + + addWindowListener( + new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + } + }); + + Button okButton = new Button("OK"); + okButton.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + + // Annoying use of flow layout managers. + Panel labelPanel = new Panel(); + Panel buttonPanel = new Panel(); + + labelPanel.add(new Label("This applet's about box...")); + buttonPanel.add(okButton); + + add(labelPanel, "North"); + add(buttonPanel, "Center"); + + // test menu bar stuff. + MenuBar menuBar = new MenuBar(); + aboutMenu = (Menu) cloneMenu(aboutMenu); + for (int i = 0; i < actionListeners.length; i++) + aboutMenu.getItem(i).addActionListener(actionListeners[i]); + menuBar.add(aboutMenu); + setMenuBar(menuBar); + + pack(); + show(); + } + + private MenuItem cloneMenu(MenuItem oldItem) { + if (oldItem instanceof Menu) { + Menu oldMenu = (Menu) oldItem; + Menu newMenu = new Menu(oldMenu.getLabel()); + int count = oldMenu.getItemCount(); + for (int i = 0; i < count; i++) { + newMenu.add(cloneMenu(oldMenu.getItem(i))); + } + return newMenu; + } else { + MenuItem newItem = new MenuItem(oldItem.getLabel()); + return newItem; + } + } +} + +class ExceptionThread extends Thread { + ExceptionThread() { + start(); + } + + public void run() { + throw new Error("this is an error!"); + } +} + +public class TrivialApplet extends Applet { + public Button goButton; + public Button aboutButton; + public TextField urlField; + public Menu aboutMenu; + public ActionListener[] actionListeners; + private static int appletCount; + + public void init() { + ++appletCount; + + goButton = new Button("Go"); + aboutButton = new Button("About"); + + String urlText = getParameter("URL"); + if (urlText == null) + urlText = "http://www.apple.com"; + + urlField = new TextField(urlText); + + ActionListener goListener = + new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + URL apple = new URL(urlField.getText()); + getAppletContext().showDocument(apple, "Apple!"); + } catch (MalformedURLException mfue) { + } + } + }; + + ActionListener aboutListener = + new ActionListener() { + public void actionPerformed(ActionEvent e) { + new AboutBox(aboutMenu, actionListeners); + } + }; + + goButton.addActionListener(goListener); + aboutButton.addActionListener(aboutListener); + + add(goButton); + add(aboutButton); + add(urlField); + + // Try a pop-up menu, and a menu in the menubar. + PopupMenu contextMenu = new PopupMenu(); + aboutMenu = new Menu("About"); + + contextMenu.add(newItem("About", aboutListener)); + aboutMenu.add(newItem("About", aboutListener)); + + contextMenu.add(newItem("Go", goListener)); + aboutMenu.add(newItem("Go", goListener)); + + ActionListener errorListener = new ActionListener() { + public void actionPerformed(ActionEvent e) { + new ExceptionThread(); + } + }; + contextMenu.add(newItem("Error", errorListener)); + aboutMenu.add(newItem("Error", errorListener)); + + ActionListener[] listeners = { aboutListener, goListener, errorListener }; + actionListeners = listeners; + + add(contextMenu); + } + + private MenuItem newItem(String title, ActionListener listener) { + MenuItem item = new MenuItem(title); + item.addActionListener(listener); + return item; + } + + private Frame getFrame() { + Component p = this; + while (p != null && !(p instanceof Frame)) + p = getParent(); + return (Frame)p; + } + + // public void paint( Graphics g ) {} + + public boolean mouseEnter(Event evt, int x, int y) { + showStatus("Welcome!"); + return true; + } + + public boolean mouseExit(Event evt, int x, int y) { + showStatus("See you later!"); + return true; + } + + public void print(String message) { + JSObject window = JSObject.getWindow(this); + Object[] args = { message }; + window.call("println", args); + } + + public int getAppletCount() { + return appletCount; + } +} diff --git a/plugin/oji/MRJ/testing/TrivialApplet/TrivialApplets.html b/plugin/oji/MRJ/testing/TrivialApplet/TrivialApplets.html new file mode 100644 index 000000000000..6321529d7da1 --- /dev/null +++ b/plugin/oji/MRJ/testing/TrivialApplet/TrivialApplets.html @@ -0,0 +1,77 @@ + + +TrivialApplets + + + + + + +
+ + + + + +
+ + + + + +
+ +

+The source. +

+ +
+ + + + + + + +
+ + +