Fifth time Java Job

Source: Internet
Author: User

Import Java.awt.BorderLayout;
Import Java.awt.Color;
Import Java.io.File;

Import Javax.swing.JComboBox;
Import Javax.swing.JFrame;
Import Javax.swing.JPanel;
Import Javax.swing.JScrollPane;
Import Javax.swing.JTextArea;


public class FileUtils {
/**
* Lists the names of all files or directories in the specified folder (directory)
* @param folder (directory) specified by dir file type
* @return
* @throws illegalaccessexception
*/
public static String ListDirectory (File dir) throws illegalaccessexception{
Determine if the files and directories associated with dir exist
if (!dir.exists ()) {
Throws an exception if it does not exist
throw new Illegalaccessexception ("directory" + dir + "does not exist.) ");
}
Determine if dir is associated with a directory
if (!dir.isdirectory ()) {
throw new Illegalaccessexception (dir + "not Directory");
}
/* With the passed in file object dir calls the list () method to obtain
* The name of all files and folders under the current directory (dir).
*/
string[] files = dir.list ();
String m = "";
for (String a:files) {
M=m+a+ "\ n";}
return m;
}
/**
* @param args
*/
public static void Main (string[] args) {
TODO auto-generated Method Stub
JFrame frame=new JFrame ();
JPanel Main_panel =new JPanel (New BorderLayout ());//panel
Frame.setdefaultcloseoperation (Jframe.exit_on_close);
Frame.setlayout (NULL);

Set combo box
String[] Itme = {". png", "ico"};
JComboBox frm=new JComboBox (itme);
Frm.setenabled (TRUE);
Frm.seteditable (TRUE);
Frm.setmaximumrowcount (5);
Frm.setbounds (230,30,130,25);

Frame.setbounds (400,200,350,400);
Frame.setvisible (TRUE);
JTextArea main_text =new JTextArea ();
Main_text.setbackground (Color.Black);
JScrollPane z=new JScrollPane ();
Z.setviewportview (Main_text);
Main_text.setenabled (FALSE);
Main_panel.add (Frm,borderlayout.north);
Main_panel.add (Z,borderlayout.center);
Frame.add (Main_panel);

try {
String str = fileutils.listdirectory (new File ("D:\\$_outdir\\skin"));
Main_text.settext (str);
} catch (Illegalaccessexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
}

}

}

Fifth time Java Job

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.