Java,如何将对话框弹出为仅图像? [英] Java, how can I popup a dialog box as only an image?

查看:96
本文介绍了Java,如何将对话框弹出为仅图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图找到一种方法将JDialog的所有内容替换为简单的图像。
这是我正在处理的项目的大约页面,当用户点击关于部分时,我想要一个以JDialog风格弹出的图像(并在焦点丢失时消失)。
示例: http://www.tecmint .com / wp-content / uploads / 2012/08 / About-Skype.jpg
Skype只显示他们创建的图像作为关于页面。
如何在Java(swing)中创建图像对话框?

I'm trying to find a way to replace all the contents of a JDialog to simply an image. It's for the about page of a project I'm working on and I want when the user clicks on the About section, an image to popup in the style of a JDialog(and to disappear when focus is lost). Example: http://www.tecmint.com/wp-content/uploads/2012/08/About-Skype.jpg There Skype displays only an image they've created as their "About" page. How can I make an "image dialog" in Java(swing)?

推荐答案


如何在Java(swing)中创建图像对话框?

How can I make an "image dialog" in Java(swing)?

将未修饰的JDialog与包含ImageIcon的JLabel一起使用:

Use an undecorated JDialog with a JLabel containing an ImageIcon:

JDialog dialog = new JDialog();
dialog.setUndecorated(true);
JLabel label = new JLabel( new ImageIcon(...) );
dialog.add( label );
dialog.pack();
dialog.setVisible(true);

这篇关于Java,如何将对话框弹出为仅图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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