The Swing Text Components
Despite all the complexity and power Swing’s text components provide, it’s still pretty simple to do most things. Figure 19-1 shows each of the six Swing text components, plus an extra JTextArea (to show a different wrapping style) and an extra JEditorPane (to show a different EditorKit).
here the code:
// TextComponentSampler.java
//
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.border.*;
import java.awt.*;
public [...]
The JFileChooser Class
The application itself reports only which file (or files, if you use the Open option) you chose to open or save. Our application has a Pick Directory button that restricts the chooser to directories. The event handlers for each button do most of the interesting work. In each case, we create a new JFileChooser object, [...]
Simple Drop Out
import javax.swing.*;
import java.awt.event.*;
import java.awt.dnd.*;
import java.awt.datatransfer.*;
import java.io.*;
public class UberHandler extends TransferHandler {
JTextArea output;
public void TransferHandler( ) { }
public boolean canImport(JComponent dest, DataFlavor[] flavors) {
// You bet we can!
return true;
}
public boolean importData(JComponent src, Transferable transferable) {
[...]

