Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void load()
- {
- int val = jfc.showOpenDialog(DrawBoardLayoutDemo.this);
- if (val == JFileChooser.APPROVE_OPTION)
- {
- File f = new File(jfc.getSelectedFile().getAbsolutePath());
- try
- {
- FileInputStream fin = new FileInputStream(f.getAbsoluteFile());
- ObjectInputStream ios = new ObjectInputStream(fin);
- drawPanel.shape = (ArrayList<Shape>) ios.readObject();
- ios.close();
- fin.close();
- drawPanel.repaint();
- index = drawPanel.shape.size();
- }
- catch (FileNotFoundException e2)
- {
- e2.printStackTrace();
- }
- catch (IOException e2)
- {
- e2.printStackTrace();
- }
- catch (ClassNotFoundException e2)
- {
- e2.printStackTrace();
- }
- }
- else
- {
- System.err.println("Nothing was loaded.");
- }
- }
- private void save()
- {
- int val = jfc.showSaveDialog(DrawBoardLayoutDemo.this);
- if (val == JFileChooser.APPROVE_OPTION)
- {
- File f = new File(jfc.getSelectedFile().getAbsolutePath());
- try
- {
- FileOutputStream fout = new FileOutputStream(f.getAbsoluteFile());
- ObjectOutputStream oos = new ObjectOutputStream(fout);
- oos.writeObject(drawPanel.shape);
- oos.flush();
- oos.close();
- fout.close();
- }
- catch (FileNotFoundException e1)
- {
- System.err.println("File not found");
- }
- catch (IOException e1)
- {
- System.err.println("Error loading");
- }
- }
- else
- {
- System.err.println("Nothing was saved.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement