ponedeljek, avgust 01, 2005

HTMLEditor in Java

today I was programming in java HTMLEditor in still in progress

here is my snippets from my project

// shrani dokument kot
public void shraniDokumentKot()
{
try {
File trenutnaDat = new File(".");
JFileChooser izberem = new JFileChooser(trenutnaDat);
izberem.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
izberem.setFileFilter(new TextFilter());
int dovolim = izberem.showSaveDialog(jframe);
if (dovolim == JFileChooser.APPROVE_OPTION) {
File novaDat = izberem.getSelectedFile();
if (novaDat.exists()) {
String sporocilo = novaDat.getAbsolutePath() + " ze obstaja \n "
+ "Ali ga hoces nadomestit.";
if (JOptionPane.showConfirmDialog(jframe, sporocilo) == JOptionPane.YES_OPTION) {
trenutnaDat = novaDat;
jframe.setTitle(trenutnaDat.getName());
FileWriter fw = new FileWriter(trenutnaDat);
try {

fw.write(editor.getText(0,document.getLength()));

} catch (BadLocationException ble)
{
ble.printStackTrace();
}

fw.close();
if (debug)
System.out.println("Shranim " + trenutnaDat.getAbsolutePath());
}
} else {
trenutnaDat = new File(novaDat.getAbsolutePath());
jframe.setTitle(trenutnaDat.getName());
FileWriter fw = new FileWriter(trenutnaDat);

try {

fw.write(editor.getText(0,document.getLength()));

} catch (BadLocationException ble)
{
ble.printStackTrace();
}

fw.close();
if (debug)
System.out.println("Shranim " + trenutnaDat.getAbsolutePath());
}
}
} catch (FileNotFoundException fnfe) {
System.err.println("FileNotFoundException " + fnfe.getMessage());
} catch (IOException ioe) {
System.err.println("IOException " + ioe.getMessage());
}

}

Št. komentarjev: 0:

Objavite komentar

Naročite se na Objavi komentarje [Atom]

<< Domov