i have java GUI problem

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) {
System.out.println("Error:"+ie.getMessage());
}
}
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.getContentPane().add(panel);
frame.setSize(500, 500);
frame.setVisible(true);
}
else{
JOptionPane.showMessageDialog(null,"Password is not accepted ! you can't load any image","Hey !",JOptionPane.WARNING_MESSAGE);
System.exit(0);
}
}
}

thanks

Replies

You are reading an archived discussion.

Related Posts

Good day all This is the Schematic of Intercom circuit P.S. you will see "R" Symbol it's just Indicates to the "ohm" unit 2R2 = 2.2 ohm 22R = 22...
Today CEan Gaurav Bhorkar is celebrating his birthday. Wish you many many Happy Returns Of The Day. 😀
Ben Silbermann is the new Mark Zuckerberg and almost everyone's watching the new startup on the block - Pinterest. Ben and his friends founded Pintrest few years ago and no...
Few days back I was in InOrbit, Mall Hyderabad. I saw that there are advertisement on washroom mirrors.The whole glass is just like a screen and advertisement is displaying on...
hai friendz.. I hope i can learn something from here.. 😀 i am from kerala.. nice to meet you guys.. HappY Journey ...😁