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

📄 input_window.java

📁 文本文档中的报表数据转换为数据库中的记录
💻 JAVA
字号:
package MainWindow;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import ReadToDB.readIntoDB;

public class Input_Window implements ActionListener{

	Frame frame;
	Button b_select,b_ok;
	TextField tf;
	FileDialog fd_load;
	
	public Input_Window() {

		frame=new Frame("文件写入数据库");
		b_ok=new Button("开始写入");
		b_select=new Button("选择文件");
		tf=new TextField("",30);
		fd_load=new FileDialog(frame,"打开文件",FileDialog.LOAD);
		
		b_ok.addActionListener(this);
		b_select.addActionListener(this);
		
		frame.add(tf,BorderLayout.NORTH);
		frame.add(b_ok,BorderLayout.SOUTH);
	    frame.add(b_select,BorderLayout.CENTER);
	    
	    frame.pack();
	    frame.setVisible(true);
	    frame.addWindowListener(new WindowAdapter()
	    {

			public void windowClosing(WindowEvent arg0) {

				System.exit(1);	
			}
			});
				
	}

	
	public static void main(String[] args) {
		new Input_Window();

	}

	public void actionPerformed(ActionEvent e) {

		Object temp=e.getSource();
		if(temp==b_select)
		{
			fd_load.setVisible(true);
			String fpath=fd_load.getDirectory();
			String fname=fd_load.getFile();
			tf.setText(fpath + fname);
			
		}
		if(temp==b_ok)
		{
			new readIntoDB().init(this.encodePath(tf.getText()));
			}
		}
		
	

	public String encodePath(String path)
	{
		return path.replace("\\", "/");
	}
}

⌨️ 快捷键说明

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