public class ReplaceDialog extends AbstractFindReplaceDialog
An application can use a ReplaceDialog as follows. It is suggested
that you create an Action or something similar to facilitate
"bringing up" the Replace dialog. Have the main application contain an object
that implements ActionListener. This object will receive the
following action events from the Replace dialog:
SearchEvent.Type.FIND action when the user clicks the
"Find" button.
SearchEvent.Type.REPLACE action
when the user clicks the "Replace" button.
SearchEvent.Type.REPLACE_ALL
action when the user clicks the "Replace All" button.
SearchEngine.find()
or
SearchEngine.replace()
to actually execute the search.javax.swing.JDialog.AccessibleJDialogjava.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityTypejava.awt.Window.AccessibleAWTWindow, java.awt.Window.Type| Modifier and Type | Field and Description |
|---|---|
protected SearchListener |
searchListener
Our search listener, cached so we can grab its selected text easily.
|
dirPanel, downButton, findFieldLabel, findNextButton, markAllCheckBox, SEARCH_DOWNWARD_PROPERTY, upButtoncancelButton, caseCheckBox, context, findTextCombo, regexCheckBox, searchConditionsPanel, wholeWordCheckBoxaccessibleContext, rootPane, rootPaneCheckingEnabledBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT| Constructor and Description |
|---|
ReplaceDialog(java.awt.Dialog owner,
SearchListener listener)
Creates a new
ReplaceDialog. |
ReplaceDialog(java.awt.Frame owner,
SearchListener listener)
Creates a new
ReplaceDialog. |
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Listens for action events in this dialog.
|
protected void |
escapePressed()
Called when the Escape key is pressed in this dialog.
|
java.lang.String |
getReplaceAllButtonText()
Returns the text on the "Replace All" button.
|
java.lang.String |
getReplaceButtonText()
Returns the text on the "Replace" button.
|
java.lang.String |
getReplaceString()
Returns the
java.lang.String to replace with. |
java.lang.String |
getReplaceWithLabelText()
Returns the label on the "Replace with" text field.
|
protected void |
handleRegExCheckBoxClicked()
Called when the regex checkbox is clicked.
|
protected void |
handleSearchContextPropertyChanged(java.beans.PropertyChangeEvent e)
Called whenever a property in the search context is modified.
|
protected FindReplaceButtonsEnableResult |
handleToggleButtons()
Returns whether any action-related buttons (Find Next, Replace, etc.)
should be enabled.
|
void |
setReplaceAllButtonText(java.lang.String text)
Sets the text on the "Replace All" button.
|
void |
setReplaceButtonText(java.lang.String text)
Sets the text on the "Replace" button.
|
void |
setReplaceString(java.lang.String newReplaceString)
Sets the
java.lang.String to replace with. |
void |
setReplaceWithLabelText(java.lang.String text)
Sets the label on the "Replace with" text field.
|
void |
setVisible(boolean visible)
Overrides
JDialog's setVisible method; decides
whether or not buttons are enabled. |
void |
updateUI()
This method should be called whenever the
LookAndFeel of
the application changes. |
addSearchListener, fireSearchEvent, getDownRadioButtonText, getFindButtonText, getFindWhatLabelText, getSearchButtonsBorderText, getUpRadioButtonText, refreshUIFromContext, removeSearchListener, setDownRadioButtonText, setFindButtonText, setFindWhatLabelText, setSearchButtonsBorderText, setUpRadioButtonTextcreateDefaultSearchContext, createTitledBorder, focusFindTextField, getBundle, getCancelButtonText, getContentAssistImage, getMatchCaseCheckboxText, getRegularExpressionCheckboxText, getSearchContext, getSearchString, getString, getWholeWordCheckboxText, isPreJava6JRE, isWholeWord, matchesSearchFor, requestFocus, setCancelButtonText, setMatchCaseCheckboxText, setRegularExpressionCheckboxText, setSearchContext, setSearchString, setWholeWordCheckboxTextsetEscapeClosesDialogaddImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, updateaddNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, show, toBackaddPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFrontadd, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleprotected SearchListener searchListener
public ReplaceDialog(java.awt.Dialog owner,
SearchListener listener)
ReplaceDialog.owner - The main window that owns this dialog.listener - The component that listens for SearchEvents.public ReplaceDialog(java.awt.Frame owner,
SearchListener listener)
ReplaceDialog.owner - The main window that owns this dialog.listener - The component that listens for SearchEvents.public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListeneractionPerformed in class AbstractFindReplaceDialoge - The event that occurred.protected void escapePressed()
EscapableDialogsetVisible(false);).escapePressed in class AbstractSearchDialogpublic final java.lang.String getReplaceButtonText()
setReplaceButtonText(java.lang.String)public final java.lang.String getReplaceAllButtonText()
setReplaceAllButtonText(java.lang.String)public java.lang.String getReplaceString()
java.lang.String to replace with.String the user wants to replace the text to
find with.public final java.lang.String getReplaceWithLabelText()
setReplaceWithLabelText(java.lang.String)protected void handleRegExCheckBoxClicked()
handleRegExCheckBoxClicked in class AbstractSearchDialogprotected void handleSearchContextPropertyChanged(java.beans.PropertyChangeEvent e)
AbstractFindReplaceDialoghandleSearchContextPropertyChanged in class AbstractFindReplaceDialoge - The property change event fired.protected FindReplaceButtonsEnableResult handleToggleButtons()
AbstractSearchDialoghandleToggleButtons in class AbstractFindReplaceDialogpublic final void setReplaceButtonText(java.lang.String text)
text - The text for the Replace button.getReplaceButtonText()public final void setReplaceAllButtonText(java.lang.String text)
text - The text for the Replace All button.getReplaceAllButtonText()public final void setReplaceWithLabelText(java.lang.String text)
text - The text for the "Replace with" text field's label.getReplaceWithLabelText()public void setReplaceString(java.lang.String newReplaceString)
java.lang.String to replace with.newReplaceString - The String to put into
the replace field.public void setVisible(boolean visible)
JDialog's setVisible method; decides
whether or not buttons are enabled.setVisible in class java.awt.Dialogvisible - Whether or not the dialog should be visible.public void updateUI()
LookAndFeel of
the application changes. This calls
SwingUtilities.updateComponentTreeUI(this) and does
other necessary things.
Note that this is not an override, as JDialogs don't have an
updateUI() method.