本文整理匯總了Java中javax.swing.JDialog.getPreferredSize方法的典型用法代碼示例。如果您正苦於以下問題:Java JDialog.getPreferredSize方法的具體用法?Java JDialog.getPreferredSize怎麽用?Java JDialog.getPreferredSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JDialog
的用法示例。
在下文中一共展示了JDialog.getPreferredSize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: actionPerformed
import javax.swing.JDialog; //導入方法依賴的package包/類
public void actionPerformed( final ActionEvent e ) {
String command = e.getActionCommand();
if ( COMMAND_OK.equals( command ) ) {
// Call the OK option listener
ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() {
public Object run() {
okOptionListener.actionPerformed( e ); // XXX maybe create new event
actionPerformed(e, categories);
return null;
}
});
final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(CustomizerDialog.class, "LBL_Saving_Project_data_progress"));
JComponent component = ProgressHandleFactory.createProgressComponent(handle);
Frame mainWindow = WindowManager.getDefault().getMainWindow();
final JDialog dialog = new JDialog(mainWindow,
NbBundle.getMessage(CustomizerDialog.class, "LBL_Saving_Project_data"), true);
SavingProjectDataPanel panel = new SavingProjectDataPanel(component);
dialog.getContentPane().add(panel);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.pack();
Rectangle bounds = mainWindow.getBounds();
int middleX = bounds.x + bounds.width / 2;
int middleY = bounds.y + bounds.height / 2;
Dimension size = dialog.getPreferredSize();
dialog.setBounds(middleX - size.width / 2, middleY - size.height / 2, size.width, size.height);
// Call storeListeners out of AWT EQ
RequestProcessor.getDefault().post(new Runnable() {
@Override
public void run() {
try {
ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() {
@Override
public Object run() {
FileUtil.runAtomicAction(new Runnable() {
@Override
public void run() {
handle.start();
if (storeListener != null) {
storeListener.actionPerformed(e);
}
storePerformed(e, categories);
// #97998 related
saveModifiedProject();
}
});
return null;
}
});
} finally {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
dialog.setVisible(false);
dialog.dispose();
}
});
}
}
});
dialog.setVisible(true);
}
}