华南俳烁实业有限公司

自考

各地資訊
當(dāng)前位置:考試網(wǎng) >> 自學(xué)考試 >> 模擬試題 >> 工學(xué)類 >> Java 語言程序設(shè)計(jì)(一) >> 文章內(nèi)容

排行熱點(diǎn)

  • 歷年真題
  • 模擬試題
  • 自考自答

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

來源:考試網(wǎng) [ 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("第三十屆倫敦奧運(yùn)會(huì)金牌查詢");
          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)兩個(gè)文本區(qū)內(nèi)分別每次追加何種字符?有多少個(gè)?
 (2)兩個(gè)文本區(qū)里面內(nèi)容的顯示速度有何區(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());//最近輸出的內(nèi)容在文本區(qū)中顯示
             try{sleep(getName().equals("1")?400:700);}
             catch (InterruptedException e){}
         }
    }
 }
責(zé)編:abcwuli1234
京山县| 十堰市| 炎陵县| 柏乡县| 读书| 内丘县| 禄丰县| 永福县| 美姑县| 项城市| 长泰县| 桓仁| 沂源县| 营口市| 美姑县| 松阳县| 广饶县| 横峰县| 鲁甸县| 汤原县| 漾濞| 萍乡市| 桂阳县| 准格尔旗| 治县。| 德昌县| 石阡县| 阿坝县| 南宁市| 庄浪县| 丁青县| 新化县| 淮阳县| 金山区| 绥德县| 将乐县| 新晃| 安仁县| 崇文区| 双鸭山市| 陇川县|