diff --git a/DGcreate/out/production/DGcreate/joggle/joggle$JFileChooserDemo.class b/DGcreate/out/production/DGcreate/joggle/joggle$JFileChooserDemo.class new file mode 100644 index 0000000..ccb65b9 Binary files /dev/null and b/DGcreate/out/production/DGcreate/joggle/joggle$JFileChooserDemo.class differ diff --git a/DGcreate/out/production/DGcreate/joggle/joggle.class b/DGcreate/out/production/DGcreate/joggle/joggle.class index 39434e3..1c4f63c 100644 Binary files a/DGcreate/out/production/DGcreate/joggle/joggle.class and b/DGcreate/out/production/DGcreate/joggle/joggle.class differ diff --git a/DGcreate/out/production/DGcreate/menu/Main$1.class b/DGcreate/out/production/DGcreate/menu/Main$1.class deleted file mode 100644 index 8ed4429..0000000 Binary files a/DGcreate/out/production/DGcreate/menu/Main$1.class and /dev/null differ diff --git a/DGcreate/out/production/DGcreate/menu/Main$2.class b/DGcreate/out/production/DGcreate/menu/Main$2.class deleted file mode 100644 index d527897..0000000 Binary files a/DGcreate/out/production/DGcreate/menu/Main$2.class and /dev/null differ diff --git a/DGcreate/out/production/DGcreate/menu/MainWindow$1.class b/DGcreate/out/production/DGcreate/menu/MainWindow$1.class new file mode 100644 index 0000000..ac6e10e Binary files /dev/null and b/DGcreate/out/production/DGcreate/menu/MainWindow$1.class differ diff --git a/DGcreate/out/production/DGcreate/menu/MainWindow$2.class b/DGcreate/out/production/DGcreate/menu/MainWindow$2.class new file mode 100644 index 0000000..3e04585 Binary files /dev/null and b/DGcreate/out/production/DGcreate/menu/MainWindow$2.class differ diff --git a/DGcreate/out/production/DGcreate/menu/Main.class b/DGcreate/out/production/DGcreate/menu/MainWindow.class similarity index 57% rename from DGcreate/out/production/DGcreate/menu/Main.class rename to DGcreate/out/production/DGcreate/menu/MainWindow.class index 1419b67..3559704 100644 Binary files a/DGcreate/out/production/DGcreate/menu/Main.class and b/DGcreate/out/production/DGcreate/menu/MainWindow.class differ diff --git a/DGcreate/src/joggle/joggle.java b/DGcreate/src/joggle/joggle.java index eacaaa0..fcc7981 100644 --- a/DGcreate/src/joggle/joggle.java +++ b/DGcreate/src/joggle/joggle.java @@ -1,17 +1,36 @@ package joggle; import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.Desktop; import java.io.*; public class joggle { - public static boolean open_resource(){ + public static class JFileChooserDemo{ + public static void fileFilter(JFileChooser fd, String flag){ + if(flag == "maindow"){ + fd.setFileFilter(new FileNameExtensionFilter("DRC(*.drc)", "drc")); + fd.setAcceptAllFileFilterUsed(false); + } + else{ + fd.setFileFilter(new FileNameExtensionFilter("image(*.jpg,*.jpeg,*.png)", "drc")); + fd.setAcceptAllFileFilterUsed(false); + } + } + public static boolean open_resource(){ JFileChooser fd = new JFileChooser(); //fd.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - fd.showOpenDialog(null); - File f = fd.getSelectedFile(); - if(f != null){} - return true; + fileFilter(fd, "mindow"); + int val = fd.showOpenDialog(null); + if(val == fd.APPROVE_OPTION){ + fd.getSelectedFile(); + return true; + } + else{ + return false; + } + } } + public static void copyFile(String oldPath, String newPath) { try { int bytesum = 0; diff --git a/DGcreate/src/menu/Main.java b/DGcreate/src/menu/MainWindow.java similarity index 55% rename from DGcreate/src/menu/Main.java rename to DGcreate/src/menu/MainWindow.java index 682040b..7a05a61 100644 --- a/DGcreate/src/menu/Main.java +++ b/DGcreate/src/menu/MainWindow.java @@ -8,7 +8,7 @@ import java.io.*; //主窗口 -public class Main extends menu { +public class MainWindow extends menu { public static JFrame page = new JFrame("主菜单"); //创建主窗口 public static void main(String[] args) { @@ -32,28 +32,27 @@ public class Main extends menu { //鼠标触发事件 b.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { - joggle.open_resource(); - JFileChooser fd = new JFileChooser(); + joggle.JFileChooserDemo.open_resource(); } }); } - //打开 - public static void open(){ - JButton b = new JButton("打开"); - b.setBounds(625,400,250,50); - Container c = page.getContentPane(); - c.setLayout(new FlowLayout()); - c.add(b); - b.setDefaultCapable(true); - b.setVisible(true); - //鼠标触发事件 - b.addActionListener(new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - joggle.open_resource(); - joggle.copyFile("C:/Users/wangw/Desktop/英语作文","C:/Users/wangw/Desktop/英语作文"); - } - }); + //打开 + public static void open(){ + JButton b = new JButton("打开"); + b.setBounds(625,400,250,50); + Container c = page.getContentPane(); + c.setLayout(new FlowLayout()); + c.add(b); + b.setDefaultCapable(true); + b.setVisible(true); + //鼠标触发事件 + b.addActionListener(new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + joggle.JFileChooserDemo.open_resource(); + joggle.copyFile("C:/Users/wangw/Desktop/英语作文","C:/Users/wangw/Desktop/英语作文"); + } + }); } -} \ No newline at end of file +}