Hi guys,

I need to open 2 different folders seperately from a single folder.
i.e. From Folder A (which contains nothing else but folder B and C), when I click "open" Folder A, it will load my images in folder B and images in folder C at the same time individually into a same area but is divided into half.

These are my current codes. Not sure if it helps..


public ImageArea(File dir) {
this.dir = dir;
loadImage(true, true);
loadImage(false, true);
addKeyListener(this);
addMouseMotionListener(this);
addMouseListener(this);
setFocusable(true);
this.setName("asdasd");
}

public void loadImage(boolean isFileA, boolean increase) {
File[] fileList = dir.listFiles(new FilenameFilter() {

public boolean accept(File dir, String name) {
if (name.toLowerCase().endsWith(".dcm")
|| name.toLowerCase().endsWith(".dc3")
|| name.toLowerCase().endsWith(".dic")) {
return true;
} else {
return false;
}
}
});
if (fileList.length < 2) {
return;
}
try {
if (isFileA) { //exception code - If folder does not contain dcm images.
a_os = increase? (a_os + 1) % fileList.length : (a_os - 1 + fileList.length) % fileList.length;
} else { //exception code - If folder does not contain dcm images.
b_os = increase? (b_os + 1) % fileList.length: (b_os - 1 + fileList.length) % fileList.length;
}
String ext = fileList[a_os].getName().substring(fileList[a_os].getName().lastIndexOf(".") + 1);
Iterator readers = ImageIO.getImageReadersByFormatName(ext);
ImageReader reader = (ImageReader) readers.next();
reader.setInput(new FileImageInputStream(fileList[a_os]), true);
imgA = ((DICOMImageReader) reader).read(0, null);

ext = fileList[b_os].getName().substring(fileList[b_os].getName().lastIndexOf(".") + 1);
readers = ImageIO.getImageReadersByFormatName(ext);
reader = (ImageReader) readers.next();
reader.setInput(new FileImageInputStream(fileList[b_os]), true);
imgB = ((DICOMImageReader) reader).read(0, null);

w = Math.max(imgA.getWidth(), imgB.getWidth());
h = Math.max(imgA.getHeight(), imgB.getHeight());
} catch (Exception e) { //catch error
String fileName; //error handling code
fileName = isFileA ? fileList[a_os].getPath() : fileList[b_os].getPath();
promptError(fileName + " could not be read");
e.printStackTrace();
System.exit(1);
}
dx = w / 2;
dy = h / 2;
}

Open file action:
public class OpenFileAction extends AbstractAction {
JFrame frame;
JFileChooser chooser;
File file;

OpenFileAction() {
super("Open...");
frame = new JFrame();
chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
}

public void actionPerformed(ActionEvent evt) {
// Show dialog; this method does not return until dialog is closed
chooser.showOpenDialog(frame);
// Get the selected file
file = chooser.getSelectedFile();
}

public File getFile() {
chooser.showOpenDialog(frame);
// Get the selected file
file = chooser.getSelectedFile();
return file;
}
};