Results 1 to 2 of 2
  1. #1
    Soufly is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default Displaying a selected image into a JLabel with JFileChooser when using a JmenuItem.

    I'm still somewhat of a noob to java, sorry if this question sounds a bit silly, but I'm having a hard time trying to figure out how to pick an image with JFileChooser and affecting it to "canevas", which is my JLabel.

    Java Code:
    public void actionPerformed (ActionEvent ae){
    		
    		Object src = ae.getSource();
    		if(src == jmiOuvrir){
    			JFileChooser jfc = new JFileChooser(".");
    			int n =  jfc.showOpenDialog(this);
    			if(n == JFileChooser.APPROVE_OPTION){
    				BufferedImage image = null;
    				canevas.setIcon(new ImageIcon(image));
    			}
    		}
    jmiOuvrir is what i'm using to trigger it...Any help?
    Thanks!


    Ps. First post. :P

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. how to display image selected by JFileChooser
    By khushi.cutegal in forum AWT / Swing
    Replies: 17
    Last Post: 07-24-2010, 07:03 AM
  2. JMenuItem - image won't show
    By javawriter in forum AWT / Swing
    Replies: 10
    Last Post: 07-13-2010, 07:11 PM
  3. Replies: 8
    Last Post: 08-13-2009, 05:23 AM
  4. Replies: 2
    Last Post: 04-24-2009, 09:10 AM
  5. Replies: 0
    Last Post: 03-10-2008, 03:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •