SHARE
TWEET

Untitled

a guest May 26th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     mntmLoad.addActionListener(new ActionListener() {
  2.             public void actionPerformed(ActionEvent arg0) {
  3.                 JFileChooser fileChooser = new JFileChooser();
  4.                 fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
  5.                 int result = fileChooser.showOpenDialog(frame);
  6.                 Image image = null;
  7.                 if (result == JFileChooser.APPROVE_OPTION) {
  8.                     File selectedFile = fileChooser.getSelectedFile();
  9.                     System.out.println("Selected file: " + selectedFile.getAbsolutePath());
  10.                     try {
  11.                         image=ImageIO.read(selectedFile);
  12.                     } catch (IOException e) {
  13.                         e.printStackTrace();   
  14.                         System.exit(1);}
  15.                 }
  16. //              ImageIcon imageIcon = new ImageIcon(image);
  17. //              lblIm.setIcon(imageIcon);
  18.                 JFrame frame2 = new JFrame();
  19.                 frame2.setSize(image.getWidth(null),image.getHeight(null)+35);
  20.                 JLabel l = new JLabel(new ImageIcon(image));
  21.                 frame2.add(l);
  22.                 frame2.setVisible(true);
  23.                
  24.             }
  25.         });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top