/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The {@code PrintingStatus} provides a dialog that displays progress
* of the printing job and provides a way to abort it
* <p/>
* Methods of these class are thread safe, although most Swing methods
* are not. Please see
* to Use Threads</A> for more information.
*
* @author Alexander Potochkin
* @since 1.6
*/
public class PrintingStatus {
// the action that will abort printing
// update the status abortDialog to indicate aborting
abortButton.setEnabled(false);
// cancel the PrinterJob
}
}
};
}
};
/**
* Creates PrintingStatus instance
*
* @param parent a <code>Component</code> object to be used
* as parent component for PrintingStatus dialog
* @param job a <code>PrinterJob</code> object to be cancelled
* using this <code>PrintingStatus</code> dialog
* @return a <code>PrintingStatus</code> object
*/
public static PrintingStatus
}
}
private void init() {
// prepare the status JOptionPane
// this one's a MessageFormat since it must include the page
// number in its text
statusFormat = new MessageFormat(
int abortMnemonic =
int abortMnemonicIndex =
if (abortMnemonic != -1) {
}
if (abortMnemonicIndex != -1) {
}
// The dialog should be centered over the viewport if the table is in one
} else {
}
// clicking the X button should not hide the dialog
}
/**
* Shows PrintingStatus dialog.
* if dialog is modal this method returns only
* after <code>dispose()</code> was called otherwise returns immediately
*
* @param isModal <code>true</code> this dialog should be modal;
* <code>false</code> otherwise.
* @see #dispose
*/
if (SwingUtilities.isEventDispatchThread()) {
} else {
try {
public void run() {
}
});
} catch(InterruptedException e) {
throw new RuntimeException(e);
} catch(InvocationTargetException e) {
if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
} else {
throw new RuntimeException(cause);
}
}
}
}
/**
* The EDT part of the showModal method.
*
* This method is to be called on the EDT only.
*/
assert SwingUtilities.isEventDispatchThread();
init();
abortDialog.setVisible(true);
}
/**
* Disposes modal PrintingStatus dialog
*
* @see #showModal(boolean)
*/
public void dispose() {
if (SwingUtilities.isEventDispatchThread()) {
disposeOnEDT();
} else {
public void run() {
disposeOnEDT();
}
});
}
}
/**
* The EDT part of the dispose method.
*
* This method is to be called on the EDT only.
*/
private void disposeOnEDT() {
assert SwingUtilities.isEventDispatchThread();
if (abortDialog != null) {
abortDialog = null;
}
}
/**
* Returns whether the printng was aborted using this PrintingStatus
*
* @return whether the printng was aborted using this PrintingStatus
*/
public boolean isAborted() {
}
/**
* Returns printable which is used to track the current page being
* printed in this PrintingStatus
*
* @param printable to be used to create notification printable
* @return printable which is used to track the current page being
* printed in this PrintingStatus
* @throws NullPointerException if <code>printable</code> is <code>null</code>
*/
return new NotificationPrintable(printable);
}
throw new NullPointerException("Printable is null");
}
this.printDelegatee = delegatee;
}
throws PrinterException {
final int retVal =
if (SwingUtilities.isEventDispatchThread()) {
} else {
public void run() {
}
});
}
}
return retVal;
}
/**
* The EDT part of the print method.
*
* This method is to be called on the EDT only.
*/
assert SwingUtilities.isEventDispatchThread();
}
}
/**
* Duplicated from UIManager to make it visible
*/
}
try {
} catch(NumberFormatException nfe) {
}
}
return defaultValue;
}
}