Object+Oriented+Programming+using+JAVA+02

Object+Oriented+Programming+using+JAVA+02 - Chapter 6...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter 6 Graphical User Interfaces in J AVA Contents 6.1 Introduction: The Modern User Interface . . . . . . . . . . . . . 106 6.2 The Basic GUI Application . . . . . . . . . . . . . . . . . . . . . . . 107 6.2.1 JFrame and JPanel . . . . . . . . . . . . . . . . . . . . . . . . . 109 6.2.2 Components and Layout . . . . . . . . . . . . . . . . . . . . . . 111 6.2.3 Events and Listeners . . . . . . . . . . . . . . . . . . . . . . . . 112 6.3 Applets and HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 6.3.1 JApplet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 6.3.2 Reusing Your JPanels . . . . . . . . . . . . . . . . . . . . . . . . 115 6.3.3 Applets on Web Pages . . . . . . . . . . . . . . . . . . . . . . . 117 6.4 Graphics and Painting . . . . . . . . . . . . . . . . . . . . . . . . . . 119 6.4.1 Coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 6.4.2 Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 6.4.3 Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 6.4.4 Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 6.4.5 An Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 6.5 Mouse Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 6.5.1 Event Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 6.5.2 MouseEvent and MouseListener . . . . . . . . . . . . . . . . . 131 6.5.3 Anonymous Event Handlers . . . . . . . . . . . . . . . . . . . . 134 6.6 Basic Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 6.6.1 JButton . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 6.6.2 JLabel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 6.6.3 JCheckBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 6.6.4 JTextField and JTextArea . . . . . . . . . . . . . . . . . . . . . 141 6.7 Basic Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 6.7.1 Basic Layout Managers . . . . . . . . . . . . . . . . . . . . . . 144 6.7.2 A Simple Calculator . . . . . . . . . . . . . . . . . . . . . . . . 146 6.7.3 A Little Card Game . . . . . . . . . . . . . . . . . . . . . . . . . 148 105 6.8 Images and Resources . . . . . . . . . . . . . . . . . . . . . . . . . . 152 6.8.1 Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 6.8.2 Image File I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 6.1 Introduction: The Modern User Interface WHEN COMPUTERS WERE FIRST INTRODUCED , ordinary people,including most program- mers, couldn’t get near them. They were locked up in rooms with white-coated at- tendants who would take your programs and data, feed them to the computer, and return the computer’s response some time later. When timesharing – where the com- puter switches its attention rapidly from one person to another – was invented in the 1960s, it became possible for several people to interact directly with the computer...
View Full Document

This document was uploaded on 08/10/2011.

Page1 / 117

Object+Oriented+Programming+using+JAVA+02 - Chapter 6...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online