package com.test.ggg.ui;
import lombok.extern.slf4j.Slf4j;
import javax.swing.*;
import java.awt.*;
import java.io.File;
@Slf4j
public class QrCodeImgDialog extends JDialog
{
public QrCodeImgDialog( String title, JFrame parent, String imgPath )
{
super( parent, "", ModalityType.DOCUMENT_MODAL );
setTitle( title );
if( imgPath.isEmpty() )
{
log.error( "QrCodeImgDialog: Image path is empty!" );
return;
}
File file = new File( imgPath );
if( !file.exists() )
{
log.error( "QrCodeImgDialog: given image file not exist!" );
return;
}
//load image
ImageIcon imageIcon = new ImageIcon( imgPath );
imageIcon = new ImageIcon( imageIcon.getImage().getScaledInstance( 500, 500, Image.SCALE_DEFAULT )); //缩放
JLabel labelImg = new JLabel( imageIcon );
this.getContentPane().add( labelImg, BorderLayout.CENTER );
this.setSize( 700, 700 );
this.setLocation( 300, 20 );
this.setResizable( false );
}
public void showDialog()
{
this.setVisible( true );
}
}
Swing 弹窗显示图片
原创
©著作权归作者所有:来自51CTO博客作者006玩命的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:MySQL快速导出数据探索
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Swing显示图片
Swing显示图片可以有很多的种选择,例如:可以用JLabel和JTable等,通过自己的编程我还是推荐使用JPanel,因为JLab
Swing Java 编程 虚拟机 Blog -
java opencv读取Mat矩阵里的颜色
、几种图像的数据类型一表中罗列了常见的数据类型及其含义: 输入图像,指定为数值标量、向量、矩阵或多维数组。①如果 I 是灰度或真彩色 (RGB) 图像,它可以是 uint8、uint16、double、logical、single或 int16。 ②如果 I为索引图像,它可以是 uint8、uint16、double 或 logical。 &nbs
CNN Matlab例子RGB matlab meshc函数 MATLAB 长度和像素 matlab 颜色代码 大全