sheettest.java
来自「oraily的Swing hacks code」· Java 代码 · 共 47 行
JAVA
47 行
import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.beans.*;public class SheetTest extends Object implements PropertyChangeListener { JOptionPane optionPane; AniSheetableJFrame frame; public static void main (String[] args) { new SheetTest(); } public SheetTest () { frame = new AniSheetableJFrame ("Animated 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); } public void propertyChange (PropertyChangeEvent pce) { if (pce.getPropertyName().equals (JOptionPane.VALUE_PROPERTY)) { System.out.println ("Selected option " + pce.getNewValue()); frame.hideSheet(); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?