⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getrecfiles.java

📁 局域网聊天工具,学习java桌面应用程序的好例子,(代传)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    .addComponent(jLabel9)                    .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)                    .addGroup(jPanel3Layout.createSequentialGroup()                        .addComponent(jLabel1)                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                        .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE))                    .addGroup(jPanel3Layout.createSequentialGroup()                        .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE))                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()                        .addComponent(jLabel5)                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                        .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)))                .addContainerGap())        );        jPanel3Layout.setVerticalGroup(            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel3Layout.createSequentialGroup()                .addComponent(jLabel7)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jLabel8)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jLabel9)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jLabel10)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel11)                    .addComponent(jLabel12))                .addGap(11, 11, 11)                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel2)                    .addComponent(jLabel1))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel3)                    .addComponent(jLabel4))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel5)                    .addComponent(jLabel6))                .addContainerGap(70, Short.MAX_VALUE))        );        getContentPane().add(jPanel3, java.awt.BorderLayout.EAST);        jMenu1.setText("系统");        jMenuItem3.setText("发送");        jMenu1.add(jMenuItem3);        jMenuItem1.setText("退出");        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jMenuItem1ActionPerformed(evt);            }        });        jMenu1.add(jMenuItem1);        jMenuBar1.add(jMenu1);        jMenu2.setText("聊天");        jMenuItem2.setText("和对方聊天");        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jMenuItem2ActionPerformed(evt);            }        });        jMenu2.add(jMenuItem2);        jMenuBar1.add(jMenu2);        setJMenuBar(jMenuBar1);        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();        setBounds((screenSize.width-434)/2, (screenSize.height-369)/2, 434, 369);    }// </editor-fold>//GEN-END:initComponentsprivate void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed// TODO add your handling code here:    this.exit();}//GEN-LAST:event_jMenuItem1ActionPerformedprivate void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed// TODO add your handling code here:    /*if (!UtilityMsgSendRecv.newWindow(            (String) this.clientConnect.getInetAddress().getHostAddress()            , null)) {        UtilityGui.showNotice(this, "窗口已打开!");    }*/}//GEN-LAST:event_jMenuItem2ActionPerformedprivate void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed// TODO add your handling code here:    this.exit();}//GEN-LAST:event_jButton1ActionPerformedprivate void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed// TODO add your handling code here:    //获取用户选择的文件    int choice=-1;    if(this.guiChooseAll.isSelected()){        choice=this.flist.getFiles().size();    }    else if(this.guiFiles.getSelectedValue()!=null){        choice=UtilityGlobal.atoi(                ((String) this.guiFiles.getSelectedValue()).trim());    }else {        UtilityGui.showNotice(this, "请标记您需要接收的文件!");        return;    }        //接收的文件放在哪里。    String savePath;    if((savePath=UtilityGui.chooseFile(this, false))==null)return;    this.setVisible(false);    new RecvingFile(this.flist,choice,savePath,this,            this.guiCoverExist.isSelected()).setVisible(true);}//GEN-LAST:event_jButton2ActionPerformedprivate void guiFilesValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_guiFilesValueChanged// TODO add your handling code here:    int selectLen=this.guiFiles.getSelectedIndices().length;    if(selectLen==1){        FileNode fnode=this.flist.getFiles().get(                this.guiFiles.getSelectedIndex());        if(fnode.getFileKind()==GlobalConstant.IPMSG_FILE_DIR)            this.jLabel2.setText("目录");        else if(fnode.getFileKind()==GlobalConstant.IPMSG_FILE_REGULAR)            this.jLabel2.setText("普通文件");        else this.jLabel2.setText("未知类型");                this.jLabel6.setText(fnode.getFileLen()+" B");        this.jLabel4.setText(this.getSize(fnode.getFileLen()));    }}//GEN-LAST:event_guiFilesValueChangedprivate void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing// TODO add your handling code here:    this.exit();}//GEN-LAST:event_formWindowClosing    // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JCheckBox guiChooseAll;    private javax.swing.JCheckBox guiCoverExist;    private javax.swing.JList guiFiles;    private javax.swing.JButton jButton1;    private javax.swing.JButton jButton2;    private javax.swing.JLabel jLabel1;    private javax.swing.JLabel jLabel10;    private javax.swing.JLabel jLabel11;    private javax.swing.JLabel jLabel12;    private javax.swing.JLabel jLabel2;    private javax.swing.JLabel jLabel3;    private javax.swing.JLabel jLabel4;    private javax.swing.JLabel jLabel5;    private javax.swing.JLabel jLabel6;    private javax.swing.JLabel jLabel7;    private javax.swing.JLabel jLabel8;    private javax.swing.JLabel jLabel9;    private javax.swing.JMenu jMenu1;    private javax.swing.JMenu jMenu2;    private javax.swing.JMenuBar jMenuBar1;    private javax.swing.JMenuItem jMenuItem1;    private javax.swing.JMenuItem jMenuItem2;    private javax.swing.JMenuItem jMenuItem3;    private javax.swing.JPanel jPanel1;    private javax.swing.JPanel jPanel2;    private javax.swing.JPanel jPanel3;    private javax.swing.JScrollPane jScrollPane1;    private javax.swing.JSeparator jSeparator1;    // End of variables declaration//GEN-END:variables    public void exit(){        Command com=new Command(GlobalConstant.IPMSG_RELEASEFILES);        com.setIp(this.flist.getIp());        com.setAdditional(this.flist.getPacketNo()+"");        UtilityNet.sendUdpPacket(com);        this.dispose();    }        private String getSize(long size){        if(size>>12<=0)return size+" B";        else if(size>>22<=0) return (size>>10)+" KB";        else if(size>>32<=0) return (size>>20)+" MB";        else return (size>>30)+" GB";    }    public void enableVisible() {        this.guiFiles.setListData(flist.exportFileList());        if(this.guiFiles.getModel().getSize()==0)this.dispose();        else this.setVisible(true);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -