Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mntmLoad.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- JFileChooser fileChooser = new JFileChooser();
- fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
- int result = fileChooser.showOpenDialog(frame);
- Image image = null;
- if (result == JFileChooser.APPROVE_OPTION) {
- File selectedFile = fileChooser.getSelectedFile();
- System.out.println("Selected file: " + selectedFile.getAbsolutePath());
- try {
- image=ImageIO.read(selectedFile);
- } catch (IOException e) {
- e.printStackTrace();
- System.exit(1);}
- }
- // ImageIcon imageIcon = new ImageIcon(image);
- // lblIm.setIcon(imageIcon);
- JFrame frame2 = new JFrame();
- frame2.setSize(image.getWidth(null),image.getHeight(null)+35);
- JLabel l = new JLabel(new ImageIcon(image));
- frame2.add(l);
- frame2.setVisible(true);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement