public void save() { saveFile(file); }
public EditTiffG() { setTitle(TITLE); setLayout(new BorderLayout()); textArea = new JTextArea(25, 80); add(new JScrollPane(textArea), BorderLayout.CENTER); //textArea.setWrapStyleWord(true); textArea.setLineWrap(true); JMenuBar menubar = new JMenuBar(); setJMenuBar(menubar); JMenu file = new JMenu("File"); menubar.add(file); JMenuItem fileOpen = new JMenuItem("Open"); file.add(fileOpen); fileOpen.addActionListener(this); fileOpen.setActionCommand("open"); JMenuItem fileSave = new JMenuItem("Save"); file.add(fileSave); fileSave.addActionListener(this); fileSave.setActionCommand("save"); JMenuItem fileExit = new JMenuItem("Exit"); file.add(fileExit); fileExit.addActionListener(this); fileExit.setActionCommand("exit"); fileBox = new JFileChooser(System.getProperty("user.dir")); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setVisible(true); }
public static void main(String[] args) throws Exception { try (RandomAccessInputStream in = EditTiffG.open(args[0])) { } }
public void saveFile(File f) { String path = f.getAbsolutePath(); try (RandomAccessInputStream in = new RandomAccessInputStream(path); RandomAccessOutputStream out = new RandomAccessOutputStream(path)){ String xml = getXML(); TiffSaver saver = new TiffSaver(out, path); saver.overwriteComment(in, xml); } catch (FormatException exc) { showError(exc); } catch (IOException exc) { showError(exc); } }
public void open() { int rval = fileBox.showOpenDialog(this); if (rval != JFileChooser.APPROVE_OPTION) return; File f = fileBox.getSelectedFile(); openFile(f); }
public EditTiffG() { setTitle(TITLE); setLayout(new BorderLayout()); textArea = new JTextArea(25, 80); add(new JScrollPane(textArea), BorderLayout.CENTER); //textArea.setWrapStyleWord(true); textArea.setLineWrap(true); JMenuBar menubar = new JMenuBar(); setJMenuBar(menubar); JMenu file = new JMenu("File"); menubar.add(file); JMenuItem fileOpen = new JMenuItem("Open"); file.add(fileOpen); fileOpen.addActionListener(this); fileOpen.setActionCommand("open"); JMenuItem fileSave = new JMenuItem("Save"); file.add(fileSave); fileSave.addActionListener(this); fileSave.setActionCommand("save"); JMenuItem fileExit = new JMenuItem("Exit"); file.add(fileExit); fileExit.addActionListener(this); fileExit.setActionCommand("exit"); fileBox = new JFileChooser(System.getProperty("user.dir")); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setVisible(true); }
public static void main(String[] args) throws Exception { try (RandomAccessInputStream in = EditTiffG.open(args[0])) { } }
public void saveFile(File f) { String path = f.getAbsolutePath(); try (RandomAccessInputStream in = new RandomAccessInputStream(path); RandomAccessOutputStream out = new RandomAccessOutputStream(path)){ String xml = getXML(); TiffSaver saver = new TiffSaver(out, path); saver.overwriteComment(in, xml); } catch (FormatException exc) { showError(exc); } catch (IOException exc) { showError(exc); } }
public void open() { int rval = fileBox.showOpenDialog(this); if (rval != JFileChooser.APPROVE_OPTION) return; File f = fileBox.getSelectedFile(); openFile(f); }
try (RandomAccessInputStream in = EditTiffG.open(file)) {}
public void save() { saveFile(file); }
public static RandomAccessInputStream open(String filename) throws IOException { EditTiffG etg = new EditTiffG(); File f = new File(filename); if (f.exists()) { RandomAccessInputStream in = new RandomAccessInputStream(filename); etg.openFile(f, in); return in; } return null; } // -- ActionListener methods --
public static RandomAccessInputStream open(String filename) throws IOException { EditTiffG etg = new EditTiffG(); File f = new File(filename); if (f.exists()) { RandomAccessInputStream in = new RandomAccessInputStream(filename); etg.openFile(f, in); return in; } return null; } // -- ActionListener methods --