G
Guest
Gast
Hallo, hab folgendes Problem, und zwar wollen die filechooser die filter nicht annehemen:
währe nett, wenn jemand helfen könnte, danke im vorraus
währe nett, wenn jemand helfen könnte, danke im vorraus
Code:
public void OpenButtonActionPerformed(ActionEvent evt) { //OpenButton
JFileChooser fc = new JFileChooser();
fc.showOpenDialog( null );
File file = fc.getSelectedFile();
fc.setFileFilter(new javax.swing.filechooser.FileFilter(){
public boolean accept( File f ){
return f.isDirectory() || f.getName().toLowerCase().endsWith( ".jef" );
}
public String getDescription(){
return "JEditor-Projekte(*.jep)";
}
});
try {
FileInputStream fis = new FileInputStream (file.getPath());
System.out.println(file.getPath());
ObjectInputStream ois = new ObjectInputStream (fis);
doc = (StyledDocument)ois.readObject();
ois.close();
//jTextPane1.setStyledDocument(doc);
textpanes.get(jTabbedPane1.getSelectedIndex()).setStyledDocument(doc);
// beim schließen daruaf achten, textpane aus list zu entfernen
}
catch (Exception exc) {
System.out.println(exc);
}
}
public void SaveButtonActionPerformed(ActionEvent evt) { //SaveButton
JFileChooser fc = new JFileChooser();
fc.showSaveDialog(null);
fc.setFileFilter(new javax.swing.filechooser.FileFilter(){
public boolean accept( File f ){
return f.isDirectory() || f.getName().toLowerCase().endsWith( ".jef" );
}
public String getDescription(){
return "JEditor-Projekte(*.jep)";
}
});
File file = fc.getSelectedFile();
try{
FileOutputStream fos = new FileOutputStream(file.getPath());
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(textpanes.get(jTabbedPane1.getSelectedIndex()).getStyledDocument());
oos.close();
fos.close();
}
catch (FileNotFoundException exc) {
System.out.println("File Not Found: " + file.getName());
}
catch (IOException exc) {
System.out.println("IOException: " + file.getName());
}
}