Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowOpened(WindowEvent e) {
- try {
- controller.importFileOnLoad();
- } catch (ClassNotFoundException | IOException e1) {
- e1.printStackTrace();
- }
- }
- tablePanel.getList(Controller.getList());
- private List<Auto> list = Controller.getList();
- private JTree server;
- server = new JTree(createTree());
- add(new JScrollPane(server), BorderLayout.CENTER);
- private DefaultMutableTreeNode createTree() {
- DefaultMutableTreeNode top = newDefaultMutableTreeNode("Servers");
- findChld(top);
- return top;
- }
- private void findChld(DefaultMutableTreeNode parent) {
- for (int i = 0; i < list.size(); i++) {
- DefaultMutableTreeNode child = new
- DefaultMutableTreeNode(list.get(i).toString());
- parent.add(child);
- }
- }
- public void ImportFile(File file) throws IOException,
- ClassNotFoundException {
- db.ImportFile(file);
- }
- private List<Auto> AutoList;
- public void importFileOnLoad() throws FileNotFoundException,
- IOException, ClassNotFoundException {
- File file = new File("C:\Users\Jovan\Desktop\ExitFile.auto");
- if(file.exists()) {
- ObjectInputStream inputStream = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
- AutoList.clear();
- Auto[] auto = (Auto[]) inputStream.readObject();
- AutoList.addAll(Arrays.asList(auto));
- inputStream.close();
- }
- }
Add Comment
Please, Sign In to add comment