hi everyone ,
here it is my code i ran this code, i set a password to the program to allow user to write the image location in computer, but its not taking the action ...
also i wanted to modify image after loading it like : changing its color or apply any filter then save image ..
any idea ?

import java.awt.*; // JpasswordField
import java.awt.image.BufferedImage; //bo hinanaway image lanaw pc
import java.io.*; // in/out image
import javax.imageio.ImageIO; //in/out image
import javax.swing.JFrame; // windowy rasm
import javax.swing.*; // Joptionpane (cancelu ok u isharati sual )..
public class ShowImage extends Panel
BufferedImage image; // ta3rif bakarde lo xindnaway rasmaka
public ShowImage() { //constructor
try {
System.out.println("Enter image name\n");
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));// dachitawa naw pc
String imageName=bf.readLine(); // nawi rasm daxil dakay
File input = new File(imageName); // obj. rasm drust daka
image = ImageIO.read(input); // daxinitawa
} catch (IOException ie) {
public void paint(Graphics g) {
g.drawImage( image, 0, 0, null);

public static void main(String []arg)throws
Exception {
//String password;
JPasswordField passwordField = new JPasswordField();
passwordField.setEchoChar('*'); // ka password danusi ba * diardabi, aw methoda baxoy haya
Object[] obj = {"Please enter the password:\n\n", passwordField}; // bo pishandani enter password
Object stringArray[] = {"OK","Cancel"}; // bo pishandani ok u cancel drustt krdiya
int password = JOptionPane.showOptionDialog(null, obj, "Need password",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, stringArray, obj);/*bo krdnaway messagea bchukaka
ka bo daxil krdni password bakarde*/
//password = passwordField.getPassword().toString();
if (password==12345){
/* bo krdnaway windowi rasmaka , danani sizey windowyaka,panel : bo henanaway rasm lanaw computeraka */
JFrame frame = new JFrame("Display image");
ShowImage dis=new ShowImage();
Panel panel = new ShowImage();
frame.setSize(500, 500);
JOptionPane.showMessageDialog(null,"Password is not accepted ! you can't load any image","Hey !",JOptionPane.WARNING_MESSAGE);