@@ -55,6 +55,14 @@ public class QuickFindDialog extends JDialog implements DocumentListener, Action
5555 protected JCheckBox regexCheckBox ;
5656 protected JCheckBox wrapCheckBox ;
5757
58+ protected String prev = "prev" ;
59+ protected String next = "next" ;
60+ protected String componentName = "QuickFindDialog" ;
61+ protected String ignoreCase = "Ignore case" ;
62+ protected String useRegex = "Use regex" ;
63+ protected String wrap = "Wrap" ;
64+ protected String notFound = "Not found" ;
65+
5866 public QuickFindDialog (JTextComponent target ) {
5967 this (target , DocumentSearchData .getFromEditor (target ));
6068 }
@@ -124,15 +132,14 @@ protected void initComponents() {
124132 JToolBar toolBar = new JToolBar ();
125133 this .statusLabel = new JLabel ();
126134 this .searchField = new JTextField ();
127- this .prevButton = new JButton (" prev" );
128- this .nextButton = new JButton (" next" );
129- this .ignoreCaseCheckBox = new JCheckBox ();
130- this .regexCheckBox = new JCheckBox ();
131- this .wrapCheckBox = new JCheckBox ();
135+ this .prevButton = new JButton (this . prev );
136+ this .nextButton = new JButton (this . next );
137+ this .ignoreCaseCheckBox = new JCheckBox (this . ignoreCase );
138+ this .regexCheckBox = new JCheckBox (this . useRegex );
139+ this .wrapCheckBox = new JCheckBox (this . wrap );
132140
133141 this .setDefaultCloseOperation (WindowConstants .DISPOSE_ON_CLOSE );
134142 this .setBackground (Color .DARK_GRAY );
135- this .setName ("QuickFindDialog" );
136143 this .setResizable (false );
137144 this .setUndecorated (true );
138145
@@ -165,29 +172,27 @@ protected void initComponents() {
165172
166173 toolBar .addSeparator ();
167174
168- this .ignoreCaseCheckBox .setText ("Ignore case" );
169175 this .ignoreCaseCheckBox .setFocusable (false );
170176 this .ignoreCaseCheckBox .setOpaque (false );
171177 this .ignoreCaseCheckBox .setVerticalTextPosition (SwingConstants .BOTTOM );
172178 this .ignoreCaseCheckBox .addActionListener (this );
173179 toolBar .add (this .ignoreCaseCheckBox );
174180
175- this .regexCheckBox .setText ("Use regex" );
176181 this .regexCheckBox .setFocusable (false );
177182 this .regexCheckBox .setOpaque (false );
178183 this .regexCheckBox .setVerticalTextPosition (SwingConstants .BOTTOM );
179184 this .regexCheckBox .addActionListener (this );
180185 toolBar .add (this .regexCheckBox );
181186
182- this .wrapCheckBox .setText ("Wrap" );
183187 this .wrapCheckBox .setFocusable (false );
184188 this .wrapCheckBox .setOpaque (false );
185189 this .wrapCheckBox .setVerticalTextPosition (SwingConstants .BOTTOM );
186190 this .wrapCheckBox .addActionListener (this );
187191 toolBar .add (this .wrapCheckBox );
188192
189- this .statusLabel .setFont (this .statusLabel .getFont ().deriveFont (this .statusLabel .getFont ().getStyle () | Font .BOLD , this . statusLabel . getFont (). getSize () - 2 ));
193+ this .statusLabel .setFont (this .statusLabel .getFont ().deriveFont (this .statusLabel .getFont ().getStyle () | Font .BOLD ));
190194 this .statusLabel .setForeground (Color .RED );
195+ toolBar .addSeparator ();
191196 toolBar .add (this .statusLabel );
192197
193198 GroupLayout layout = new GroupLayout (this .getContentPane ());
@@ -197,6 +202,16 @@ protected void initComponents() {
197202 layout .setVerticalGroup (layout .createParallelGroup (GroupLayout .Alignment .LEADING )
198203 .addComponent (toolBar , GroupLayout .PREFERRED_SIZE , GroupLayout .DEFAULT_SIZE , GroupLayout .PREFERRED_SIZE ));
199204
205+ this .translate ();
206+ }
207+
208+ protected void translate () {
209+ this .nextButton .setText (this .next );
210+ this .prevButton .setText (this .prev );
211+ this .setName (this .componentName );
212+ this .ignoreCaseCheckBox .setText (this .ignoreCase );
213+ this .regexCheckBox .setText (this .useRegex );
214+ this .wrapCheckBox .setText (this .wrap );
200215 this .pack ();
201216 }
202217
@@ -208,7 +223,7 @@ private void prevButtonActionPerformed(ActionEvent e) {
208223 this .prevCaretPos = caretPos ;
209224 this .fixOverlappedCaret ();
210225 } else {
211- this .statusLabel .setText ("QuickFindDialog.NotFound" );
226+ this .statusLabel .setText (this . notFound );
212227 }
213228 }
214229
@@ -220,7 +235,7 @@ private void nextButtonActionPerformed(ActionEvent e) {
220235 this .prevCaretPos = caretPos ;
221236 this .fixOverlappedCaret ();
222237 } else {
223- this .statusLabel .setText ("QuickFindDialog.NotFound" );
238+ this .statusLabel .setText (this . notFound );
224239 }
225240 }
226241
@@ -259,7 +274,7 @@ private void updateFind() {
259274 DocumentSearchData searchData = this .searchData .get ();
260275 String searchText = this .searchField .getText ();
261276
262- if (searchText == null || searchText .isEmpty ()) {
277+ if (searchText == null || searchText .isEmpty () || target == null || searchData == null ) {
263278 this .statusLabel .setText (null );
264279 return ;
265280 }
@@ -273,7 +288,7 @@ private void updateFind() {
273288 // so we need to relocate to our saved pos before we call doFindNext
274289 target .setCaretPosition (this .prevCaretPos );
275290 if (!searchData .doFindNext (target )) {
276- this .statusLabel .setText ("QuickFindDialog.NotFound" );
291+ this .statusLabel .setText (this . notFound );
277292 } else {
278293 this .statusLabel .setText (null );
279294 }
0 commit comments