// find photo by fullPath and highlight it
public void find() {
System.out.println("Find image");
String[] options = photoManager.getPhotoFullPaths(); // get photoList's fullPaths (as String[])
if (options == null) return; // if photoManager has no photo, then return here
String fullPath = (String)JOptionPane.showInputDialog(null, "Find the image:", "Find", JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
if (fullPath != null) {
Photo found = photoManager.find(fullPath); // find photo by fullPath
if (found == null) return; // if photo is not found, then return here
found.print();
// find ImageLabel component that has the same fullPath. If found, then highlight its border to red
Component[] componentList = photoPanel.getComponents();
for (Component c: componentList) {
if (c instanceof ImageLabel)
((JLabel)c).setBorder(javax.swing.BorderFactory.createEmptyBorder());
}
for(Component c : componentList) {
if (c instanceof ImageLabel) {
if (((ImageLabel)c).getFullPath() == fullPath) { // find ImageLabel component that has the same fullPath
Border border = BorderFactory.createLineBorder(Color.RED, 3); // highlight its border to red
((JLabel)c).setBorder(border);
}
}
}
}
}