|

Email me
Site in English
Site en Français
| |
Class ThreadLauncherDialog
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--java.awt.Window
|
+--java.awt.Dialog
|
+--ThreadLauncherDialog
- public class ThreadLauncherDialog
- extends java.awt.Dialog
- implements java.awt.event.ActionListener
This class creates a Dialog containing a single Cancel button and
launches a thread. This thread can be stopped by the Cancel button.
Exemple of use: while loading a big file, or while doing lots of computing.
Requirements: Java 1.1
Warning: this class calls the method Thread.stop(). One should be aware that this
method is deprecated in Java 1.2. It would therefore be wise to change this call
to a direct call to a specific method in the task.
Please report any bug/enhancement proposal to the author.
** See http://www.chez.com/elefevre
for updates and more Java stuff to download. **
- Version:
- v1.0.1, 15 Nov 1998:
- new constructor added, without the parameter that concerns the label on the button
- cosmetic modifications in the documentation
- the go() method is renamed show(). Therefore, it now overrides the usual show() method.
v1.0, 21 Nov 1997.
- Author:
- Eric Lefevre (e-mail: eric.lefevre@usa.net)
- See Also:
- Serialized Form
| Inner classes inherited from class java.awt.Component |
java.awt.Component.AWTTreeLock |
|
Field Summary |
private java.awt.Button |
cancelButton
The Cancel Button. |
private java.lang.Thread |
theThreadToRun
The Thread containing the action to execute. |
| Fields inherited from class java.awt.Dialog |
base,
keepBlocking,
modal,
nameCounter,
resizable,
serialVersionUID,
title |
| Fields inherited from class java.awt.Window |
active,
base,
focusMgr,
inputContext,
nameCounter,
OPENED,
ownedWindowList,
serialVersionUID,
state,
warningString,
weakThis,
windowListener,
windowSerializedDataVersion |
| Fields inherited from class java.awt.Container |
component,
containerListener,
containerSerializedDataVersion,
dispatcher,
layoutMgr,
maxSize,
ncomponents,
serialVersionUID |
| Fields inherited from class java.awt.Component |
actionListenerK,
adjustmentListenerK,
appContext,
assert,
background,
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
changeSupport,
componentListener,
componentListenerK,
componentOrientation,
componentSerializedDataVersion,
containerListenerK,
cursor,
dropTarget,
enabled,
eventMask,
focusListener,
focusListenerK,
font,
foreground,
hasFocus,
height,
incRate,
inputMethodListener,
inputMethodListenerK,
isInc,
isPacked,
itemListenerK,
keyListener,
keyListenerK,
LEFT_ALIGNMENT,
locale,
LOCK,
minSize,
mouseListener,
mouseListenerK,
mouseMotionListener,
mouseMotionListenerK,
name,
nameExplicitlySet,
newEventsOnly,
ownedWindowK,
parent,
peer,
peerFont,
popups,
prefSize,
RIGHT_ALIGNMENT,
serialVersionUID,
textListenerK,
TOP_ALIGNMENT,
valid,
visible,
width,
windowListenerK,
x,
y |
|
Constructor Summary |
ThreadLauncherDialog(java.awt.Frame parent,
java.lang.String title,
java.lang.String message,
java.lang.Runnable taskToLaunch)
Constructs a dialog box containing a Cancel Button and launches a Thread. |
ThreadLauncherDialog(java.awt.Frame parent,
java.lang.String title,
java.lang.String message,
java.lang.String cancelLabel,
java.lang.Runnable taskToLaunch)
Constructs a dialog box containing a Cancel Button and launches a Thread. |
|
Method Summary |
void |
actionPerformed(java.awt.event.ActionEvent event)
Tests if the Cancel Button has been clicked. |
void |
show()
Shows the dialog box and launches the thread. |
| Methods inherited from class java.awt.Dialog |
,
addNotify,
conditionalShow,
constructComponentName,
dispose,
getTitle,
hide,
hideAndDisposeHandler,
initIDs,
isModal,
isResizable,
paramString,
setModal,
setResizable,
setTitle |
| Methods inherited from class java.awt.Window |
addOwnedWindow,
addWindowListener,
applyResourceBundle,
applyResourceBundle,
connectOwnedWindow,
dispatchEventImpl,
eventEnabled,
finalize,
getFocusOwner,
getInputContext,
getLocale,
getOwnedWindows,
getOwner,
getToolkit,
getWarningString,
isActive,
isShowing,
nextFocus,
ownedInit,
pack,
postEvent,
postProcessKeyEvent,
postWindowEvent,
preProcessKeyEvent,
processEvent,
processWindowEvent,
readObject,
removeOwnedWindow,
removeWindowListener,
setCursor,
setFocusOwner,
setWarningString,
toBack,
toFront,
transferFocus,
writeObject |
| Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
applyOrientation,
countComponents,
deliverEvent,
dispatchEventToSelf,
doLayout,
findComponentAt,
findComponentAt,
getAlignmentX,
getAlignmentY,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents_NoClientCode,
getComponents,
getCursorTarget,
getInsets,
getLayout,
getMaximumSize,
getMinimumSize,
getMouseEventTarget,
getPreferredSize,
getWindow,
insets,
invalidate,
invalidateTree,
isAncestorOf,
layout,
lightweightPrint,
list,
list,
locate,
minimumSize,
paint,
paintComponents,
postsOldMouseEvents,
preferredSize,
print,
printComponents,
printOneComponent,
processContainerEvent,
proxyEnableEvents,
proxyRequestFocus,
remove,
remove,
removeAll,
removeContainerListener,
removeNotify,
setFont,
setLayout,
update,
updateCursor,
validate,
validateTree |
| Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addPropertyChangeListener,
addPropertyChangeListener,
areInputMethodsEnabled,
bounds,
checkImage,
checkImage,
coalesceEvents,
contains,
contains,
createImage,
createImage,
disable,
disableEvents,
dispatchEvent,
enable,
enable,
enableEvents,
enableInputMethods,
firePropertyChange,
getBackground,
getBounds,
getBounds,
getColorModel,
getComponentOrientation,
getCursor,
getDropTarget,
getFont_NoClientCode,
getFont,
getFontMetrics,
getForeground,
getGraphics,
getHeight,
getInputMethodRequests,
getIntrinsicCursor,
getLocation,
getLocation,
getLocationOnScreen,
getName,
getNativeContainer,
getParent_NoClientCode,
getParent,
getPeer,
getSize,
getSize,
getToolkitImpl,
getTreeLock,
getWidth,
getWindowForObject,
getX,
getY,
gotFocus,
handleEvent,
hasFocus,
imageUpdate,
inside,
isDisplayable,
isDoubleBuffered,
isEnabled,
isEnabledImpl,
isFocusTraversable,
isLightweight,
isOpaque,
isValid,
isVisible,
keyDown,
keyUp,
list,
list,
list,
location,
lostFocus,
mouseDown,
mouseDrag,
mouseEnter,
mouseExit,
mouseMove,
mouseUp,
move,
nextFocus,
paintAll,
prepareImage,
prepareImage,
printAll,
processComponentEvent,
processFocusEvent,
processInputMethodEvent,
processKeyEvent,
processMouseEvent,
processMouseMotionEvent,
remove,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removePropertyChangeListener,
removePropertyChangeListener,
repaint,
repaint,
repaint,
repaint,
requestFocus,
reshape,
resize,
resize,
setBackground,
setBounds,
setBounds,
setComponentOrientation,
setDropTarget,
setEnabled,
setForeground,
setLocale,
setLocation,
setLocation,
setName,
setSize,
setSize,
setVisible,
show,
size,
toString,
transferFocus |
| Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
theThreadToRun
private java.lang.Thread theThreadToRun
- The Thread containing the action to execute.
cancelButton
private java.awt.Button cancelButton
- The Cancel Button.
ThreadLauncherDialog
public ThreadLauncherDialog(java.awt.Frame parent,
java.lang.String title,
java.lang.String message,
java.lang.String cancelLabel,
java.lang.Runnable taskToLaunch)
- Constructs a dialog box containing a Cancel Button and launches a Thread.
- Parameters:
title - the text in the title barmessage - the text in the dialog boxcancelLabel - the label on the Cancel ButtontaskToLaunch - the task that we want to run in the background
ThreadLauncherDialog
public ThreadLauncherDialog(java.awt.Frame parent,
java.lang.String title,
java.lang.String message,
java.lang.Runnable taskToLaunch)
- Constructs a dialog box containing a Cancel Button and launches a Thread. The label
on the button is "Cancel" by default.
- Parameters:
title - the text in the title barmessage - the text in the dialog boxtaskToLaunch - the task that we want to run in the background
show
public void show()
- Shows the dialog box and launches the thread.
- Overrides:
- show in class java.awt.Dialog
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent event)
- Tests if the Cancel Button has been clicked.
In that case, stops the thread and closes the dialog box.
- Specified by:
- actionPerformed in interface java.awt.event.ActionListener
|