Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Applets
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Java
»
Applets
Where dose JSException come from?
Kidd He
,
Ranch Hand
Jan 15, 2007 05:20:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
I make
applet
communication with javascript.
java
code:
import java.awt.Color; import java.awt.Container; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JApplet; import javax.swing.JLabel; import javax.swing.JTextField; import netscape.javascript.JSObject; public class AppletToJs extends JApplet { public void init() { final JLabel labInfo = new JLabel("input text and press ENTER"); labInfo.setForeground(Color.WHITE); final JTextField txtMessage = new JTextField(20); Container contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()); contentPane.setBackground(Color.BLACK); txtMessage.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { Object[] args = {txtMessage.getText()}; JSObject window= JSObject.getWindow(AppletToJs.this); window.call("setHtml",args); } }); contentPane.add(labInfo); contentPane.add(txtMessage); } }
the html:
<html> <head> <script language="javascript"> function setHtml(message) { document.AppletToJsForm.message.value = message; } </script> </head> <body> <center> <applet code="AppletToJs.class" width="400" height="100"> </applet><p> <form name="AppletToJsForm"> <input name="message" type="text" size="30" value="Applet' input"> </form> </center> </body> </html>
I compile the java code with any error or exception, but when I run the html page, inputing a
word
in the applet and pressing Enter, throwing a exception :
Exception in thread "AWT-EventQueue-2" netscape.javascript.JSException at netscape.javascript.JSObject.getWindow(Unknown Source) at AppletToJs$1.actionPerformed(AppletToJs.java:27) at javax.swing.JTextField.fireActionPerformed(Unknown Source) at javax.swing.JTextField.postActionEvent(Unknown Source) at javax.swing.JTextField$NotifyAction.actionPerformed(Unknown Source) at javax.swing.SwingUtilities.notifyAction(Unknown Source) at javax.swing.JComponent.processKeyBinding(Unknown Source) at javax.swing.JComponent.processKeyBindings(Unknown Source) at javax.swing.JComponent.processKeyEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
Why?Thanks!
Ulf Dittmer
,
Rancher
Jan 22, 2007 09:07:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
If you catch that exception in the applet, what does its getMessage method return?
Post by:
autobot
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
This thread has been viewed 2689 times.
Similar Threads
Exception trying to play audio file
Getting parameters from the htmp page
null pointer?
WAMP/Java/MysqlConnector Issue
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:10:25
.