Docsity

Swing: A Comprehensive Tutorial on Java's Platform Independent GUI Framework, Study notes of Design

Partial preview of the text

Download Swing: A Comprehensive Tutorial on Java's Platform Independent GUI Framework and more Study notes Design in PDF only on Docsity!

Poelman & Associates, Inc. (c) 2003

Swing

A Quick Tutorial on Programming

Swing Applications

Poelman & Associates, Inc. (c) 2003

MVC – Model View Controller

• Swing is based on this design pattern• It means separating the implementation of

an application into layers or components:– The

Model

- the data structure that

represents something (like a customer inforec)

– The

Controller

- the user interface logic for

manipulating it

– The

View

- the display of that data structure to

the user.

Poelman & Associates, Inc. (c) 2003

Swing

• Visible “widgets” - windows, buttons,

combo boxes, trees, tables, checkboxes,text fields, menus, …

• Containers of components – applets,

dialogs, windows and frames

• Supporting classes and utility methods

Poelman & Associates, Inc. (c) 2003

Some important Swing visible

component classes

•^

JApplet **

-^

JButton

-^

JCheckBox

-^

JColorChooser

-^

JComboBox

-^

JDialog **

-^

JFileChooser

-^

JFormattedTextField

-^

JFrame **

-^

JLabel

-^

JList

-^

JMenu

-^

JMenuBar

-^

JMenuItem

-^

JPanel

•^

JPasswordField

-^

JPopupMenu

-^

JProgressBar

-^

JRadioButton

-^

JScrollBar

-^

JSlider

-^

JSpinner

-^

JTable

-^

JTextArea

-^

JTextField

-^

JToggleButton

-^

JToolBar

-^

JTree

-^

JWindow **

-^

** means a top level containers

Poelman & Associates, Inc. (c) 2003

adding fields

  • Poelman & Associates, Inc. (c)

Poelman & Associates, Inc. (c) 2003

code created

Poelman & Associates, Inc. (c) 2003

To kill a zombie or running process in

netbeans right click and choose: ”terminate”

Poelman & Associates, Inc. (c) 2003

Editing a dialog

St

select a layout manager for the dialog

Poelman & Associates, Inc. (c) 2003

select component edit properties

Poelman & Associates, Inc. (c) 2003

what layout manager should I

use?

• Start with the absolute and then

experiment when you feel comfortable (orhire a graphic artist and let them worryabout it ;-).

Poelman & Associates, Inc. (c) 2003

Adding other components to the

view - JTextFields

Poelman & Associates, Inc. (c) 2003

Adding a combo box

Poelman & Associates, Inc. (c) 2003

edit the model property for the

combo box

type in stateabbreviationsseparatedby commas