/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * ImageViewerDialog.java * * Created on Nov 4, 2009, 1:11:38 PM */ package com.server.gui; import com.server.gui.mngr.ImageViewerManager; import com.server.utils.ImageHandler; import java.awt.Image; import javax.swing.ImageIcon; /** * * @author Administrator */ public class ImageViewerDialog extends javax.swing.JDialog { private String imageFileName = ""; private ImageHandler imageHandler = null; private int imageCount = -1; private ImageViewerManager imageViewerManager = null; /** Creates new form ImageViewerDialog */ public ImageViewerDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); imageHandler = new ImageHandler(); imageViewerManager = new ImageViewerManager(this); } /** 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. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); imageLabel = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setAlwaysOnTop(true); jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); imageLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(imageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 658, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(imageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { ImageViewerDialog dialog = new ImageViewerDialog(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel imageLabel; private javax.swing.JPanel jPanel1; // End of variables declaration//GEN-END:variables void setFileName(String imageFileName) { this.imageFileName = imageFileName; this.setTitle(imageFileName.substring(imageFileName.lastIndexOf("\\") + 1)); Image image = new ImageIcon(imageFileName).getImage(); ImageIcon imageIcon = imageHandler.getScaledImage(image, image.getWidth(null), image.getHeight(null), imageLabel.getWidth(), imageLabel.getHeight()); imageLabel.setIcon(imageIcon); } void setImageCount(int imageCount) { this.imageCount = imageCount; } }