JAVA's fifth job and java's fifth job

Source: Internet
Author: User

JAVA's fifth job and java's fifth job

If you do not understand it, please refer to the 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 Fil EUtils extends JFrame {/*** list all files or directories in the specified folder (directory) * @ param dri File-type specified folder (directory) * @ throws IllegalAccessException */public static String listDirectory (File dir) throws IllegalAccessException {if (! Dir. exists () {throw new IllegalAccessException ("directory" + dir + "does not exist");} // determine whether the associated files and directories under dir exist if (! Dir. isDirectory () {// if no exception is thrown, throw new IllegalAccessException (dir + "not a 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 JFrame frame = new JFrame (); JPanel main_panel = new JPanel (new BorderLayout (); frame. setdefaclocloseoperation (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 );}}

  

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.