June 2002
Beginner to intermediate
640 pages
14h 24m
English
Now let's create a GUI based on our prototype in both Jython and Java. The following example shows our Python employee form; after that is its Java equivalent.
Python:
from javax.swing import JFrame, JButton, JTextField, JLabel, JPanel from string import split from pawt import GridBag from Employee import Employee class EmployeeForm(JFrame): def __init__(self): JFrame.__init__(self, "Employee Form") pane = JPanel() self.contentPane.add(pane) bag = GridBag(pane) #Create a name and id text field. self.__name = JTextField(25) self.__id = JTextField(10) #Create and add a "Name" and "ID" label. name = JLabel("Name", labelFor=self.__name, displayedMnemonic=ord('N')) bag.add(name) id = JLabel("ID", labelFor=self.__id, displayedMnemonic=ord('I')) ...Read now
Unlock full access