如何在Java桌面应用程序中插入图片框 [英] How to insert a Picture box in java desktop application
本文介绍了如何在Java桌面应用程序中插入图片框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个创建的java桌面应用程序,我想添加一个图片框来显示用户的图像,然后将其存储在一个访问数据库中..我已经尝试过这个代码,但它没有在面板上显示任何内容我想放置我的图片框。请帮助
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
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;固定代码格式
Fredrik Bornander; Fixed code formatting
推荐答案
您可以设置Jlable的图标属性以查看图片。
a示例代码如下。
You can set icon property of a Jlable to view picture.
a sample code are below.
JLable lblPic = new javax.swing.JLabel();
lblPic.setIcon(new javax.swing.ImageIcon("D:\\picture\\Image.JPG"));
没有图片框!这是Java,而不是MS的东西。您可以在大多数组件中显示图像。
使用图像 [ ^ ]
问候
Torsten
there is no picturebox! This is Java, not MS stuff. You can display an image in most components.
Working with images[^]
regards
Torsten
这篇关于如何在Java桌面应用程序中插入图片框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文