Fifth time Java Job

Source: Internet
Author: User

Job One:

The file displays a list box.

The drop-down combo box is added, and the text locale color is red.

1Import javax.swing.*;2Import java.awt.*;3 import Java.io.File;4 5  Public classFileutil extends jframe{6 7     /**8 * @param args9      */Ten      One      Public StaticString listdirectory (File dir) throws illegalaccessexception{ A         if(!dir.exists ()) { -             Throw NewIllegalaccessexception ("Catalogue"+dir+"does not exist"); -         } the         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";} A         returnname; at         } -      -      Public Static voidMain (string[] args) { -         //TODO auto-generated Method Stub -JFrame frame=NewJFrame (); -JPanel Main_panel =NewJPanel (NewBorderLayout ()); inJLabel label =NewJLabel ("FileList"); - frame.setdefaultcloseoperation (jframe.exit_on_close); to         //frame.setlayout (null); +string[] Itme =Newstring[]{"Folder A","folder B"}; -JComboBox box=NewJComboBox (); the          for(intI=0; i<itme.length;i++){ * Box.additem (Itme[i]); $         }Panax NotoginsengBox.setenabled (true); -Box.seteditable (true); theBox.setmaximumrowcount (6); +Box.setbounds ( the, -, the, -); A              theFrame.setbounds ( -, -, -, $); +Frame.setvisible (true); -JTextArea Main_text =NewJTextArea (); $ Main_text.setbackground (color.red); $JScrollPane aa=NewJScrollPane (); - Aa.setviewportview (main_text); -Main_text.setenabled (false); the Main_panel.add (Box,borderlayout.north); - Main_panel.add (aa,borderlayout.center);Wuyi Main_panel.add (Label,borderlayout.south); the Frame.add (main_panel); -          Wu         Try { -String Str=fileutil.listdirectory (NewFile ("C:\\users\\woshinibaba\\desktop\\java Job 5\\soundplayer")); About Main_text.settext (str); $         } -         Catch(illegalaccessexception e) { -             //TODO auto-generated Catch block - e.printstacktrace (); A         } +          the  -          $Frame.setbounds ( -, $, $, $); theFrame.setvisible (true); the          the      the     } -}

Code effects:

Job 2:

Fifth time Java 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.