Guest User

Untitled

a guest
Nov 24th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. addWindowListener(new WindowAdapter() {
  2.  
  3. @Override
  4. public void windowOpened(WindowEvent e) {
  5. try {
  6. controller.importFileOnLoad();
  7. } catch (ClassNotFoundException | IOException e1) {
  8. e1.printStackTrace();
  9. }
  10. }
  11.  
  12. tablePanel.getList(Controller.getList());
  13.  
  14. private List<Auto> list = Controller.getList();
  15. private JTree server;
  16.  
  17.  
  18.  
  19. server = new JTree(createTree());
  20. add(new JScrollPane(server), BorderLayout.CENTER);
  21.  
  22. private DefaultMutableTreeNode createTree() {
  23. DefaultMutableTreeNode top = newDefaultMutableTreeNode("Servers");
  24. findChld(top);
  25. return top;
  26.  
  27. }
  28.  
  29.  
  30. private void findChld(DefaultMutableTreeNode parent) {
  31. for (int i = 0; i < list.size(); i++) {
  32. DefaultMutableTreeNode child = new
  33. DefaultMutableTreeNode(list.get(i).toString());
  34. parent.add(child);
  35.  
  36. }
  37. }
  38.  
  39. public void ImportFile(File file) throws IOException,
  40. ClassNotFoundException {
  41. db.ImportFile(file);
  42. }
  43.  
  44. private List<Auto> AutoList;
  45.  
  46. public void importFileOnLoad() throws FileNotFoundException,
  47. IOException, ClassNotFoundException {
  48. File file = new File("C:\Users\Jovan\Desktop\ExitFile.auto");
  49. if(file.exists()) {
  50.  
  51.  
  52. ObjectInputStream inputStream = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
  53.  
  54. AutoList.clear();
  55.  
  56. Auto[] auto = (Auto[]) inputStream.readObject();
  57.  
  58. AutoList.addAll(Arrays.asList(auto));
  59.  
  60. inputStream.close();
  61.  
  62. }
  63. }
Add Comment
Please, Sign In to add comment