List of usage examples for javax.swing JCheckBox requestFocus
public void requestFocus()
Component
gets the input focus. From source file:org.p_vcd.ui.VcdDialog.java
public void updateDatabases(String defaultValue) { List<VideoDatabase> refDbs = VideoDatabase.getReferenceDatabases(); // remove from map List<VideoDatabase> entriesToRemove = new ArrayList<VideoDatabase>(); for (VideoDatabase edb : map_refDbCheck.keySet()) { if (!refDbs.contains(edb)) entriesToRemove.add(edb);/*from ww w . j a va 2 s .com*/ } for (VideoDatabase edb : entriesToRemove) map_refDbCheck.remove(edb); // add to map List<VideoDatabase> entriesToAdd = new ArrayList<VideoDatabase>(); for (VideoDatabase db : refDbs) { if (!map_refDbCheck.containsKey(db)) entriesToAdd.add(db); } for (VideoDatabase db : entriesToAdd) { JCheckBox chkbox = new JCheckBox(db.getName() + " (" + db.getFileList().size() + " files, " + MyUtil.getSecondsToHHMMSS(db.getTotalSeconds()) + " length)"); chkbox.setBackground(Color.WHITE); chkbox.setFont(new Font("Tahoma", Font.PLAIN, 13)); chkbox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateReferenceDbDetail(); } }); map_refDbCheck.put(db, chkbox); } // draw checkboxes panel_refDatabasesList.removeAll(); int cont = 0; for (JCheckBox chkbox : map_refDbCheck.values()) { panel_refDatabasesList.add(chkbox, "cell 0 " + cont); cont++; } panel_refDatabasesList.validate(); // default value if (defaultValue != null) { for (Map.Entry<VideoDatabase, JCheckBox> entry : map_refDbCheck.entrySet()) { if (!defaultValue.equals(entry.getKey().getName())) continue; JCheckBox chkbox = entry.getValue(); chkbox.setSelected(true); chkbox.requestFocus(); break; } } List<String> listQ = new ArrayList<String>(); listQ.add("-- select a db --"); for (VideoDatabase db : refDbs) { listQ.add(db.getName()); } comboBox_queryDb.setModel(new DefaultComboBoxModel<String>(listQ.toArray(new String[0]))); updateReferenceDbDetail(); updateQueryDbDetail(); }