Java Fifth time job

Source: Internet
Author: User

Import javax.swing.*; import java.awt.*; import Java.io.File; Public classWork extends jframe{/** * @param args*/         Public StaticString listdirectory (File dir) throws illegalaccessexception{if(!dir.exists ()) {            Throw NewIllegalaccessexception ("Catalogue"+dir+"does not exist"); }        if(!dir.isdirectory ()) {//Judging is not a directory            Throw NewIllegalArgumentException (dir+"not a directory"); } string[] FileName=dir.list (); String name="";  for(String a:filename) {name=name+a+"\ n";} returnname; }         Public Static voidMain (string[] args) {//TODO auto-generated Method StubJFrame frame=NewJFrame (); JPanel Main_panel=NewJPanel (NewBorderLayout ());        Frame.setdefaultcloseoperation (Jframe.exit_on_close); //frame.setlayout (null);string[] Itme =Newstring[]{"","2"}; JComboBox Box=NewJComboBox ();  for(intI=0; i<itme.length;i++) {Box.additem (itme[i]); } box.setenabled (true); Box.seteditable (true); Box.setmaximumrowcount (6); Box.setbounds ( the, -, the, -); Frame.setbounds ( -, -, -, $); Frame.setvisible (true); JTextArea Main_text=NewJTextArea ();        Main_text.setbackground (Color.Black); JScrollPane AA=NewJScrollPane ();        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=work.listdirectory (NewFile ("D:\\soundplayer"));        Main_text.settext (str); }        Catch(illegalaccessexception e) {//TODO auto-generated Catch blockE.printstacktrace (); } frame.setbounds ( -, $, -, $); Frame.setvisible (true); }}

Displays the file under the specified path to the text box, and the program adds a combo box and a background color. Through this assignment, I mastered the operation of reading files from disk.

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.