FileDocCategorySizeDatePackage
SheetTest.javaAPI DocExample1482Mon Jan 09 11:02:00 GMT 2006None

SheetTest

public class SheetTest extends Object implements PropertyChangeListener

Fields Summary
JOptionPane
optionPane
SheetableJFrame
frame
Constructors Summary
public SheetTest()

        frame = new SheetableJFrame ("Sheet test");
        // put an image in the frame's content pane
        ImageIcon icon = new ImageIcon ("keagy-lunch.png");
        JLabel label = new JLabel (icon);
        frame.getContentPane().add(label);
        // build JOptionPane dialog and hold onto it
        optionPane = new JOptionPane ("Do you want to save?",
                                      JOptionPane.QUESTION_MESSAGE,
                                      JOptionPane.YES_NO_OPTION);
        frame.pack();
        frame.setVisible(true);
        optionPane.addPropertyChangeListener (this);
        // pause for effect, then show the sheet
        try {Thread.sleep(1000);}
        catch (InterruptedException ie) {}
        JDialog dialog = 
            optionPane.createDialog (frame, "irrelevant");
        frame.showJDialogAsSheet (dialog);
    
Methods Summary
public static voidmain(java.lang.String[] args)

        new SheetTest();
    
public voidpropertyChange(java.beans.PropertyChangeEvent pce)

        if (pce.getPropertyName().equals (JOptionPane.VALUE_PROPERTY)) {
            System.out.println ("Selected option " + 
                                pce.getNewValue());
            frame.hideSheet();
        }