Java Fifth time job

Source: Internet
Author: User

 1 Import javax.swing.*; 2 Import java.awt.*; 3 Import Java.io.File; 4 5 public class Fileutil extends jframe{6 7/** 8 * @param args 9 */10 one public static String L Istdirectory (File dir) throws illegalaccessexception{12 if (!dir.exists ()) {New Illegalaccessex Ception ("directory" +dir+ "does not Exist"),}15 if (!dir.isdirectory ()) {//determines if the directory is not a new illegalargumentexc    Eption (dir+ "not Directory");}18 string[] fileName = Dir.list (); String name = ""; (string a:filename) {name=name+a+ "\ n";}  Return name;23}24 public static void Main (string[] args) {//TODO auto-generated Method Stub27 JFrame frame=new JFrame (); JPanel main_panel =new JPanel (New BorderLayout ()); J Label label = new JLabel ("FileList"); Frame.setdefaultcloseoperation (jframe.exit_on_close);//frame.se Tlayout (NULL);Tring[] itme =new string[]{"folder A", "Folder B"};33 JComboBox box=new JComboBox (); (int i=0;i<itme.length         ; i++) {Box.additem (itme[i]);}37 box.setenabled (true); Box.seteditable (true); 39 Box.setmaximumrowcount (6); Box.setbounds (230,30,130,25); Frame.setbounds (400,30 0,400,200); frame.setvisible (true); JTextArea main_text =new JTextArea (); main_text.setback Ground (color.red); JScrollPane aa=new JScrollPane (); Aa.setviewportview (main_text); Main_tex          T.setenabled (false); Main_panel.add (Box,borderlayout.north); Main_panel.add (Aa,borderlayout.center); 51             Main_panel.add (Label,borderlayout.south); Frame.add (Main_panel); try {55 String str=fileutil.listdirectory (New File ("C:\\users\\woshinibaba\\desktop\\java job 5\\soundplayer"));  N_text.settext (str); 57       }58 catch (illegalaccessexception e) {//TODO auto-generated catch block60 e.pri Ntstacktrace ();}62 frame.setbounds (400,200,200,200); Frame.setvisibl E (TRUE); 67 68 69}70}

Java Fifth time job

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.