package pkg;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JFileChooser;
/**
* @author ulicwh-308
*
*/
public class Test extends JFrame{
/**
*
*/
private static final long serialVersionUID = 1L;
/*
* *
*
*/
//static JFrame jf=new JFrame("JAVA查询小工具");
static JButton jb=new JButton("find");
static JButton jb1=new JButton("submit");
//static JButton jb=new JButton("请点击");
static Label lb=new Label("select:");
//static TextField tf=new TextField();
static String fileStr="";
static File location=new File("D://work//code//renyb_life_main//life_code");
JFileChooser jfc=new JFileChooser("D:\\");
public Test() {
// TODO Auto-generated constructor stub
}
public static void main(String [] args)
{
//jf.add(jb);
//jf.add(lb);
// tf.setSize(30, 30);
//jf.add(tf);
//jf.setSize(500, 500);
//jf.setVisible(true);
Test test =new Test();
test.initFrame();
test.setVisible(true);
}
private void initFrame()
{ this.setName("JAVA小工具");
this.setSize(400,400);
this.setLayout(null);
jb.setBounds(200, 200, 100, 30);
jb.setVisible(true);
jb.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
Find find=new Find();
find.findInDir(location);
}
}
);
this.add(jb);
lb.setBounds(120, 100, 60, 30);
lb.setVisible(true);
this.add(lb);
jfc.setDialogType(JFileChooser.OPEN_DIALOG);
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
this.add(jfc);
jfc.setVisible(true);
jb1.setBounds(200, 100, 100, 30);
jb1.setVisible(true);
jb1.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(jfc.showDialog(null, "确定")==jfc.APPROVE_OPTION)
{
fileStr=jfc.getCurrentDirectory().toString().trim();
//System.out.print(jfc.getCurrentDirectory().toString().trim());
location=new File(fileStr);
}
}
}
);
this.add(jb1);
}
}
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JFileChooser;
/**
* @author ulicwh-308
*
*/
public class Test extends JFrame{
/**
*
*/
private static final long serialVersionUID = 1L;
/*
* *
*
*/
//static JFrame jf=new JFrame("JAVA查询小工具");
static JButton jb=new JButton("find");
static JButton jb1=new JButton("submit");
//static JButton jb=new JButton("请点击");
static Label lb=new Label("select:");
//static TextField tf=new TextField();
static String fileStr="";
static File location=new File("D://work//code//renyb_life_main//life_code");
JFileChooser jfc=new JFileChooser("D:\\");
public Test() {
// TODO Auto-generated constructor stub
}
public static void main(String [] args)
{
//jf.add(jb);
//jf.add(lb);
// tf.setSize(30, 30);
//jf.add(tf);
//jf.setSize(500, 500);
//jf.setVisible(true);
Test test =new Test();
test.initFrame();
test.setVisible(true);
}
private void initFrame()
{ this.setName("JAVA小工具");
this.setSize(400,400);
this.setLayout(null);
jb.setBounds(200, 200, 100, 30);
jb.setVisible(true);
jb.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
Find find=new Find();
find.findInDir(location);
}
}
);
this.add(jb);
lb.setBounds(120, 100, 60, 30);
lb.setVisible(true);
this.add(lb);
jfc.setDialogType(JFileChooser.OPEN_DIALOG);
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
this.add(jfc);
jfc.setVisible(true);
jb1.setBounds(200, 100, 100, 30);
jb1.setVisible(true);
jb1.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(jfc.showDialog(null, "确定")==jfc.APPROVE_OPTION)
{
fileStr=jfc.getCurrentDirectory().toString().trim();
//System.out.print(jfc.getCurrentDirectory().toString().trim());
location=new File(fileStr);
}
}
}
);
this.add(jb1);
}
}