如何在其他应用程序中调用java文件?

如何在其他应用程序中调用java文件?,java,swing,Java,Swing,我必须将java文件保存在同一个软件包dicomizer中: *Pdf2Dcm.java: package dicomizer; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOExce

我必须将java文件保存在同一个软件包dicomizer中:

*Pdf2Dcm.java:

    package dicomizer;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.dcm4che2.data.BasicDicomObject;
import org.dcm4che2.data.DicomObject;
import org.dcm4che2.data.Tag;
import org.dcm4che2.data.UID;
import org.dcm4che2.data.VR;
import org.dcm4che2.io.DicomOutputStream;
import org.dcm4che2.util.UIDUtils;

/**
 * @author gunter zeilinger(gunterze@gmail.com)
 * @version $Revision: 12456 $ $Date: 2009-11-26 13:51:53 +0100 (Thu, 26 Nov 2009) $
 * @since Apr 1, 2006
 *
 */
public class Pdf2Dcm extends Interface {

    private static final String USAGE = 
        "pdf2dcm [Options] <pdffile> <dcmfile>";
    private static final String DESCRIPTION = 
        "Encapsulate PDF Document into DICOM Object.\nOptions:";
    private static final String EXAMPLE = 
        "pdf2dcm -c pdf2dcm.cfg report.pdf report.dcm\n" +
        "=> Encapulate PDF Document report.pdf into DICOM Object stored to " +
        "report.dcm using DICOM Attribute values specified in Configuration " +
        "file pdf2dcm.cfg.";

    private String transferSyntax = UID.ExplicitVRLittleEndian;
    private String charset = "ISO_IR 100";
    private int bufferSize = 8192;
    private Properties cfg = new Properties();



