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

📄 downloadmanager.java

📁 一个网络上传下载器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * DownloadManager.java * * Created on 2007年10月28日, 下午3:16 */package DownloadManager;import java.util.*;import javax.swing.*;import javax.swing.event.*;import java.awt.*;import java.awt.event.*;import java.net.*;/** this class is UI that download files by URL@author Liu Yu Yang */public class DownloadManager extends javax.swing.JFrame        implements Observer {    /**     Constructor of DownloadManager     */    public DownloadManager() {        tableModel = new DownloadsTableModel();        initComponents();        setDownloadsTableModel();        pack();    }    /** 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="Generated Code">//GEN-BEGIN:initComponents    private void initComponents() {        jPanel1 = new javax.swing.JPanel();        addDownloadButton = new javax.swing.JButton();        removeDownloadButton = new javax.swing.JButton();        showDetailsButton = new javax.swing.JButton();        controlButtonPanel = new javax.swing.JPanel();        startButton = new javax.swing.JButton();        pauseButton = new javax.swing.JButton();        resumeButton = new javax.swing.JButton();        cancelButton = new javax.swing.JButton();        downloadsPanel = new javax.swing.JPanel();        jScrollPane1 = new javax.swing.JScrollPane();        jTable1 = new javax.swing.JTable();        jPanel2 = new javax.swing.JPanel();        jLabel1 = new javax.swing.JLabel();        jLabel2 = new javax.swing.JLabel();        jLabel3 = new javax.swing.JLabel();        txtURL = new javax.swing.JTextField();        txtSaveTo = new javax.swing.JTextField();        txtRenameAs = new javax.swing.JTextField();        jLabel5 = new javax.swing.JLabel();        threadsSpinner = new javax.swing.JSpinner();        browseButton = new javax.swing.JButton();        jMenuBar2 = new javax.swing.JMenuBar();        fileMenuItem1 = new javax.swing.JMenu();        menuItemCodeManager = new javax.swing.JMenuItem();        jSeparator2 = new javax.swing.JSeparator();        fileExitMenuItem1 = new javax.swing.JMenuItem();        editMenuItem1 = new javax.swing.JMenu();        jMenuItem1 = new javax.swing.JMenuItem();        controlMenuItem = new javax.swing.JMenu();        startMenuItem = new javax.swing.JMenuItem();        pauseMenuItem = new javax.swing.JMenuItem();        resumeMenuItem = new javax.swing.JMenuItem();        stopMenuItem = new javax.swing.JMenuItem();        helpMenuItem = new javax.swing.JMenu();        aboutMenuItem = new javax.swing.JMenuItem();        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);        setTitle("DownloadManagers");        setLocationByPlatform(true);        setName("Form"); // NOI18N        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());        jPanel1.setName("jPanel1"); // NOI18N        addDownloadButton.setText("Add");        addDownloadButton.setName("addDownloadButton"); // NOI18N        addDownloadButton.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                addDownloadButtonActionPerformed(evt);            }        });        removeDownloadButton.setText("Remove");        removeDownloadButton.setName("removeDownloadButton"); // NOI18N        removeDownloadButton.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                removeDownloadButtonActionPerformed(evt);            }        });        showDetailsButton.setText("Details");        showDetailsButton.setName("showDetailsButton"); // NOI18N        controlButtonPanel.setName("controlButtonPanel"); // NOI18N        startButton.setText("Start");        startButton.setName("startButton"); // NOI18N        startButton.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                startButtonActionPerformed(evt);            }        });        pauseButton.setText("Pause");        pauseButton.setName("pauseButton"); // NOI18N        pauseButton.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                pauseButtonActionPerformed(evt);            }        });        resumeButton.setText("Resume");        resumeButton.setName("resumeButton"); // NOI18N        resumeButton.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                resumeButtonActionPerformed(evt);            }        });        cancelButton.setText("Stop");        cancelButton.setName("cancelButton"); // NOI18N        cancelButton.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                cancelButtonActionPerformed(evt);            }        });        javax.swing.GroupLayout controlButtonPanelLayout = new javax.swing.GroupLayout(controlButtonPanel);        controlButtonPanel.setLayout(controlButtonPanelLayout);        controlButtonPanelLayout.setHorizontalGroup(            controlButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(controlButtonPanelLayout.createSequentialGroup()                .addComponent(startButton)                .addGap(30, 30, 30)                .addComponent(pauseButton)                .addGap(38, 38, 38)                .addComponent(resumeButton)                .addGap(41, 41, 41)                .addComponent(cancelButton)                .addContainerGap(284, Short.MAX_VALUE))        );        controlButtonPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancelButton, pauseButton, resumeButton, startButton});        controlButtonPanelLayout.setVerticalGroup(            controlButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(controlButtonPanelLayout.createSequentialGroup()                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                .addGroup(controlButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(startButton)                    .addComponent(pauseButton)                    .addComponent(resumeButton)                    .addComponent(cancelButton)))        );        downloadsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Downloads"));        downloadsPanel.setName("downloadsPanel"); // NOI18N        jScrollPane1.setName("jScrollPane1"); // NOI18N        jTable1.setModel(tableModel);        jTable1.setName("jTable1"); // NOI18N        jScrollPane1.setViewportView(jTable1);        javax.swing.GroupLayout downloadsPanelLayout = new javax.swing.GroupLayout(downloadsPanel);        downloadsPanel.setLayout(downloadsPanelLayout);        downloadsPanelLayout.setHorizontalGroup(            downloadsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(downloadsPanelLayout.createSequentialGroup()                .addContainerGap()                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)                .addContainerGap())        );        downloadsPanelLayout.setVerticalGroup(            downloadsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(downloadsPanelLayout.createSequentialGroup()                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)                .addContainerGap())        );        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);        jPanel1.setLayout(jPanel1Layout);        jPanel1Layout.setHorizontalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel1Layout.createSequentialGroup()                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addGroup(jPanel1Layout.createSequentialGroup()                        .addContainerGap()                        .addComponent(addDownloadButton)                        .addGap(18, 18, 18)                        .addComponent(removeDownloadButton)                        .addGap(18, 18, 18)                        .addComponent(showDetailsButton))                    .addComponent(downloadsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                    .addGroup(jPanel1Layout.createSequentialGroup()                        .addContainerGap()                        .addComponent(controlButtonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))                .addContainerGap())        );        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {addDownloadButton, removeDownloadButton, showDetailsButton});        jPanel1Layout.setVerticalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel1Layout.createSequentialGroup()                .addContainerGap(38, Short.MAX_VALUE)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(removeDownloadButton)                    .addComponent(showDetailsButton)                    .addComponent(addDownloadButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(18, 18, 18)                .addComponent(downloadsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(controlButtonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(24, 24, 24))        );        jPanel2.setName("jPanel2"); // NOI18N        jLabel1.setText("URL:");        jLabel1.setName("jLabel1"); // NOI18N        jLabel2.setText("Save To:");        jLabel2.setName("jLabel2"); // NOI18N        jLabel3.setText("Rename As:");        jLabel3.setName("jLabel3"); // NOI18N        txtURL.setName("txtURL"); // NOI18N        txtSaveTo.setName("txtSaveTo"); // NOI18N        txtRenameAs.setName("txtRenameAs"); // NOI18N        jLabel5.setText("Set threads:");        jLabel5.setName("jLabel5"); // NOI18N        threadsSpinner.setName("threadsSpinner"); // NOI18N        browseButton.setText("Browse");        browseButton.setName("browseButton"); // NOI18N        browseButton.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                browseButtonActionPerformed(evt);            }        });        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(22, 22, 22)                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)                    .addComponent(jLabel1)                    .addComponent(jLabel3)                    .addComponent(jLabel2))                .addGap(18, 18, 18)                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(txtRenameAs, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)                    .addComponent(txtURL, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)                    .addGroup(jPanel2Layout.createSequentialGroup()                        .addComponent(txtSaveTo, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)                        .addComponent(browseButton)                        .addGap(11, 11, 11)))                .addGap(15, 15, 15)                .addComponent(jLabel5)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                .addComponent(threadsSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(96, 96, 96))        );        jPanel2Layout.setVerticalGroup(            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel2Layout.createSequentialGroup()                .addContainerGap()                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel1)                    .addComponent(txtURL, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(txtSaveTo, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)                    .addComponent(jLabel2)                    .addComponent(browseButton)                    .addComponent(jLabel5)                    .addComponent(threadsSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel3)                    .addComponent(txtRenameAs))                .addGap(20, 20, 20))        );        jMenuBar2.setName("jMenuBar1"); // NOI18N        fileMenuItem1.setText("File");        fileMenuItem1.setName("fileMenuItem"); // NOI18N        menuItemCodeManager.setText("CodeManager");        menuItemCodeManager.setName("menuItemCodeManager"); // NOI18N        menuItemCodeManager.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                menuItemCodeManagerActionPerformed(evt);            }        });        fileMenuItem1.add(menuItemCodeManager);        jSeparator2.setName("jSeparator2"); // NOI18N        fileMenuItem1.add(jSeparator2);        fileExitMenuItem1.setText("Exit");        fileExitMenuItem1.setName("fileExitMenuItem"); // NOI18N        fileExitMenuItem1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                fileExitMenuItem1ActionPerformed(evt);            }        });        fileMenuItem1.add(fileExitMenuItem1);        jMenuBar2.add(fileMenuItem1);        editMenuItem1.setText("Edit");        editMenuItem1.setName("editMenuItem"); // NOI18N        jMenuItem1.setText("Add");        jMenuItem1.setName("jMenuItem1"); // NOI18N

⌨️ 快捷键说明

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