Click here to Skip to main content
15,889,849 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a created java desktop application and i would like to add a picture box to display the image of a user and then store it in an access database..I have tried this code but it doesnot display anything on the panel where i want to place my picture box.please help
Java
PictureBox pic=new PictureBox(300,200);
this.add(pic);
this.setVisible(true);
for (int i = 0; i < 100; i++) 
   pic.setPixel(50,i,Color.WHITE);

pic.print(40,40,"Hello");
pic.setPixel(60,60,Color.RED);
pic.loadImage("images/still3.jpg");



Fredrik Bornander; Fixed code formatting
Posted
Updated 6-Jun-11 22:27pm
v3

You can set icon property of a Jlable to view picture.
a sample code are below.
Java
JLable  lblPic = new javax.swing.JLabel();
 lblPic.setIcon(new javax.swing.ImageIcon("D:\\picture\\Image.JPG")); 
 
Share this answer
 
there is no picturebox! This is Java, not MS stuff. You can display an image in most components.

Working with images[^]

regards
Torsten
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900