20 package net.sf.gridarta.textedit.textarea.actions;
22 import java.awt.Container;
23 import java.awt.FlowLayout;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
26 import javax.swing.Box;
27 import javax.swing.BoxLayout;
28 import javax.swing.JButton;
29 import javax.swing.JDialog;
30 import javax.swing.JOptionPane;
31 import javax.swing.JPanel;
32 import javax.swing.JTextField;
33 import javax.swing.WindowConstants;
34 import javax.swing.text.JTextComponent;
40 import net.
sf.japi.swing.action.ActionBuilder;
41 import net.
sf.japi.swing.action.ActionBuilderFactory;
42 import net.
sf.japi.swing.action.ActionMethod;
43 import org.jetbrains.annotations.NotNull;
44 import org.jetbrains.annotations.Nullable;
50 public class Replace implements ActionListener {
56 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
76 pane.
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
78 pane.
dialog.setModal(
false);
79 pane.
dialog.setVisible(
true);
92 final int startPos = textArea.getCaretPosition();
93 final String text = textArea.getText();
94 final int foundIndex = text.indexOf(
textToFind, startPos + 1);
95 if (foundIndex == -1) {
102 textArea.select(foundIndex, foundIndex +
textToFind.length());
104 textArea.select(foundIndex, foundIndex +
textToReplace.length());
203 final JPanel replacePanel =
new JPanel();
204 replacePanel.setLayout(
new BoxLayout(replacePanel, BoxLayout.Y_AXIS));
207 final Container findTextPanel =
new JPanel(
new FlowLayout(FlowLayout.RIGHT));
212 replacePanel.add(findTextPanel);
213 replacePanel.add(Box.createVerticalStrut(5));
216 final Container replaceTextPanel =
new JPanel(
new FlowLayout(FlowLayout.RIGHT));
220 replacePanel.add(replaceTextPanel);
221 replacePanel.add(Box.createVerticalStrut(5));