JXImageView

JXImageView 是sun的swingx项目下的图像浏览控件,支持的图像格式没多大改进,据说支持tiff,但我试了之后还是无法打开。不过相对于其他的基本swing控件,JXImageView已经进步很多了。

 

import  java.io.File;
import  java.io.IOException;
/**
 *
 * 
@author  zwql
 
*/

public   class  JXImageVIewTest  extends  javax.swing.JFrame  {
    
    
/** Creates new form JXImageVIewTest */
    
public JXImageVIewTest() {
        initComponents();
        
try {            
            jXImageView1.setImage(
new File("D:/z.ico"));
        }
 catch (IOException ex) {
            ex.printStackTrace();
        }

    }

    
    
/** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     
*/

    
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">
    private void initComponents() {
        jXImagePanel1 
= new org.jdesktop.swingx.JXImagePanel();
        jXImageView1 
= new org.jdesktop.swingx.JXImageView();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        org.jdesktop.layout.GroupLayout jXImageView1Layout 
= new org.jdesktop.layout.GroupLayout(jXImageView1);
        jXImageView1.setLayout(jXImageView1Layout);
        jXImageView1Layout.setHorizontalGroup(
            jXImageView1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(
0352, Short.MAX_VALUE)
        );
        jXImageView1Layout.setVerticalGroup(
            jXImageView1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(
0244, Short.MAX_VALUE)
        );

        org.jdesktop.layout.GroupLayout jXImagePanel1Layout 
= new org.jdesktop.layout.GroupLayout(jXImagePanel1);
        jXImagePanel1.setLayout(jXImagePanel1Layout);
        jXImagePanel1Layout.setHorizontalGroup(
            jXImagePanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jXImagePanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jXImageView1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jXImagePanel1Layout.setVerticalGroup(
            jXImagePanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jXImagePanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jXImageView1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        org.jdesktop.layout.GroupLayout layout 
= new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jXImagePanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jXImagePanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        pack();
    }
// </editor-fold>
    
    
/**
     * 
@param args the command line arguments
     
*/

    
public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(
new Runnable() {
            
public void run() {
                
new JXImageVIewTest().setVisible(true);
            }

        }
);
    }

JXImageView有很多其他的功能,这里只演示了最简单的一个——拖放,一起慢慢研究吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值