Results 1 to 2 of 2
- 03-19-2011, 11:03 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 3
- Rep Power
- 0
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.
jmiOuvrir is what i'm using to trigger it...Any help?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)); } }
Thanks!
Ps. First post. :P
-
You'll want to read the tutorial on how to use a JFileChooser to learn how to get the file that has been chosen. It's all there in the tutorial: How to use File Choosers
Similar Threads
-
how to display image selected by JFileChooser
By khushi.cutegal in forum AWT / SwingReplies: 17Last Post: 07-24-2010, 06:03 AM -
JMenuItem - image won't show
By javawriter in forum AWT / SwingReplies: 10Last Post: 07-13-2010, 06:11 PM -
Displaying text in a JTextArea when a JtextField is Selected
By Frys82 in forum AWT / SwingReplies: 8Last Post: 08-13-2009, 04:23 AM -
Displaying a selected image with a JFileChooser into a textarea
By Jonte79 in forum AWT / SwingReplies: 2Last Post: 04-24-2009, 08:10 AM -
Applet - Displaying an HTML page with a selected resolution
By Java Tip in forum Java TipReplies: 0Last Post: 03-10-2008, 02:36 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks