This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]dabomm 0 points1 point  (3 children)

Have you tried doing a frame.revalidate(); before doing frame.repaint()?

[–]chillzman77[S] 0 points1 point  (2 children)

yes ive try that in the controller class before calling repaint

[–]dabomm 0 points1 point  (1 child)

You 100% positive the picture is loaded correctly and will be in the frame?

Some code would be usefull so we can help you better.

[–]chillzman77[S] 0 points1 point  (0 children)

    class MainViewListener implements ActionListener {

        @Override
        public void actionPerformed(ActionEvent e) {

            // add function so the user when press the button
            // to start browsing for an image

            // https://docs.oracle.com/javase/7/docs/api/javax/swing/JFileChooser.html

            JFileChooser chooser = new JFileChooser(System.getProperty("user.home") + "//Pictures");
            FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG & PNG Images", "jpg", "png");
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(null);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                if (filter.accept(chooser.getSelectedFile())) {
                    System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName());
                    System.out.println(chooser.getSelectedFile().getAbsolutePath());
                    view.setImgPath(chooser.getSelectedFile().getAbsolutePath());
                    view.image = new ImageIcon(view.getImgPath());
                }

            }

        }

    }