So I'm playing around with Jython, trying to slap together a generic GUI. Nothing beyond what they have on the Jython Wiki for swing examples. So I declare a JFrame, and then try to add a panel, some text fields, all that good stuff. I get this error when I run it, however. "'NoneType' object has no attribute 'add'"
Here's the basic code I have.
from javax.swing import *
frame = JFrame('E-mail Gathering', defaultCloseOperation = JFrame.EXIT_ON_CLOSE, size =(600,400), locationRelativeTo = None).setVisible(True)
pnl = JPanel()
frame.add(pnl)
self.textfield1 = JTextField('username:',15)
pnl.add(self.textfield1)
self.textfield2 = JTextField('password:', 15)
pnl.add(self.textfield2)
mailButton = JButton('Login',actionPerformed=self.checkmail)
pnl.add(mailButton)
frame.pack()
frame.setVisible(True)
I know the relevant part where it's crashing is at 'frame.add(pnl)' with the aforementioned error. I figured I'd throw the rest up there just in case I'm making some even greater mistakes. I feel like something's wrong where I'm not declaring frame as a JFrame properly, but I know that's not the case because it creates the frame just fine if I don't try to add anything to it.
Thanks for any advice or suggestions you have.