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

📄 adddialog.java

📁 java做的下载工具
💻 JAVA
字号:
import java.awt.*;
import javax.swing.*;
import java.net.*;
import java.awt.event.*;
import java.util.*;
public class AddDialog extends JDialog{
	JPanel over,p1,p2,p3,p4,p5;
	JLabel l1,l2,l3,l4;
	JTextField t1,t2,t3,t4;
	JButton ok,cancel;
	Container contentPane;
	Listener listener;
	public AddDialog(JFrame f){
		super(f,"Add...");
		init();
	}
	public void init(){
              
		listener=new Listener();
		contentPane=getContentPane();
		ok=new JButton("OK");
		cancel=new JButton("Cancel");
		ok.addActionListener(listener);
		cancel.addActionListener(listener);
		over=new JPanel();
		p1=new JPanel();
		p2=new JPanel();
		p3=new JPanel();
		p4=new JPanel();
		p5=new JPanel();
		l1=new JLabel("     URL:     ");
		l2=new JLabel("  Save To:  ");
		l3=new JLabel("Rename As:");
		l4=new JLabel("  Comment:  ");
		t1=new JTextField(20);
		t2=new JTextField(20);
		t3=new JTextField(20);
		t4=new JTextField(20);
		over.setLayout(new FlowLayout());
		p1.setLayout(new FlowLayout(5));
		p2.setLayout(new FlowLayout(5));
		p3.setLayout(new FlowLayout(5));
		p4.setLayout(new FlowLayout(5));
		p5.setLayout(new FlowLayout(5));
		p1.add(l1);
		p1.add(t1);
		p2.add(l2);
		p2.add(t2);
		p3.add(l3);
		p3.add(t3);
		p4.add(l4);
		p4.add(t4);
		p5.add(ok);
		p5.add(cancel);
		over.add(p1);
		over.add(p2);
		over.add(p3);
		over.add(p4);
		over.add(p5);
		contentPane.add(over,BorderLayout.CENTER);
		//contentPane.add(p5,BorderLayout.SOUTH);
	}
	class Listener implements ActionListener{
		public void actionPerformed(ActionEvent e){
			String command=e.getActionCommand();
			if(command=="OK"){
			     Utility.url=t1.getText();
		             GetRequest gr=new GetRequest();
                             gr.start();   
                            if(t2.getText().length()!=0)   
                              Utility.defaultDirectory=t2.getText();
				System.out.println("URL"+Utility.url);
			    //System.out.println("Directory"+Utility.defaultDirectory);
			    if(Utility.url.length()!=0)
			      
				dispose();
                            
                           
			}
			else if(command=="Cancel"){
				dispose();
			}
		}
       }
       
	public void center(){
		Dimension screenSize,size;
		screenSize=Toolkit.getDefaultToolkit().getScreenSize();
		size=this.getSize();
		if(size.height > screenSize.height){
           size.height=screenSize.height;
        }
        if(size.width >screenSize.width){
           size.width=screenSize.width;
        }
        this.setLocation((screenSize.width - size.width)/2,(screenSize.height - size.height)/2);
    }
}

⌨️ 快捷键说明

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