Import Java.awt.Color;
Import Java.awt.BorderLayout;
Import Java.io.File;
Import Java.awt.Container;
Import java.awt.event.ActionEvent;
Import java.util.ArrayList;
Import java.util.List;
Import Javax.swing.JComboBox;
Import Javax.swing.JFrame;
Import Javax.swing.JLabel;
Import javax.swing.JList;
Import Javax.swing.JPanel;
Import Javax.swing.JScrollPane;
Import Javax.swing.JTextArea;
public class FileUtils extends jframe{
/**
* List of places for all files or directories in the specified folder (directory)
* @param the folder (directory) specified by the DRI file type
* @throws illegalaccessexception
*/
public static String ListDirectory (File dir) throws illegalaccessexception{
if (!dir.exists ()) {
throw new Illegalaccessexception ("directory" +dir+ "does not exist");
}
Determine if the files and directories associated with dir exist
if (!dir.isdirectory ()) {
If no throw exception exists
throw new Illegalaccessexception (dir + "not Directory");
}
string[] FileName = Dir.list ();
String name = "";
for (String a:filename) {
Name=name+a+ "\ n";}
return name;
}
/**
* @param args
*/
public static void Main (string[] args) {
TODO auto-generated Method Stub
TODO auto-generated Method Stub
JFrame frame=new JFrame ();
JPanel Main_panel =new JPanel (New BorderLayout ());
Frame.setdefaultcloseoperation (Jframe.exit_on_close);
Frame.setlayout (NULL);
String[] Itme =new string[]{". jpg", ". zip", ". Doc"};
JComboBox box=new JComboBox ();
for (int i=0;i<itme.length;i++) {
Box.additem (Itme[i]);
}
Box.setenabled (TRUE);
Box.seteditable (TRUE);
Box.setmaximumrowcount (6);
Box.setbounds (230,30,130,25);
Frame.setbounds (400,300,400,200);
Frame.setvisible (TRUE);
JTextArea main_text =new JTextArea ();
Main_text.setbackground (Color.Black);
JScrollPane aa=new JScrollPane ();
Aa.setviewportview (Main_text);
Main_text.setenabled (FALSE);
Main_panel.add (Box,borderlayout.north);
Main_panel.add (Aa,borderlayout.center);
Frame.add (Main_panel);
try {
String str=fileutils.listdirectory (New File ("C:\\users\\administrator\\desktop\\java job 5\\soundplayer\\audio"));
Main_text.settext (str);
}
catch (Illegalaccessexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
Frame.setbounds (300,400,300,400);
Frame.setvisible (TRUE);
}
}
Fifth time Assignment