package delnopdir;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.File;public class delNopDir extends JFrame{
private JLabel JLTargetDir=new JLabel("目标文件夹:");
private JTextField JTFTargetDir=new JTextField("");
private JButton JBSearch=new JButton("...");
public delNopDir() {
Container con=getContentPane();
con.setLayout(null);
setSize(400,200);
setTitle("删除空目录:");
JLTargetDir.setBounds(20,20,80,30);
con.add(JLTargetDir);
JTFTargetDir.setBounds(100,20,220,30);
con.add(JTFTargetDir);
JBSearch.setBounds(330,20,30,30);
con.add(JBSearch);
JBSearch.addActionListener(new search());
setVisible(true);
}
public JTextField getJTFTargetDir(){
return JTFTargetDir;
}
public static void main(String[] args)
{
delNopDir dnp=new delNopDir();
dnp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}class search implements ActionListener
{
JFileChooser fc;
public void actionPerformed(ActionEvent e)
{
fc=new JFileChooser();
if(JFileChooser.APPROVE_OPTION==fc.showOpenDialog(null))
{
File f=fc.getSelectedFile();
(new delNopDir()).getJTFTargetDir().setText(f.getAbsolutePath());//此处我创建的对象和在主程序创建的对象应该是两个对象,可我用这个对象却能设置那个对象的变量的值,求大侠解释下,万分感激
}
}
}
解决方案 »
- 趣味编程题一道,我自己编的题,非教条主义,大家快来看看啦
- 类的访问权限问题!
- 菜鸟求教高手关于打包的问题
- 关于java 文件流 stream的截取
- 转成EXE文件的问题
- 考考你的java基础,认为java基础不错的进来看看。
- 请教大侠做jsp网页的步骤
- 一个极其简单的问题
- 怎么在java Applet和java Application中调用javabean?
- 有谁实现自己过Sun的Blueprints里面的 Front Controller 模式?
- 请问Hibernate的Session的一级缓存和Hibernate.cache.use_query_cache两者有什么区别
- 寻物启事:sql server 2005驱动包
import javax.swing.*;
import java.awt.event.*;
import java.io.File;public class delNopDir extends JFrame{
private JLabel JLTargetDir=new JLabel("目标文件夹:");
private JTextField JTFTargetDir=new JTextField("");
private JButton JBSearch=new JButton("...");
public delNopDir() {
Container con=getContentPane();
con.setLayout(null);
setSize(400,200);
setTitle("删除空目录:");
JLTargetDir.setBounds(20,20,80,30);
con.add(JLTargetDir);
JTFTargetDir.setBounds(100,20,220,30);
con.add(JTFTargetDir);
JBSearch.setBounds(330,20,30,30);
con.add(JBSearch);
JBSearch.addActionListener(new search());
setVisible(true);
}
public JTextField getJTFTargetDir(){
return JTFTargetDir;
}
public static void main(String[] args)
{
delNopDir dnp=new delNopDir();
dnp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
class search implements ActionListener
{
JFileChooser fc;
public void actionPerformed(ActionEvent e)
{
fc=new JFileChooser();
if(JFileChooser.APPROVE_OPTION==fc.showOpenDialog(null))
{
File f=fc.getSelectedFile();
JTFTargetDir.setText(f.getAbsolutePath());
}
}
}
}