本文整理匯總了Java中javax.swing.SwingUtilities.notifyAction方法的典型用法代碼示例。如果您正苦於以下問題:Java SwingUtilities.notifyAction方法的具體用法?Java SwingUtilities.notifyAction怎麽用?Java SwingUtilities.notifyAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.SwingUtilities
的用法示例。
在下文中一共展示了SwingUtilities.notifyAction方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testActionNotification
import javax.swing.SwingUtilities; //導入方法依賴的package包/類
private static void testActionNotification() {
KeyEvent keyEvent = new KeyEvent(new JLabel("Test"), 0, 0, 0, 0, 'A');
SenderObject rejectedSenderObject = new SenderObject();
SwingUtilities.notifyAction(new TestAction(false), null, keyEvent,
rejectedSenderObject, 0);
if (rejectedSenderObject.accepted) {
throw new RuntimeException("The sender is incorrectly accepted!");
}
if (rejectedSenderObject.performed) {
throw new RuntimeException("The action is incorrectly performed!");
}
SenderObject acceptedSenderObject = new SenderObject();
SwingUtilities.notifyAction(new TestAction(true), null, keyEvent,
acceptedSenderObject, 0);
if (!acceptedSenderObject.accepted) {
throw new RuntimeException("The sender is not accepted!");
}
if (!acceptedSenderObject.performed) {
throw new RuntimeException("The action is not performed!");
}
}