From: <pi...@hu...> - 2001-04-30 16:08:18
|
Any thougts on the best way to bind events? I'm working with a form that has two text fields and a button; eventually it's going to be a login form. For the button I'm using: btnLogin = java.awt.Button("Login", actionPerformed=processLogin(txtLoginID.text, txtPasswd.txt)) When I have any type of parameters for processLogin it dies on me with (I didn't paste the entire traceback): java.lang.ArrayIndexOutOfBoundsException If I place 'actionPerformed=processLogin("test")' it prints out "test" when the program starts and does nothing when the button is pressed. When I place 'processLogin' by itself the method is invoded, however it has no way of knowing about the values in the login method (where the form is created). I have some buttons and menu items on other forms that don't need to pass parameters and they work fine. Does anyone know of a better way to pass this information? Thanks for any help, Wayne Free, encrypted, secure Web-based email at www.hushmail.com |
From: Glen S. <gl...@en...> - 2001-04-30 16:30:11
|
O > Any thougts on the best way to bind events? > > I'm working with a form that has two text fields and a button; eventually > it's going to be a login form. For the button I'm using: > > btnLogin = java.awt.Button("Login", actionPerformed=processLogin(txtLoginID.text, > txtPasswd.txt)) Inherits from awt.Event.ActionListener in your class and implement the actionPerformed method... like... from java.awt import * from java.awt.event import * class LogonForm(ActionListener): def __init__(self): self.btnLogin = Button("Login") self.txtLoginID = TextField() self.txtPasswd = TextField() ..... (implenent the GUI, etc...) def actionPerformed(self, event): source = event.getSource() if source==self.Login: self.processLogin(self.txtLoginID.text, self.txtPasswd.text) else: #handle some other event... def processLogin(loginID, passwd): #do something... Hope that helps. -- Glen Starchman Enabled Ventures/Enabled Technology Group gl...@en... 206.234.7330 |