1 19 20 21 package org.netbeans.modules.properties; 22 23 import java.awt.event.KeyEvent ; 24 import java.awt.event.KeyAdapter ; 25 import java.awt.ContainerOrderFocusTraversalPolicy ; 26 import javax.swing.JButton ; 27 import javax.swing.JCheckBox ; 28 import javax.swing.JComboBox ; 29 30 import org.openide.util.NbBundle; 31 32 33 38 public class FindPanel extends javax.swing.JPanel { 39 40 41 public FindPanel() { 42 initComponents (); 43 initAccessibility (); 44 findCombo.getEditor().getEditorComponent().addKeyListener(new KeyAdapter () { 45 public void keyTyped(KeyEvent evt) { 46 if (evt.getKeyChar() == '\n') { 47 findButton.doClick(20); 48 evt.consume(); 49 } 50 } 51 }); 52 } 53 54 private String getBundleString(String s){ 55 return NbBundle.getMessage(FindPanel.class, s); 56 } 57 58 60 61 public JButton [] getButtons() { 62 return new JButton [] { findButton, cancelButton}; 63 } 64 65 66 public JComboBox getComboBox() { 67 return findCombo; 68 } 69 70 71 public JCheckBox getHighlightCheck() { 72 return highlightCheck; 73 } 74 75 76 public JCheckBox getMatchCaseCheck() { 77 return matchCaseCheck; 78 } 79 80 81 public JCheckBox getBackwardCheck() { 82 return backwardCheck; 83 } 84 85 86 public JCheckBox getWrapCheck() { 87 return wrapCheck; 88 } 89 90 91 public JCheckBox getRowCheck() { 92 return rowCheck; 93 } 94 95 private void initAccessibility () { 96 this.getAccessibleContext().setAccessibleDescription(getBundleString("ACS_FindPanel")); 97 98 findButton.getAccessibleContext().setAccessibleDescription(getBundleString("ACS_CTL_Find")); 99 rowCheck.getAccessibleContext().setAccessibleDescription(getBundleString("ACS_CTL_SearchByRows")); 100 wrapCheck.getAccessibleContext().setAccessibleDescription(getBundleString("ACS_CTL_WrapSearch")); 101 matchCaseCheck.getAccessibleContext().setAccessibleDescription(getBundleString("ACS_CTL_MatchCaseCheck")); 102 cancelButton.getAccessibleContext().setAccessibleDescription(getBundleString("ACS_CTL_Cancel")); 103 backwardCheck.getAccessibleContext().setAccessibleDescription(getBundleString("ACS_CTL_BackwardCheck")); 104 findCombo.getAccessibleContext().setAccessibleDescription(getBundleString("ACS_CTL_FindCombo")); 105 highlightCheck.getAccessibleContext().setAccessibleDescription(getBundleString("ACS_CTL_HighlightCheck")); 106 107 } 108 109 114 private void initComponents() { 116 java.awt.GridBagConstraints gridBagConstraints; 117 118 findLabel = new javax.swing.JLabel (); 119 findCombo = new javax.swing.JComboBox (); 120 highlightCheck = new javax.swing.JCheckBox (); 121 matchCaseCheck = new javax.swing.JCheckBox (); 122 backwardCheck = new javax.swing.JCheckBox (); 123 wrapCheck = new javax.swing.JCheckBox (); 124 rowCheck = new javax.swing.JCheckBox (); 125 findButton = new javax.swing.JButton (); 126 cancelButton = new javax.swing.JButton (); 127 128 setFocusCycleRoot(true); 129 setFocusTraversalPolicy(new ContainerOrderFocusTraversalPolicy ()); 130 setLayout(new java.awt.GridBagLayout ()); 131 132 findLabel.setLabelFor(findCombo); 133 org.openide.awt.Mnemonics.setLocalizedText(findLabel, getBundleString("LBL_Find")); findLabel.setFocusable(false); 135 gridBagConstraints = new java.awt.GridBagConstraints (); 136 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 137 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 138 add(findLabel, gridBagConstraints); 139 140 findCombo.setEditable(true); 141 gridBagConstraints = new java.awt.GridBagConstraints (); 142 gridBagConstraints.gridx = 1; 143 gridBagConstraints.gridy = 0; 144 gridBagConstraints.gridwidth = 2; 145 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 146 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 147 gridBagConstraints.weightx = 1.0; 148 gridBagConstraints.insets = new java.awt.Insets (12, 11, 0, 0); 149 add(findCombo, gridBagConstraints); 150 151 org.openide.awt.Mnemonics.setLocalizedText(highlightCheck, getBundleString("CTL_HighlightCheck")); gridBagConstraints = new java.awt.GridBagConstraints (); 153 gridBagConstraints.gridx = 0; 154 gridBagConstraints.gridy = 1; 155 gridBagConstraints.gridwidth = 2; 156 gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; 157 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 158 add(highlightCheck, gridBagConstraints); 159 160 org.openide.awt.Mnemonics.setLocalizedText(matchCaseCheck, getBundleString("CTL_MatchCaseCheck")); gridBagConstraints = new java.awt.GridBagConstraints (); 162 gridBagConstraints.gridx = 0; 163 gridBagConstraints.gridy = 2; 164 gridBagConstraints.gridwidth = 2; 165 gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; 166 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 167 add(matchCaseCheck, gridBagConstraints); 168 169 org.openide.awt.Mnemonics.setLocalizedText(backwardCheck, getBundleString("CTL_BackwardCheck")); gridBagConstraints = new java.awt.GridBagConstraints (); 171 gridBagConstraints.gridx = 0; 172 gridBagConstraints.gridy = 3; 173 gridBagConstraints.gridwidth = 2; 174 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 175 gridBagConstraints.insets = new java.awt.Insets (0, 12, 11, 0); 176 add(backwardCheck, gridBagConstraints); 177 178 org.openide.awt.Mnemonics.setLocalizedText(wrapCheck, getBundleString("CTL_WrapSearch")); gridBagConstraints = new java.awt.GridBagConstraints (); 180 gridBagConstraints.gridx = 2; 181 gridBagConstraints.gridy = 1; 182 gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; 183 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 184 add(wrapCheck, gridBagConstraints); 185 186 org.openide.awt.Mnemonics.setLocalizedText(rowCheck, getBundleString("CTL_SearchByRows")); gridBagConstraints = new java.awt.GridBagConstraints (); 188 gridBagConstraints.gridx = 2; 189 gridBagConstraints.gridy = 2; 190 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 191 gridBagConstraints.insets = new java.awt.Insets (0, 11, 0, 0); 192 add(rowCheck, gridBagConstraints); 193 194 findButton.setText(getBundleString("CTL_Find")); gridBagConstraints = new java.awt.GridBagConstraints (); 196 gridBagConstraints.gridx = 3; 197 gridBagConstraints.gridy = 0; 198 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 199 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 200 gridBagConstraints.insets = new java.awt.Insets (12, 11, 0, 11); 201 add(findButton, gridBagConstraints); 202 203 cancelButton.setText(getBundleString("CTL_Cancel")); gridBagConstraints = new java.awt.GridBagConstraints (); 205 gridBagConstraints.gridx = 3; 206 gridBagConstraints.gridy = 1; 207 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 208 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST; 209 gridBagConstraints.insets = new java.awt.Insets (5, 11, 0, 11); 210 add(cancelButton, gridBagConstraints); 211 } 213 public boolean requestFocusInWindow() { 214 return findCombo.requestFocusInWindow(); 215 } 216 217 private javax.swing.JCheckBox backwardCheck; 219 private javax.swing.JButton cancelButton; 220 private javax.swing.JButton findButton; 221 private javax.swing.JComboBox findCombo; 222 private javax.swing.JLabel findLabel; 223 private javax.swing.JCheckBox highlightCheck; 224 private javax.swing.JCheckBox matchCaseCheck; 225 private javax.swing.JCheckBox rowCheck; 226 private javax.swing.JCheckBox wrapCheck; 227 229 } 230 | Popular Tags |