如何在java中将图像添加到表单 [英] How to add an Image to Form in java

查看:130
本文介绍了如何在java中将图像添加到表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JDeveloper在java中设计一个表单。
我是JDeveloper的新手。
在JDeveloper工具中,我没有找到任何选项来直接添加像.Net这样的形式。
我不知道如何手动添加图像。
有没有其他方法可以解决它。
所以请帮我解决。

I am designing a form in java using JDeveloper. I am new to JDeveloper. In JDeveloper tool I didn't found any option to directly add image to form like .Net. And I don't know how to add image to form manually. is there any other way to solve it out. So please help me to solve it.

推荐答案

这很简单:

      image = ImageIO.read(new File(path));
      JLabel picLabel = new JLabel(new ImageIcon(image));

Yayy!现在你的形象是摆动组件!将它添加到框架或面板或您通常做的任何事情!可能还需要重新绘制,例如

Yayy! Now your image is a swing component ! add it to a frame or panel or anything like you usually do! Probably need a repainting too , like

      jpanel.add(picLabel);
      jpanel.repaint(); 

这篇关于如何在java中将图像添加到表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