- Shopping Bag ( 0 items )
The Swing classes eliminate Java's biggest weakness: its relatively primitive user interface toolkit. Swing provides many new components and containers that allow you to build sophisticated user interfaces, far beyond what was possible with AWT. The old components have been greatly improved, and there are many new components, like trees, tables, and even text editors. It also adds several completely new features to Java's user interface capabilities: drag-and-drop, undo, and the ability to develop your own "look ...
Ships from: fallbrook, CA
Usually ships in 1-2 business days
Ships from: acton, MA
Usually ships in 1-2 business days
Ships from: Grand Rapids, MI
Usually ships in 1-2 business days
The Swing classes eliminate Java's biggest weakness: its relatively primitive user interface toolkit. Swing provides many new components and containers that allow you to build sophisticated user interfaces, far beyond what was possible with AWT. The old components have been greatly improved, and there are many new components, like trees, tables, and even text editors. It also adds several completely new features to Java's user interface capabilities: drag-and-drop, undo, and the ability to develop your own "look and feel," or the ability to choose between several standard looks. The Swing components are all "lightweight," and therefore provide more uniform behavior across platforms, making it easier to test your software.All these new features mean that there's a lot to learn. Swing is undoubtedly way ahead of AWT — or, for that matter, any widely available user interface toolkit — but it's also a lot more complicated. It's still easy to do simple things. But once you've seen what's possible, you won't want to do the simple things.Java Swing gives you in-depth coverage of everything you need to know to take full advantage of Swing, providing detailed descriptions of every class and interface in the key Swing packages. It shows you how to use all of the new components, allowing you to build state-of-the-art user interfaces. It also discusses how the components implement the MVC (Model View Controller) architecture, so you can understand how the components are designed and subclass them intelligently. Finally, it shows how to create your own "look and feel." Throughout, Java Swing focuses on giving you the context you need to understand what you're doing. It's more than documentation; Java Swing helps you develop code quickly and effectively.Whether you're a serious Java developer, or just trying to find out what Java can do, you'll find Java Swing an indispensable guide.
"Swing," the user interface components of the Java Foundation Classes (JFC), is quickly revolutionizing user interface development. This publication provides both an excellent reference and a complete tutorial for the Swing component set. Based on Java 1.1 and 1.2 beta 4 JFC, it details UI development, the model delegate architecture and all data models. To derive the most benefit from this reference, you should be familiar with the Java language, programming concepts, inner classes and the Java 1.1 event model.
In this chapter, we'll look at a collection of classes Swing provides to allow you to create this type of application in Java. At the end of the chapter, we'll provide a large sample program that shows how to implement a variety of useful features.
A JInternalFrame is a container that looks much like a JFrame. The key difference is that internal frames can only exist within some other Java container. JInternalFrame implements the following six interfaces: Accessible, MouseListener, MouseMotionListener, WindowConstants, RootPaneContainer, ComponentListener.
Each internal frame keeps a reference to an instance of the static inner class called JDesktopIcon. Like real frames, JInternalFrames can be iconified. JDesktop Icon is the class responsible for taking the place of the frame when it gets iconified.
Though it is not required, JInternalFrames are typically used inside of a JDesktopPane. JDesktopPane is an extension of JLayeredPane that adds direct support for managing a collection of JInternalFrames in layers. JDesktopPane uses an object called a DesktopManager to control how different behavior, like iconification or maximization, is carried out. A default implementation of this interface, DefaultDesktopManager, is provided. We'll see how all of this functionality is broken out as we cover the various classes and interfaces involved.
One more thing to notice about Figure 9-1 is that JInternalFrame supports a new type of listener called InternalFrameListener. This interface contains methods that match those defined by the AWT WindowListener class, but have slightly different names and take InternalFrameEvents, rather than WindowEvents, as input.
There's quite a lot to discuss about JInternalFrames, but most of their power comes when they are used inside a JDesktopPane. In this section, we will give a quick overview of the properties, constructors, and methods available in JInternalFrame, but we'll leave the more detailed discussion of using internal frames to the sections that follow.
The accessibleContext property is as expected. The background and foreground properties are delegated to the frame's content pane.
There are three pairs of properties that indicate whether or not something can be done to a frame and whether or not that thing is currently done to the frame.
Table 9-1. JInternalFrame Properties
They are: closable/closed, iconifiable/icon, and maximizable/maximum. Note that closed, icon, and maximum are constrained properties.
The contentPane, glassPane, layeredPane, and menuBar properties come from the RootPaneContainer interface and are taken directly from the frame's JRootPane. The rootPane property is set to a new JRootPane when the frame is constructed.
The value of the defaultCloseOperation property defaults to Windowconstants.HIDE_ON_CLOSE. This implies that when the frame is closed, its setClosed ( ) method will be called. The frame could be reopened at a later time.
The desktopIcon reflects how the frame will be displayed when iconified. A JDesktopIcon (which leaves the rendering to the L&F) is created for the frame when it is instantiated. The desktopPane property provides a convenient way to access the JDesktopPane containing the frame, if there is one.
FrameIcon is the icon painted inside the frame's titlebar (usually on the far left). By default, there is no icon. However, the basic look-and-feel checks to see if a frameIcon has been set and, if not, paints the 'Java cup" icon. This explains why an icon appears in the Windows L&F frame shown in Figure 9-2, but not in the others (which provide their own paint ( ) implementations, rather than using the one provided by the basic L&F).*
The layer property indicates the frame's current layer, if it has been placed in a JLayeredPane. The resizable property indicates whether or not the frame can be resized by dragging its edges or corners, and selected indicates whether or not the frame has been selected (this will typically determine the color of the titlebar). Note that selected is a constrained property. Title contains the string to appear on the titlebar.
The Ul property holds the current L&F implementation for the frame, and UIClassID reflects the class ID for internal frames.
Finally, the warningString property, which is always null, is used to specify the string that should appear in contexts where the frame might be insecure. This is the technique used by java.awt. Window to display a string like "Warning: Applet Window" when a Java window is displayed from an applet. Since JInternalFrames are always fully enclosed by some other top-level container, this property is always null. . . .
What This Book Covers;
About the Source Code;
Chapter 1: Introducing Swing;
1.1 What Is Swing?;
1.2 Swing Features;
1.3 Swing Packages and Classes;
1.4 The Model-View-Controller Architecture;
1.5 Working with Swing;
1.6 The Swing Set Demo;
1.7 Reading this Book;
Chapter 2: Jump Starting a Swing Application;
2.1 Upgrading Your Programs;
2.2 Beyond Buttons;
2.3 A Bigger Application;
Chapter 3: Swing Component Basics;
3.1 Understanding Actions;
3.2 Sending Change Events in Swing;
3.3 The JComponent Class;
Chapter 4: Labels and Icons;
Chapter 5: Buttons;
Chapter 6: Bounded Range Components;
6.1 The Bounded-Range Model;
6.2 The JScrollBar Class;
6.3 The JSlider Class;
6.4 The JProgressBar Class;
6.5 Monitoring Progress;
Chapter 7: Lists and Combo Boxes;
7.2 Representing List Data;
7.3 Handling Selections;
7.4 Displaying Cell Elements;
7.5 The JList Class;
7.6 Combo Boxes;
7.7 The JComboBox Class;
Chapter 8: Swing Containers;
8.1 A Simple Container;
8.2 Basic RootPaneContainers;
Chapter 9: Internal Frames;
9.1 Managing a Desktop;
9.2 Building a Desktop;
Chapter 10: Swing Dialogs;
10.1 The JDialog Class;
10.2 The JOptionPane Class;
Chapter 11: Specialty Panes and Layout Managers;
11.1 The JSplitPane Class;
11.2 The JScrollPane Class;
11.3 The JTabbedPane Class;
11.4 Layout Managers;
11.5 Other Panes;
Chapter 12: Chooser Dialogs;
12.1 The JFileChooser Class;
12.2 The File Chooser Package;
12.3 The Color Chooser;
12.4 The JColorChooser Class;
Chapter 13: Borders;
13.1 Introducing Borders;
13.2 Swing Borders;
13.3 The CompoundBorder Class;
13.4 Creating Your Own Border;
Chapter 14: Menus and Toolbars;
14.1 Introducing Swing Menus;
14.2 Menu Bar Selection Models;
14.3 The JMenuBar Class;
14.4 The JMenuItem Class;
14.5 The JPopupMenu Class;
14.6 The JMenu Class;
14.7 Selectable Menu Items;
Chapter 15: Tables;
15.1 Table Columns;
15.2 Table Data;
15.3 The JTable Class;
15.4 Editing and Rendering;
15.5 Selecting Table Entries;
Chapter 16: Advanced Table Examples;
16.1 A Table with Row Headers;
16.2 Large Tables with Paging;
16.3 Charting Data with a TableModel;
Chapter 17: Trees;
17.1 A Simple Tree;
17.2 Tree Models;
17.3 Tree Nodes and Paths;
17.4 The JTree Class;
17.5 Tree Selections;
17.6 Tree Events;
17.7 Rendering and Editing;
17.8 What Next?;
Chapter 18: Undo;
18.1 The Swing Undo Facility;
Chapter 19: Text 101;
19.1 The Swing Text Components;
19.2 More to Come;
Chapter 20: Document Model and Events;
20.1 The Document Model;
20.2 Document Events;
20.3 Advanced AbstractDocument Event Model;
Chapter 21: Styled Documents and JTextPane;
21.2 A Stylized Editor;
Chapter 22: Carets, Highlighters, and Keymaps;
22.1 JTextComponent UI Properties;
Chapter 23: Text Views;
23.1 Text Views;
23.2 The View Classes;
Chapter 24: EditorKits and TextActions;
24.1 Overview of the Editor Kits;
Chapter 25: Programming with Accessibility;
25.1 How Accessibility Works;
25.2 The Accessibility Package;
25.3 Other Accessible Objects;
25.4 The Six Types of Accessibility;
25.5 The Accessibility Utility Classes;
25.6 Interfacing with Accessibility;
Chapter 26: Look & Feel;
26.1 How Does It Work?;
26.2 Key L&F Classes and Interfaces;
26.3 The MultiLookAndFeel;
26.4 Look-and-Feel Customization;
26.5 Creation of a Custom L&F;
Chapter 27: Swing Utilities;
27.1 General Utilities;
27.2 Editing and Rendering Utilities;
27.3 Event Utilities;
27.4 Image Utilities;
Chapter 28: Swing Under the Hood;
28.1 Creating Your Own Component;
28.2 Working with Focus;
28.3 Lightweight vs. Heavyweight Components;
28.4 Multithreading Issues with Swing;
28.5 Painting and Repainting;
Look & Feel Resources;
Posted October 8, 2002
Posted April 4, 2001
There are some code errors in the first few programs that make them hard to understand. I had to go the the books website listing the errors to figure out what was wrong. Also, the author uses a lot of custom classes that implement or extend the java classes. This can be good or bad depending upon your skill level.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.