    public Pdf2Dcm() {
        try {
            cfg.load(Pdf2Dcm.class.getResourceAsStream("pdf2dcm.cfg"));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
  /*   public Pdf2Dcm(String filename,String path) {
         this.filename = filename;
         this.path = path;


        try {
            cfg.load(Pdf2Dcm.class.getResourceAsStream("pdf2dcm.cfg"));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }*/


    public final void setCharset(String charset) {
        this.charset = charset;
    }

    public final void setBufferSize(int bufferSize) {
        if (bufferSize < 64) {
            throw new IllegalArgumentException("bufferSize: " + bufferSize);
        }
        this.bufferSize = bufferSize;
    }

    public final void setTransferSyntax(String transferSyntax) {
        this.transferSyntax = transferSyntax;
    }

    private void loadConfiguration(File cfgFile) throws IOException {
        Properties tmp = new Properties(cfg);
        InputStream in = new BufferedInputStream(new FileInputStream(cfgFile));
        try {
            tmp.load(in);
        } finally {
            in.close();
        }
        cfg = tmp;
    }

    public void convert(File pdfFile, File dcmFile) throws IOException { 
        DicomObject attrs = new BasicDicomObject();
        attrs.putString(Tag.SpecificCharacterSet, VR.CS, charset);
        attrs.putSequence(Tag.ConceptNameCodeSequence);
        for (Enumeration en = cfg.propertyNames(); en.hasMoreElements();) {
            String key = (String) en.nextElement();
            attrs.putString(Tag.toTagPath(key), null, cfg.getProperty(key));           
        }
        ensureUID(attrs, Tag.StudyInstanceUID);
        ensureUID(attrs, Tag.SeriesInstanceUID);
        ensureUID(attrs, Tag.SOPInstanceUID);
        Date now = new Date();
        attrs.putDate(Tag.InstanceCreationDate, VR.DA, now);
        attrs.putDate(Tag.InstanceCreationTime, VR.TM, now);
        attrs.initFileMetaInformation(transferSyntax);
        FileInputStream pdfInput = new FileInputStream(pdfFile);
        FileOutputStream fos = new FileOutputStream(dcmFile);
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        DicomOutputStream dos = new DicomOutputStream(bos);
        try {
            dos.writeFileMetaInformation(attrs);
            dos.writeDataset(attrs.subSet(Tag.SpecificCharacterSet, 
                    Tag.EncapsulatedDocument), transferSyntax);
            int pdfLen = (int) pdfFile.length();
            dos.writeHeader(Tag.EncapsulatedDocument, VR.OB, (pdfLen+1)&~1);
            byte[] b = new byte[bufferSize];
            int r;
            while ((r = pdfInput.read(b)) > 0) {
                dos.write(b, 0, r);
            }
            if ((pdfLen&1) != 0) {
                dos.write(0);
            }
            dos.writeDataset(attrs.subSet(Tag.EncapsulatedDocument, -1), 
                    transferSyntax);
        } finally {
            dos.close();
            pdfInput.close();
        }
    }    

    private void ensureUID(DicomObject attrs, int tag) {
        if (!attrs.containsValue(tag)) {
            attrs.putString(tag, VR.UI, UIDUtils.createUID());
        }        
    }

    public static void main(String[] args) {
        try {
            //CommandLine cl = parse(args);
            Pdf2Dcm pdf2Dcm = new Pdf2Dcm();
            //if (cl.hasOption("ivrle")) {
              //  pdf2Dcm.setTransferSyntax(UID.ImplicitVRLittleEndian);
            //}
            //if (cl.hasOption("cs")) {
              //  pdf2Dcm.setCharset(cl.getOptionValue("cs"));
            //}
            //if (cl.hasOption("bs")) {
              //  pdf2Dcm.setBufferSize(Integer.parseInt(cl.getOptionValue("bs")));
            //}
            //if (cl.hasOption("c")) {
              //  pdf2Dcm.loadConfiguration(new File(cl.getOptionValue("c")));
            //}
            //if (cl.hasOption("uid")) {
               // UIDUtils.setRoot(cl.getOptionValue("uid"));
            //}
            //List argList = cl.getArgList();
            //File pdfFile = new File((String) argList.get(0));
            File pdfFile = new File(filename);
            //File pdfFile = new File("C:\\Users\\Dell\\Desktop\\input\\demande.docx");
            //File dcmFile = new File((String) argList.get(1));
            File dcmFile = new File(path);
           // File dcmFile = new File("C:\\Users\\Dell\\Desktop\\output\\demande.dcm");
           // System.out.println(filename);
            //System.out.println(path);
            long start = System.currentTimeMillis();
            pdf2Dcm.convert(pdfFile, dcmFile);
            long fin = System.currentTimeMillis();
            System.out.println("Encapsulated " + pdfFile + " to " + dcmFile 
                    + " in " + (fin - start) +  "ms.");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static CommandLine parse(String[] args) {
        Options opts = new Options();

        OptionBuilder.withArgName("charset");
        OptionBuilder.hasArg();
        OptionBuilder.withDescription(
                "Specific Character Set, ISO_IR 100 by default");
        opts.addOption(OptionBuilder.create("cs"));

        OptionBuilder.withArgName("size");
        OptionBuilder.hasArg();
        OptionBuilder.withDescription(
                "Buffer size used for copying PDF to DICOM file, 8192 by default");
        opts.addOption(OptionBuilder.create("bs"));

        OptionBuilder.withArgName("file");
        OptionBuilder.hasArg();
        OptionBuilder.withDescription(
                "Configuration file specifying DICOM attribute values");
        opts.addOption(OptionBuilder.create("c"));

        opts.addOption("ivrle", false, "use Implicit VR Little Endian instead " +
                "Explicit VR Little Endian Transfer Syntax for DICOM encoding.");
        opts.addOption("h", "help", false, "print this message");

        OptionBuilder.withArgName("prefix");
        OptionBuilder.hasArg();
        OptionBuilder.withDescription("Generate UIDs with given prefix," +
                "1.2.40.0.13.1.<host-ip> by default.");
        opts.addOption(OptionBuilder.create("uid"));

        opts.addOption("V", "version", false,
                "print the version information and exit");
        CommandLine cl = null;
        try {
            cl = new GnuParser().parse(opts, args);
        } catch (ParseException e) {
            exit("pdf2dcm: " + e.getMessage());
            throw new RuntimeException("unreachable");
        }
        if (cl.hasOption('V')) {
            Package p = Pdf2Dcm.class.getPackage();
            System.out.println("pdf2dcm v" + p.getImplementationVersion());
            System.exit(0);
        }
        if (cl.hasOption('h') || cl.getArgList().size() != 2) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE);
            System.exit(0);
        }

        return cl;
    }

    private static void exit(String msg) {
        System.err.println(msg);
        System.err.println("Try 'pdf2dcm -h' for more information.");
        System.exit(1);
    }

    void convert(String filename, String path) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

}
packagedicomizer;
导入java.io.BufferedInputStream;
导入java.io.BufferedOutputStream;
导入java.io.File;
导入java.io.FileInputStream;
导入java.io.FileOutputStream;
导入java.io.IOException;
导入java.io.InputStream;
导入java.util.Date;
导入java.util.Enumeration;
导入java.util.List;
导入java.util.Properties;
导入org.apache.commons.cli.CommandLine;
导入org.apache.commons.cli.GnuParser;
导入org.apache.commons.cli.HelpFormatter;
导入org.apache.commons.cli.OptionBuilder;
导入org.apache.commons.cli.Options;
导入org.apache.commons.cli.ParseException;
导入org.dcm4che2.data.basicdicmobject;
导入org.dcm4che2.data.dicom对象;
导入org.dcm4che2.data.Tag;
导入org.dcm4che2.data.UID;
导入org.dcm4che2.data.VR;
导入org.dcm4che2.io.dicom输出流;
导入org.dcm4che2.util.UIDUtils;
/**
*@作者gunter zeilinger(gunterze@gmail.com)
*@version$Revision:12456$$日期:2009-11-26 13:51:53+0100(2009年11月26日星期四)$
*@自2006年4月1日起
*
*/
公共类Pdf2Dcm扩展接口{
专用静态最终字符串用法=
“pdf2dcm[选项]”;
私有静态最终字符串描述=
将PDF文档封装到DICOM对象中。\n选项:;
私有静态最终字符串示例=
“pdf2dcm-c pdf2dcm.cfg report.pdf report.dcm\n”+
“=>将PDF Document report.PDF压缩到存储到的DICOM对象中”+
“report.dcm使用配置中指定的DICOM属性值”+
“文件pdf2dcm.cfg。”;
私有字符串transferSyntax=UID.explicitvrlittlendian;
私有字符串charset=“ISO_IR 100”;
私有int bufferSize=8192;
私有属性cfg=新属性();
公共Pdf2Dcm(){
试一试{
load(Pdf2Dcm.class.getResourceAsStream(“Pdf2Dcm.cfg”);
}捕获(例外e){
抛出新的运行时异常(e);
}
}
/*公共Pdf2Dcm(字符串文件名、字符串路径){
this.filename=文件名;
this.path=path;
试一试{
load(Pdf2Dcm.class.getResourceAsStream(“Pdf2Dcm.cfg”);
}捕获(例外e){
抛出新的运行时异常(e);
}
}*/
公共最终无效字符集(字符串字符集){
this.charset=charset;
}
公共最终无效setBufferSize(int bufferSize){
如果(缓冲区大小<64){
抛出新的IllegalArgumentException(“bufferSize:+bufferSize”);
}
this.bufferSize=bufferSize;
}
公共最终void setTransferSyntax(字符串transferSyntax){
this.transferSyntax=transferSyntax;
}
私有void loadConfiguration(文件cfgFile)引发IOException{
属性tmp=新属性(cfg);
InputStream in=new BufferedInputStream(new FileInputStream(cfgFile));
试一试{
tmp.荷载(in);
}最后{
in.close();
}
cfg=tmp;
}
public void convert(文件pdfFile、文件dcmFile)引发IOException{
DicomObject attrs=新的基本对象();
attrs.putString(Tag.SpecificCharacterSet、VR.CS、charset);
attrs.putSequence(Tag.ConceptNameCodeSequence);
对于(枚举en=cfg.propertyNames();en.hasMoreElements();){
字符串键=(字符串)en.nextElement();
attrs.putString(Tag.toTagPath(key),null,cfg.getProperty(key));
}
ensureUID(属性,标记.StudyInstanceUID);
ensureUID(属性、标签、序列安装UID);
ensureUID(attrs,Tag.SOPInstanceUID);
现在日期=新日期();
属性putDate(Tag.InstanceCreationDate,VR.DA,now);
attrs.putDate(Tag.InstanceCreationTime,VR.TM,now);
attrs.initFileMetaInformation(transferSyntax);
FileInputStream pdfInput=新的FileInputStream(pdfFile);
FileOutputStream fos=新的FileOutputStream(dcmFile);
BufferedOutputStream bos=新的BufferedOutputStream(fos);
DicomOutputStream dos=新的DicomOutputStream(bos);
试一试{
dos.writeFileMetaInformation(属性);
dos.writeDataset(属性子集(Tag.SpecificCharacterSet,
Tag.enclosedDocument),transferSyntax);
int pdfLen=(int)pdfFile.length();
dos.writeHeader(Tag.enclosureddocument,VR.OB,(pdfLen+1)和~1);
字节[]b=新字节[bufferSize];
INTR;
而((r=pdfInput.read(b))>0){
写(b,0,r);
}
如果((pdfLen&1)!=0){
dos.write(0);
}
dos.writeDataset(属性子集(Tag.enclosedDocument,-1),
转换语法);
}最后{
dos.close();
pdfInput.close();
}
}    
私有void ensureUID(双对象属性,int标记){
如果(!attrs.containsValue(标记)){
attrs.putString(标记,VR.UI,UIDUtils.createUID());
}        
}
公共静态void main(字符串[]args){
试一试{
//命令行cl=parse(args);
Pdf2Dcm Pdf2Dcm=新的Pdf2Dcm();
//如果(第1.1条选择权(“ivrle”)){
//pdf2Dcm.setTransferSyntax(UID.ImplicitVRLittleEndian);
//}
//如果(第1条“选择权”(“cs”)){
//pdf2Dcm.setCharset(cl.getOptionValue(“cs”);
//}
//如果(第1条“选择权”(“bs”)){
//pdf2Dcm.setBufferSize(Integer.parseInt(cl.getOptionValue(“bs”)));
//}
//如果(第三条选择权(“c”)){
//loadConfiguration(新文件(cl.getOptionValue(“c”));
//}
//如果(第1.1条选项(“uid”)){
//UIDUtils.setRoot(cl.getOptionValue(“uid”));
//}
//List argList=cl.getArgList();
//File pdfFile=新文件((字符串)argList
    package dicomizer;

import java.io.File;
import javax.swing.JFileChooser;

/**
 *
 * @author Dell
 */
public class Interface extends javax.swing.JFrame{
    public static String path;
    //String[] file;
    public static String filename;
    String extension;
     String aetitle;
     String hostName;
     int portNumber;

    /**
     * Creates new form Interface
     */
    public Interface() {
        initComponents();
    }

    /**
     * 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">                          
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        aet = new javax.swing.JTextField();
        host = new javax.swing.JTextField();
        port = new javax.swing.JTextField();
        echo = new javax.swing.JButton();
        sav = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jPanel1 = new javax.swing.JPanel();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        ConvertToDicomFile = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        browse = new javax.swing.JButton();
        save = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("DICOMIZER");

        jLabel1.setText("AET :");

        jLabel2.setText("HOST :");

        jLabel3.setText("PORT :");

        aet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aetActionPerformed(evt);
            }
        });

        host.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hostActionPerformed(evt);
            }
        });

        port.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                portActionPerformed(evt);
            }
        });

        echo.setText("ECHO");

        sav.setText("SAVE");

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
                        .addGap(45, 45, 45))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(port, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
                            .addComponent(host)
                            .addComponent(aet))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addComponent(echo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(sav)
                        .addGap(61, 61, 61))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(aet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(29, 29, 29)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(host, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(35, 35, 35)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(port, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sav)
                    .addComponent(echo))
                .addGap(35, 35, 35)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(19, 19, 19))
        );

        jTabbedPane1.addTab("Configuration", jPanel2);

        ConvertToDicomFile.setText("Convert To DICOM File");
        ConvertToDicomFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConvertToDicomFileActionPerformed(evt);
            }
        });

        jLabel4.setText("file to convert");

        jLabel5.setText("destination folder");

        browse.setText("Browse");
        browse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                browseActionPerformed(evt);
            }
        });

        save.setText("Save");
        save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(ConvertToDicomFile, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel5)
                            .addGap(18, 18, 18)
                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel4)
                            .addGap(31, 31, 31)
                            .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(browse, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(save, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(45, 45, 45)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(browse))
                .addGap(24, 24, 24)
                .addComponent(ConvertToDicomFile)
                .addGap(37, 37, 37)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(save))
                .addContainerGap(224, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Dicomizer", jPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING)
        );

        pack();
    }// </editor-fold>                        

    private void browseActionPerformed(java.awt.event.ActionEvent evt) {                                       

         JFileChooser chooser = new JFileChooser();
         chooser.showOpenDialog(null);
         File f =chooser.getSelectedFile();
         filename = f.getAbsolutePath();
         jTextField4.setText(filename);
         int index = filename.lastIndexOf(".");
         extension = filename.substring(index+1,filename.length());
         //file = filename.;
         //System.out.println(extension);
         //System.out.println(filename);
    }                                      

    private void ConvertToDicomFileActionPerformed(java.awt.event.ActionEvent evt) {                                                   
        // TODO add your handling code here:
        if (extension.equals("xlsx") || extension.equals("pdf") || extension.equals("docx"))
        {
               **// here I want to to call the file Pdf2Dcm.java** 



        }
        else if (extension.equals("png") || extension.equals("jpg"))
        {

        }
        else 
        {
            System.out.println("Format not supported");
        }
    }                                                  

    private void saveActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
        JFileChooser chooser = new JFileChooser();
        chooser.showSaveDialog(null);
        File f = chooser.getCurrentDirectory();
        path =f.getAbsolutePath();
        int index= filename.lastIndexOf("'\'");
               path=path+filename.substring(index+1, filename.lastIndexOf("."))+".dcm";
              jTextField5.setText(path);
        //System.out.println(path);
    }                                    

    private void aetActionPerformed(java.awt.event.ActionEvent evt) {                                    
        // TODO add your handling code here:
        //aetitle = aet.getAETiltle();

    }                                   

    private void hostActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
        //hostName = host.getHostname();
    }                                    

    private void portActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
        //portNumber = port.getPort();

    }                                    

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Interface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Interface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Interface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Interface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Interface().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton ConvertToDicomFile;
    private javax.swing.JTextField aet;
    private javax.swing.JButton browse;
    private javax.swing.JButton echo;
    private javax.swing.JTextField host;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField port;
    private javax.swing.JButton sav;
    private javax.swing.JButton save;
    // End of variables declaration                   
}
Pdf2Dcm.main(args);