hi,

I would like to save a .bmp image using showSaveDialog and i cannot figure out what to use.. Below i have the code of open.

Code

protected void Open(JFileChooser chooser, JLabel lblPicture) {
		// TODO Auto-generated method stub
		if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
		{
			File fileChoosed = chooser.getSelectedFile();
			try 
			{
				imageChoosed = ImageIO.read(fileChoosed);
				lblPicture.setIcon(new ImageIcon(imageChoosed));	
				IconEnableing(true);
			} 
			
			catch (IOException e) 
			{
				e.printStackTrace();				
			}

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

it saved but it saved as File not as an image.

What do you mean? Did it save but when you double click on the file in window it comes up with "Choose the program you wish to open this file with" dialog?

If that is the case make sure you have the file extension right. If you are saving it as a JPEG add the .jpg

What do you mean? Did it save but when you double click on the file in window it comes up with "Choose the program you wish to open this file with" dialog?

If that is the case make sure you have the file extension right. If you are saving it as a JPEG add the .jpg

thank you very much i figured out that when i was saving the image i did not write the extenstion after the name. thx

This article has been dead for over six months. Start a new discussion instead.