📄 addtaskframe.java~11~
字号:
package mydownloader.ui;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFileChooser;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2009</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class AddTaskFrame extends JFrame {
private String filePath;
public AddTaskFrame() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
this.setResizable(false);
this.setSize(600,200);
this.setLocation(300,200);
this.setTitle("MyDownloader-添加任务");
jLabel1.setText("地址:");
jLabel1.setBounds(new Rectangle(35, 29, 42, 15));
jLabel2.setText("保存路径:");
jLabel2.setBounds(new Rectangle(35, 97, 64, 15));
txtFilePath.setBounds(new Rectangle(63, 126, 360, 20));
btnFile.setBounds(new Rectangle(442, 126, 81, 23));
btnFile.setText("浏览");
btnFile.addActionListener(new AddTaskFrame_btnFile_actionAdapter(this));
btnStart.setBounds(new Rectangle(214, 163, 81, 23));
btnStart.setText("开始下载");
btnStart.addActionListener(new AddTaskFrame_btnStart_actionAdapter(this));
this.getContentPane().add(jLabel1);
this.getContentPane().add(txtURL);
this.getContentPane().add(jLabel2);
this.getContentPane().add(txtFilePath);
this.getContentPane().add(btnFile);
this.getContentPane().add(btnStart);
txtURL.setBounds(new Rectangle(63, 52, 360, 20));
}
JLabel jLabel1 = new JLabel();
JTextField txtURL = new JTextField();
JLabel jLabel2 = new JLabel();
JTextField txtFilePath = new JTextField();
JButton btnFile = new JButton();
JButton btnStart = new JButton();
public void btnFile_actionPerformed(ActionEvent e) {
JFileChooser jFileChooser = new JFileChooser("D:\\");
int result;
result = jFileChooser.showSaveDialog(this);
jFileChooser.setFileSelectionMode(jFileChooser.DIRECTORIES_ONLY);
if(result == JFileChooser.APPROVE_OPTION){
this.filePath = filePath;
this.txtFilePath.setText(this.filePath);
}
else{
System.out.println("bbb");
}
}
public void btnStart_actionPerformed(ActionEvent e) {
}
}
class AddTaskFrame_btnStart_actionAdapter implements ActionListener {
private AddTaskFrame adaptee;
AddTaskFrame_btnStart_actionAdapter(AddTaskFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnStart_actionPerformed(e);
}
}
class AddTaskFrame_btnFile_actionAdapter implements ActionListener {
private AddTaskFrame adaptee;
AddTaskFrame_btnFile_actionAdapter(AddTaskFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnFile_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -