246
247 private JButton createButton(String uiKey, String actionCommand, ActionListener l) {
248 JButton b = new JButton(i18n.getString(uiKey + ".btn"));
249 b.setName(uiKey);
250 b.setMnemonic(getMnemonic(uiKey));
251 b.setActionCommand(actionCommand);
252 b.addActionListener(l);
253 setToolTipText(b, uiKey);
254 //b.registerKeyboardAction(listener, actionCommand, enterKey, JComponent.WHEN_FOCUSED);
255 return b;
256 }
257
258 private JCheckBox createCheckBox(String uiKey) {
259 JCheckBox b = new JCheckBox(i18n.getString(uiKey + ".ckb"));
260 b.setName(uiKey);
261 b.setMnemonic(getMnemonic(uiKey));
262 setToolTipText(b, uiKey);
263 return b;
264 }
265
266 private JComboBox createChoice(final String uiKey, final String[] choiceKeys) {
267 // create a cache of the presentation string, for use when
268 // rendering, but otherwise, let the JComboBox work in terms of the
269 // choiceKeys
270 final String[] choices = new String[choiceKeys.length];
271 for (int i = 0; i < choices.length; i++)
272 choices[i] = i18n.getString(uiKey + "." + choiceKeys[i] + ".chc");
273
274 JComboBox<String> choice = new JComboBox<>(choiceKeys);
275 choice.setName(uiKey);
276 AccessibleContext ac = choice.getAccessibleContext();
277 ac.setAccessibleName(i18n.getString(uiKey + ".tip"));
278
279 choice.setRenderer(new DefaultListCellRenderer() {
280 public Component getListCellRendererComponent(JList list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
281 Object c = o;
282 for (int i = 0; i < choiceKeys.length; i++) {
283 if (choiceKeys[i] == o) {
284 c = choices[i];
285 break;
286 }
287 }
288 return super.getListCellRendererComponent(list, c, index, isSelected, cellHasFocus);
289 }
290 });
291
292 setToolTipText(choice, uiKey);
293 ac.setAccessibleDescription(choice.getToolTipText());
294 return choice;
295 }
296
297 private JLabel createLabel(String uiKey, boolean needMnemonic) {
298 JLabel l = new JLabel(i18n.getString(uiKey + ".lbl"));
299 l.setName(uiKey);
300 if (needMnemonic)
312 }
313
314 private ActionListener listener = new ActionListener() {
315 public void actionPerformed(ActionEvent e) {
316 String cmd = e.getActionCommand();
317 if (cmd.equals(FIND))
318 find();
319 else if (cmd.equals(CLOSE))
320 setVisible(false);
321 else if (cmd.equals(HELP)) {
322 helpBroker.displayCurrentID(helpPrefix + "search.csh");
323 }
324 }
325 };
326
327 private Interview interview;
328 private Question currentQuestion;
329 private HelpBroker helpBroker;
330 private String helpPrefix;
331 private JTextField textField;
332 private JComboBox whereChoice;
333 private JCheckBox caseChk;
334 private JCheckBox wordChk;
335
336 private static final String ANSWER = "answer";
337 private static final String ANYWHERE = "anywhere";
338 private static final String CLOSE = "close";
339 private static final String FIND = "find";
340 private static final String HELP = "help";
341 private static final String QUESTION = "question";
342 private static final String TITLE = "title";
343 private static final KeyStroke escapeKey = KeyStroke.getKeyStroke("ESCAPE");
344
345 private static final I18NResourceBundle i18n = I18NResourceBundle.getDefaultBundle();
346 }
|
246
247 private JButton createButton(String uiKey, String actionCommand, ActionListener l) {
248 JButton b = new JButton(i18n.getString(uiKey + ".btn"));
249 b.setName(uiKey);
250 b.setMnemonic(getMnemonic(uiKey));
251 b.setActionCommand(actionCommand);
252 b.addActionListener(l);
253 setToolTipText(b, uiKey);
254 //b.registerKeyboardAction(listener, actionCommand, enterKey, JComponent.WHEN_FOCUSED);
255 return b;
256 }
257
258 private JCheckBox createCheckBox(String uiKey) {
259 JCheckBox b = new JCheckBox(i18n.getString(uiKey + ".ckb"));
260 b.setName(uiKey);
261 b.setMnemonic(getMnemonic(uiKey));
262 setToolTipText(b, uiKey);
263 return b;
264 }
265
266 private JComboBox<String> createChoice(final String uiKey, final String[] choiceKeys) {
267 // create a cache of the presentation string, for use when
268 // rendering, but otherwise, let the JComboBox work in terms of the
269 // choiceKeys
270 final String[] choices = new String[choiceKeys.length];
271 for (int i = 0; i < choices.length; i++)
272 choices[i] = i18n.getString(uiKey + "." + choiceKeys[i] + ".chc");
273
274 JComboBox<String> choice = new JComboBox<>(choiceKeys);
275 choice.setName(uiKey);
276 AccessibleContext ac = choice.getAccessibleContext();
277 ac.setAccessibleName(i18n.getString(uiKey + ".tip"));
278
279 choice.setRenderer(new DefaultListCellRenderer() {
280 public Component getListCellRendererComponent(JList<?> list, Object o, int index, boolean isSelected, boolean cellHasFocus) {
281 Object c = o;
282 for (int i = 0; i < choiceKeys.length; i++) {
283 if (choiceKeys[i] == o) {
284 c = choices[i];
285 break;
286 }
287 }
288 return super.getListCellRendererComponent(list, c, index, isSelected, cellHasFocus);
289 }
290 });
291
292 setToolTipText(choice, uiKey);
293 ac.setAccessibleDescription(choice.getToolTipText());
294 return choice;
295 }
296
297 private JLabel createLabel(String uiKey, boolean needMnemonic) {
298 JLabel l = new JLabel(i18n.getString(uiKey + ".lbl"));
299 l.setName(uiKey);
300 if (needMnemonic)
312 }
313
314 private ActionListener listener = new ActionListener() {
315 public void actionPerformed(ActionEvent e) {
316 String cmd = e.getActionCommand();
317 if (cmd.equals(FIND))
318 find();
319 else if (cmd.equals(CLOSE))
320 setVisible(false);
321 else if (cmd.equals(HELP)) {
322 helpBroker.displayCurrentID(helpPrefix + "search.csh");
323 }
324 }
325 };
326
327 private Interview interview;
328 private Question currentQuestion;
329 private HelpBroker helpBroker;
330 private String helpPrefix;
331 private JTextField textField;
332 private JComboBox<String> whereChoice;
333 private JCheckBox caseChk;
334 private JCheckBox wordChk;
335
336 private static final String ANSWER = "answer";
337 private static final String ANYWHERE = "anywhere";
338 private static final String CLOSE = "close";
339 private static final String FIND = "find";
340 private static final String HELP = "help";
341 private static final String QUESTION = "question";
342 private static final String TITLE = "title";
343 private static final KeyStroke escapeKey = KeyStroke.getKeyStroke("ESCAPE");
344
345 private static final I18NResourceBundle i18n = I18NResourceBundle.getDefaultBundle();
346 }
|