I have a fairly simple program that once some data is entered into a JTable
it can then be exported or "saved" to an excel spreadsheet. All of this is working fine and it is making a saved excel file perfectly.
The problem I have run into is this:
When you try to put the excel file in a subfolder of, say, the desktop folder (desktop/folder) it saves it on the desktop instead; but it only does this on macs.
When I do this on a windows computer it works 100% of the time.
I was wondering if anyone has any insight into the problem or a fix for this?
This is my JFileChooser
code which would in theory be causing the problem.
JFileChooser fc = new JFileChooser();
fc.setSelectedFile(new File(jTextField3.getText() + jTextField6.getText() + "-" + jTextField7.getText() + "-" + jTextField8.getText()));
int option = fc.showSaveDialog(PScalcUI.this);
if(option == JFileChooser.APPROVE_OPTION){
String filename = fc.getSelectedFile().getName();
String path = fc.getSelectedFile().getParentFile().getPath();
int len = filename.length();
String ext = "";
String file = "";
if(len > 4){
ext = filename.substring(len-4, len);
}
if(ext.equals(".xls")){
file = path + "\\" + filename;
}else{
file = path + "\\" + filename + ".xcl";
}
toExcel(jTable1, new File(file));
}