user interface design csci 201l jeffrey miller, ph.d. http :// www - scf. usc. edu /~ csci 201 usc...

Post on 17-Dec-2015

212 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

User Interface DesignCSCI 201L

Jeffrey Miller, Ph.D.

HTTP://WWW-SCF.USC.EDU/~CSCI201

USC CSCI 201L

Outline

USC CSCI 201L 2/22

▪ Java GUI Organization

Java Graphical Programming

▪ Java has two different frameworks for graphical user interfaces› Abstract Windows Toolkit (AWT)› Swing

▪ AWT uses heavyweight components that call into native operating system components› AWT components are in the java.awt package

▪ Swing uses lightweight components that are platform independent› Some Swing components can call into native OS components

for rendering windows and panels› Most Swing components start with a J and are in the

javax.swing package

USC CSCI 201L 3/22Java GUI Organization

Java GUI API

▪ The Java GUI API is split into the following groups› Component classes› Container classes› Helper classes

▪ Component classes are used for creating the user interface› JButton, JTextField, JLabel

▪ Container classes are used to contain and align other components› JFrame, JPanel

▪ Helper classes are used to support GUI components› Color, Font

USC CSCI 201L 4/22Java GUI Organization

Component Classes

▪ Component classes can be displayed in a user interface› They inherit from the javax.swing.JComponent class

▪ Here are the direct subclasses of JComponent› AbstractButton, BasicInternalFrameTitlePane, Box,

Box.Filler, JColorChooser, JComboBox, JFileChooser, JInternalFrame, JInternalFrame.JDesktopIcon, JLabel, JLayer, JLayeredPane, JList, JMenuBar, JOptionPane, JPanel, JPopupMenu, JProgressBar, JRootPane, JScrollBar, JScrollPane, JSeparator, JSlider, JSpinner, JSplitPane, JTabbedPane, JTable, JTableHeader, JTextComponent, JToolBar, JToolTip, JTree, JViewport

USC CSCI 201L 5/22Java GUI Organization

Container Classes

▪ Containers allow components to be added to them to be displayed› Containers can also have other containers added to them

▪ Containers are also components, so anywhere we can add a component, we could also add a container› java.awt.Container inherits from java.awt.Component

▪ Container classes include› JFrame› JPanel› JApplet› JDialog

USC CSCI 201L 6/22Java GUI Organization

Helper Classes

▪ Helper classes describe the properties of GUI components, such as graphics context, colors, fonts, and dimensions

▪ Helper classes include› java.awt.Graphics› java.awt.Color› java.awt.Font› java.awt.FontMetrics› java.awt.Dimension› java.awt.LayoutManager

▪ Note that the helper classes are in the java.awt package› Only the AWT components are heavyweight

USC CSCI 201L 7/22Java GUI Organization

top related