import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class FindDialog2 extends KDialog {
    JLabel       findLabel   = new JLabel("Find:");
    JTextField   findText    = new JTextField();
    JCheckBox    caseCheck   = new JCheckBox("Match Case");
    JCheckBox    wordCheck   = new JCheckBox("Whole Word");
    JRadioButton topRadio    = new JRadioButton("Start at Top");
    JRadioButton wrapRadio   = new JRadioButton("Wrap Around");
    JButton      findButton  = new JButton("Find");
    JButton      closeButton = new JButton("Close");

    public static void main(String[] args) {
        JDialog dialog = new FindDialog2(new Frame(), "Find Dialog 2", true);
        dialog.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent event) { System.exit(0); }
        });
        dialog.setVisible(true);
        System.exit(0);
    }

    public FindDialog2(Frame owner, String title, boolean modal) {
        super(owner, title, modal);

        closeButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                setVisible(false);
            }
        });

        layoutComponents();

        pack();                               // Pack things neatly before showing

        setLocationRelativeTo(owner);         // Center the dialog over its owner
    }

    private void layoutComponents() {
        Container content = getContentPane(); // Take advantage of the BorderLayout

        content.add(createVerticalStrut(13), BorderLayout.NORTH);
        content.add(createVerticalStrut(10), BorderLayout.SOUTH);
        content.add(createHorizontalStrut(11), BorderLayout.WEST);
        content.add(createHorizontalStrut(10), BorderLayout.EAST);
        content.add(createMainBox());
    }
    
    private Box createMainBox() {
        Box box = Box.createVerticalBox();    // Try a simple vertical box

        box.add(findLabel);
        box.add(findText);
        box.add(caseCheck);
        box.add(wordCheck);
        box.add(topRadio);
        box.add(wrapRadio);
        box.add(findButton);
        box.add(closeButton);

        return box;
    }
}



