Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. JMenuBar menuBar = new JMenuBar();
  2.  
  3. JMenu add = new JMenu("Add");
  4. add.addActionListener(event -> {
  5.  
  6. JFileChooser chooser = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory());
  7.  
  8. chooser.setAcceptAllFileFilterUsed(false);
  9. FileNameExtensionFilter filter = new FileNameExtensionFilter("Only image files", "jpg", "png", "jpeg");
  10. chooser.addChoosableFileFilter(filter);
  11.  
  12. int returnInt = chooser.showOpenDialog(frame);
  13.  
  14. if(returnInt == JFileChooser.APPROVE_OPTION) {
  15. File selected = chooser.getSelectedFile();
  16. ArrayList<String> stringList = new ArrayList<>();
  17.  
  18. MemeInstance.INSTANCE.addMeme(selected, stringList);
  19. }
  20.  
  21. chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
  22.  
  23. });
  24.  
  25.  
  26. JMenu search = new JMenu("Find");
  27. search.addActionListener(e -> {
  28.  
  29.  
  30. });
  31. menuBar.add(add);
  32. menuBar.add(search);
  33.  
  34. frame.setJMenuBar(menuBar);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement