June 2002
Beginner to intermediate
640 pages
14h 24m
English
To see how easy it is to use the Java APIs, follow along with this interactive session. Import two classes from the Java package javax.swing: JFrame and JButton. (We'll cover these classes in depth in Chapter 13.)
>>> from javax.swing import JFrame, JButton
Create an instance of each.
>>> frame = JFrame()
>>> button = JButton("Hello Java APIs")
(Note that you create Java instances and Python instances in the same way.)
Add the button instance to the content pane.
>>> pane = frame.getContentPane() # get access to the content pane >>> pane.add(button) # add the button to the content pane javax.swing.JButton ...
Pack the components in the frame.
>>> frame.pack()
Make the frame visible.
>>> frame.visible = 1 # make the ...
Read now
Unlock full access