亚洲欧洲国产欧美一区精品,激情五月亚洲色五月,最新精品国偷自产在线婷婷,欧美婷婷丁香五月天社区

      自考

      各地資訊
      當前位置:考試網 >> 自學考試 >> 模擬試題 >> 工學類 >> Java 語言程序設計(一) >> 文章內容

      排行熱點

      全國2013年10月自考《Java語言程序設計(一)》真題_第5頁

      來源:考試網 [ 2014年3月24日 ] 【大 中 小】
      34.閱讀下列程序,請寫出該程序的功能。
       import javax.swing.*;  import java.awt.*; import java.awt.event.*;
       public class Test34 {
           public static void main(String[]args){
               ComboBoxDemo myComboBoxGUI = newComboBoxDemo();
           }
       }
       Class ComboBoxDemo extends JFrame implemems ItemListener{
            String CountryList[]={"美國","中國","英國","俄羅斯","韓國","德國"};
            im GoldMedalNumber[]={46,38,29,24,13,11};
            JLabel label;JComboBox Combobox;
            Public ComboBoxDemo(){
                setSize(350,150);
                setTitle("第三十屆倫敦奧運會金牌查詢");
                Comainer conPane = getContentPane();
                conPane.setLayout(new FlowLayout());
                combobox=new JComboBox(CountryList);
                combobox.addItemListener(this);
                conPane.add(combobox);
                label=new JLabel();   conPane.add(1abel);   this.setVisible(true);
            }
            public void itemStateChanged(ItemEvem e){
                if(e.getS ource()==combobox)
                   label.setText(
                     String.valueOf(GoldMedalNumber[combobox.getSelectedIndex()]));
           }
       }
      35.閱讀下列程序,請回答下面的問題:
       (1)兩個文本區(qū)內分別每次追加何種字符?有多少個?
       (2)兩個文本區(qū)里面內容的顯示速度有何區(qū)別?
       import iava.awt.*;import java.applet.*;import javax.swing.*;
       public class Test35 extends Applet{
           JTextArea 1Text,rText;
           public void init() {
               setSize(600,500); setLayout(null);
               1Text=new JTextArea();  rText=new JTextArea();
               lText.setFont(new Font ("Times New Roman",1,40));
               rText.setFont(new Font("Modern",1,40));
               JScrollPane jsp1=new JScrollPane(1Text);
               JScrollPane jsp2=new JScrollPane(rText);
               add(jsp1);      add(jsp2);
               jspl.setBounds(20,20,250,450);    jsp2.setBounds(310,20,200,450);
               (new threadl(1Text,"1")).start();    (new threadl(rText,"2")).start();
           }
       }
       class threadl extends Thread{
           protected JTextArea t;
           String text="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
           public thread1(JTextArea text,String m){      super(m);  t=text; }
           public void run()  {
               while(true){
                   String S=" ";
                   for(int i=0;i<6;i++){
                       int k;
                       if(getName().equals("1"))
                           k=((int)(Math.random()*100)%26);
                       else
                           k=((int)(Math.random()*100)%10)+26;
                       s+=text.charAt(k); //獲取k位置字符
                   }
                   t.append(s+"\n");
                   t.setCaretPosition(t.getText().1ength());//最近輸出的內容在文本區(qū)中顯示
                   try{sleep(getName().equals("1")?400:700);}
                   catch (InterruptedException e){}
               }
          }
       }
      責編:abcwuli1234