forked from pquiring/javaforce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindDialog.java
More file actions
executable file
·194 lines (175 loc) · 6.73 KB
/
Copy pathFindDialog.java
File metadata and controls
executable file
·194 lines (175 loc) · 6.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
* FindDialog.java
*
* Created on July 29, 2007, 4:04 PM
*/
package javaforce;
import javaforce.FindEvent;
import java.awt.event.KeyEvent;
/**
* Opens a find text dialog which uses FindEvent for callback handling.
*
* @author Peter Quiring
*/
public class FindDialog extends javax.swing.JDialog {
/**
* Creates new form FindDialog
*/
private FindDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
setTitle("Find");
setComponentOrientation(((parent == null) ? javax.swing.JOptionPane.getRootFrame() : parent).getComponentOrientation());
if (parent != null) {
setLocationRelativeTo(parent);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
text = new javax.swing.JTextField();
cbWhole = new javax.swing.JCheckBox();
cbCase = new javax.swing.JCheckBox();
find = new javax.swing.JButton();
cancel = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
anykey(evt);
}
});
jLabel1.setText("Find What:");
text.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
anykey(evt);
}
});
cbWhole.setMnemonic('w');
cbWhole.setText("Match whole word only");
cbWhole.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
cbWhole.setMargin(new java.awt.Insets(0, 0, 0, 0));
cbWhole.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
anykey(evt);
}
});
cbCase.setMnemonic('c');
cbCase.setText("Match case sensitive");
cbCase.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
cbCase.setMargin(new java.awt.Insets(0, 0, 0, 0));
cbCase.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
anykey(evt);
}
});
find.setText("Find");
find.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
findActionPerformed(evt);
}
});
find.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
anykey(evt);
}
});
cancel.setText("Cancel");
cancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelActionPerformed(evt);
}
});
cancel.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
anykey(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(text, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE))
.addComponent(cbWhole)
.addComponent(cbCase)
.addGroup(layout.createSequentialGroup()
.addComponent(find)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cancel)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbWhole)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbCase)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(find)
.addComponent(cancel))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void anykey(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_anykey
int keyCode = evt.getKeyCode();
int mods = evt.getModifiers();
if (keyCode == KeyEvent.VK_ESCAPE && mods == 0) {
cancelActionPerformed(null);
}
if (keyCode == KeyEvent.VK_ENTER && mods == 0) {
findActionPerformed(null);
}
}//GEN-LAST:event_anykey
private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
this.dispose();
}//GEN-LAST:event_cancelActionPerformed
private void findActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_findActionPerformed
fe.findEvent(this);
this.dispose();
}//GEN-LAST:event_findActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancel;
private javax.swing.JCheckBox cbCase;
private javax.swing.JCheckBox cbWhole;
private javax.swing.JButton find;
private javax.swing.JLabel jLabel1;
private javax.swing.JTextField text;
// End of variables declaration//GEN-END:variables
private FindEvent fe;
public String getText() {
return text.getText();
}
public boolean getWhole() {
return cbWhole.isSelected();
}
public boolean getCase() {
return cbCase.isSelected();
}
public static void showFindDialog(java.awt.Frame parent, boolean modular, String text, boolean bWhole, boolean bCase, FindEvent fe) {
FindDialog dialog = new FindDialog(parent, modular);
dialog.fe = fe;
dialog.text.setText(text);
dialog.cbWhole.setSelected(bWhole);
dialog.cbCase.setSelected(bCase);
dialog.text.selectAll();
dialog.setVisible(true);
}
}