June 2002
Beginner to intermediate
640 pages
14h 24m
English
Theory is good, but we need to put some code behind these abstract concepts. The following example, from GridBag.py, takes us step by step through the layout of components with GridBagLayout. At first we'll use only buttons; then we'll graduate to other components such as text fields and labels. To start, import the classes needed.
>>> from javax.swing import JButton, JTextField, JFrame, JButton, JPanel, JLabel
>>> from java.awt import GridBagLayout, GridBagConstraints
Define a helper function for creating GridBagConstraints. If you're following along in the interactive interpreter, enter from GridBag import makeConstraint.
def makeConstraint() gridx=0, gridy=0, # Holds the x, y cell location in the grid ...
Read now
Unlock full access