Subj : Re: AWT Event handling in Rhino To : mcbridematt From : Igor Bukanov Date : Wed Apr 23 2003 12:14 pm mcbridematt wrote: > Hello, > > I'm working on the new Jazilla branch (Jazilla-NG/based on jXUL) and > when I created a "File -> Open Web Location" clone, I wondered how can > I capture text from the text field when I can't access it from the > event handler. Anyway, this is my code: > > function openURL() { > frame = Packages.javax.swing.JFrame(); > frame.setTitle("Go to URL"); > URLField = Packages.javax.swing.JTextField("http://typeinaurlinthistextfield"); > GoTo = Packages.javax.swing.JButton("Go"); > panel = Packages.javax.swing.JPanel(); > panel.add(new Packages.javax.swing.JLabel("Type in a URL, or a > chrome resource")); > panel.add(URLField); > panel.add(GoTo); > frame.getContentPane().add(panel); > frame.setSize(new Packages.java.awt.Dimension(400,100)); > frame.setVisible(true); > } > Now, If I create an ActionListener against GoTo, I have a problem, I > can't call URLField.getText()?. Can someone tell me how to do this? How exactly do you need to create action listener? If from the script, then I think closure is your friend: var URLField = Packages.javax.swing.JTextField(""); var GoTo = Packages.javax.swing.JButton("Go"); var l = { actionPerformed: function() { use URLField }}; GoTo.addActionListener(new java.awt.event.ActionListener(l)) .... Regards, Igor .