当前位置:   article > 正文

JXImageView

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有很多其他的功能,这里只演示了最简单的一个——拖放,一起慢慢研究吧!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/787405
推荐阅读
相关标签
  

闽ICP备14008679号