📄 newdialog.java
字号:
package com.network.flashget;
import java.awt.event.*;
import java.net.*;
import javax.swing.JFileChooser;
import java.io.File;
import javax.swing.JOptionPane;
/**
*
* @author Administrator
*/
public class NewDialog extends javax.swing.JDialog implements ActionListener
{
/** Creates new form NewJDialog1 */
public NewDialog(java.awt.Frame parent, boolean modal)
{
super(parent, modal);
this.setBounds(200,200,400,300);
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.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jSpinner1 = new javax.swing.JSpinner();
jLabel6 = new javax.swing.JLabel();
fileDirectoryField = new javax.swing.JTextField();
ipField = new javax.swing.JTextField();
fileNameField = new javax.swing.JTextField();
confirmButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
directoryButton = new javax.swing.JButton();
confirmButton.addActionListener(this);
cancelButton.addActionListener(this);
directoryButton.addActionListener(this);
getContentPane().setLayout(null);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("\u6dfb\u52a0\u65b0\u7684\u4e0b\u8f7d\u4efb\u52a1");
setResizable(false);
jLabel1.setText("\u7f51\u5740");
getContentPane().add(jLabel1);
jLabel1.setBounds(10, 20, 70, 15);
jLabel3.setText("\u53e6\u5b58\u5230");
getContentPane().add(jLabel3);
jLabel3.setBounds(10, 50, 70, 20);
jLabel4.setText("\u91cd\u547d\u540d");
getContentPane().add(jLabel4);
jLabel4.setBounds(10, 80, 60, 20);
jLabel5.setText("\u6587\u4ef6\u5206\u6210");
getContentPane().add(jLabel5);
jLabel5.setBounds(10, 120, 70, 20);
getContentPane().add(jSpinner1);
jSpinner1.setBounds(80, 120, 110, 20);
jLabel6.setText("\u540c\u65f6\u4e0b\u8f7d");
getContentPane().add(jLabel6);
jLabel6.setBounds(200, 120, 80, 20);
getContentPane().add(fileDirectoryField);
fileDirectoryField.setBounds(80, 50, 240, 20);
getContentPane().add(ipField);
ipField.setBounds(80, 20, 240, 20);
getContentPane().add(fileNameField);
fileNameField.setBounds(80, 80, 240, 20);
confirmButton.setText("\u786e\u5b9a");
getContentPane().add(confirmButton);
confirmButton.setBounds(170, 200, 70, 23);
cancelButton.setText("\u53d6\u6d88");
getContentPane().add(cancelButton);
cancelButton.setBounds(280, 200, 60, 23);
directoryButton.setText(". . .");
getContentPane().add(directoryButton);
directoryButton.setBounds(340, 50, 30, 23);
}
// 变量声明 - 不进行修改
public javax.swing.JButton cancelButton;
public javax.swing.JButton confirmButton;
public javax.swing.JButton directoryButton;
public javax.swing.JTextField fileDirectoryField;
public javax.swing.JTextField fileNameField;
public javax.swing.JTextField ipField;
public javax.swing.JLabel jLabel1;
public javax.swing.JLabel jLabel3;
public javax.swing.JLabel jLabel4;
public javax.swing.JLabel jLabel5;
public javax.swing.JLabel jLabel6;
public javax.swing.JSpinner jSpinner1;
// 变量声明结束
/**
*定义按钮事件
**/
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==confirmButton)
{
try
{
URL url = new URL(ipField.getText());
String fileName = fileNameField.getText();
String fileDirectory = fileDirectoryField.getText()+"\\"+fileName;
System.out.println(fileDirectory);
int threadNum = ((Integer)jSpinner1.getValue()).intValue();
GetFile getFile = new GetFile(url,threadNum,fileDirectory,fileName);
getFile.connectTaskManager();
}
catch(Exception ee)
{
//
}
finally
{
this.dispose();
}
}
if(e.getSource()==cancelButton)
{
this.dispose();
}
if(e.getSource()==directoryButton)
{
JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(new File(".\\DownLoads\\"));
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if(fileChooser.showSaveDialog(null)==JFileChooser.CANCEL_OPTION)
{
return;
}
String directory = fileChooser.getSelectedFile().getAbsolutePath();
fileDirectoryField.setText(directory);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -