JAVA圖形界面編程試題及答案講解_第1頁
JAVA圖形界面編程試題及答案講解_第2頁
JAVA圖形界面編程試題及答案講解_第3頁
JAVA圖形界面編程試題及答案講解_第4頁
JAVA圖形界面編程試題及答案講解_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

JAVA圖形界面編程試題及答案講解姓名:____________________

一、單項(xiàng)選擇題(每題2分,共10題)

1.在JavaSwing庫中,用于創(chuàng)建窗口的類是:

A.JFrame

B.JPanel

C.Window

D.WindowBuilder

2.以下哪個(gè)不是JavaSwing中的組件?

A.JButton

B.JLabel

C.JScrollPane

D.InputStream

3.以下哪個(gè)不是事件監(jiān)聽器接口?

A.ActionListener

B.ComponentListener

C.KeyListener

D.MouseAdapter

4.在JavaSwing中,以下哪個(gè)類可以創(chuàng)建對話框?

A.JOptionPane

B.Dialog

C.Frame

D.JFrame

5.以下哪個(gè)方法用于設(shè)置窗口大???

A.setSize(intwidth,intheight)

B.setBounds(intx,inty,intwidth,intheight)

C.setLocation(intx,inty)

D.setVisible(booleanvisible)

6.在JavaSwing中,以下哪個(gè)類用于創(chuàng)建滾動(dòng)條?

A.JScrollBar

B.JScrollPane

C.JList

D.JTable

7.以下哪個(gè)事件是在組件被點(diǎn)擊時(shí)觸發(fā)?

A.ActionListener

B.ItemListener

C.ActionListener

D.ActionListener

8.在JavaSwing中,以下哪個(gè)方法用于添加組件?

A.add(Componentcomp)

B.add(ActionListeneral)

C.addMouseListener(MouseListenerml)

D.addKeyListener(KeyListenerkl)

9.以下哪個(gè)事件是在組件被關(guān)閉時(shí)觸發(fā)?

A.WindowListener

B.ComponentListener

C.ActionListener

D.KeyListener

10.在JavaSwing中,以下哪個(gè)方法用于獲取組件的寬度?

A.getWidth()

B.getHeight()

C.getSize()

D.setSize()

二、多項(xiàng)選擇題(每題3分,共10題)

1.以下哪些是JavaSwing的主要組件?

A.JFrame

B.JPanel

C.JLabel

D.JButton

E.JOptionPane

2.以下哪些事件可以在JavaSwing中處理?

A.ActionListener

B.ComponentListener

C.KeyListener

D.MouseListener

E.WindowListener

3.以下哪些是JavaSwing的事件處理機(jī)制?

A.AdapterPattern

B.ObserverPattern

C.CallbackPattern

D.TemplateMethodPattern

E.StrategyPattern

4.以下哪些是JavaSwing布局管理器?

A.BorderLayout

B.FlowLayout

C.GridLayout

D.GridBagLayout

E.BoxLayout

5.在JavaSwing中,以下哪些方法可以設(shè)置組件的字體?

A.setFont(Fontfont)

B.getFont()

C.setForeground(Colorcolor)

D.set看背景(Colorcolor)

E.setIcon(Iconicon)

6.以下哪些是JavaSwing中的鼠標(biāo)事件?

A.MouseEvent

B.MouseAdapter

C.MouseListener

D.MouseMotionEvent

E.MouseMotionAdapter

7.以下哪些是JavaSwing中的鍵盤事件?

A.KeyEvent

B.KeyAdapter

C.KeyListener

D.KeyStroke

E.KeyMap

8.在JavaSwing中,以下哪些方法可以設(shè)置組件的邊框?

A.setBorder(Borderborder)

B.getBorder()

C.setBorderPainted(booleanpainted)

D.setBorderInsetsInsetsinsets)

E.setBorderThickness(intthickness)

9.以下哪些是JavaSwing中的對話框組件?

A.JOptionPane

B.Dialog

C.JFrame

D.JDialog

E.JWindow

10.在JavaSwing中,以下哪些方法可以設(shè)置組件的位置?

A.setLocation(intx,inty)

B.setLocationRelativeTo(Componentc)

C.setLocationByPlatform(booleanplatform)

D.setBounds(intx,inty,intwidth,intheight)

E.setSize(intwidth,intheight)

三、判斷題(每題2分,共10題)

1.JavaSwing庫是Java平臺(tái)的標(biāo)準(zhǔn)擴(kuò)展庫之一。()

2.在JavaSwing中,所有組件都必須是容器組件的子類。()

3.BorderLayout布局管理器只能放置5個(gè)組件。()

4.FlowLayout布局管理器默認(rèn)從左到右排列組件。()

5.GridLayout布局管理器中的組件大小總是相同的。()

6.JPanel是一個(gè)容器組件,可以包含其他組件。()

7.JButton組件的默認(rèn)動(dòng)作是關(guān)閉應(yīng)用程序。()

8.JOptionPane組件可以用于顯示錯(cuò)誤信息。()

9.在JavaSwing中,每個(gè)事件都必須有一個(gè)監(jiān)聽器來處理。()

10.在JavaSwing中,可以使用ActionListener接口來監(jiān)聽鍵盤事件。()

四、簡答題(每題5分,共6題)

1.簡述JavaSwing的組件層次結(jié)構(gòu)。

2.解釋什么是布局管理器,并舉例說明JavaSwing中的幾種常用布局管理器。

3.如何在JavaSwing中實(shí)現(xiàn)事件監(jiān)聽機(jī)制?

4.簡述JFrame、JPanel和JWindow的區(qū)別。

5.如何使用JOptionPane類創(chuàng)建一個(gè)簡單的對話框?

6.在JavaSwing中,如何設(shè)置組件的字體和顏色?

試卷答案如下

一、單項(xiàng)選擇題答案及解析:

1.AJFrame是用于創(chuàng)建窗口的類。

2.DInputStream不是JavaSwing中的組件,它是一個(gè)輸入流類。

3.DMouseAdapter不是事件監(jiān)聽器接口,它是MouseListener接口的抽象子類。

4.AJOptionPane用于創(chuàng)建對話框。

5.AsetSize(intwidth,intheight)方法用于設(shè)置窗口大小。

6.BJScrollPane用于創(chuàng)建滾動(dòng)條。

7.AActionListener是在組件被點(diǎn)擊時(shí)觸發(fā)的事件監(jiān)聽器接口。

8.Aadd(Componentcomp)方法用于添加組件。

9.EWindowListener是在組件被關(guān)閉時(shí)觸發(fā)的事件監(jiān)聽器接口。

10.AgetWidth()方法用于獲取組件的寬度。

二、多項(xiàng)選擇題答案及解析:

1.A,B,C,D,EJFrame,JPanel,JLabel,JButton,JOptionPane都是JavaSwing的主要組件。

2.A,B,C,D,EActionListener,ComponentListener,KeyListener,MouseListener,WindowListener都是JavaSwing中可以處理的事件。

3.A,B,C,D,EAdapterPattern,ObserverPattern,CallbackPattern,TemplateMethodPattern,StrategyPattern都是JavaSwing的事件處理機(jī)制。

4.A,B,C,D,EBorderLayout,FlowLayout,GridLayout,GridBagLayout,BoxLayout都是JavaSwing中的布局管理器。

5.A,B,C,D,EsetFont(Fontfont),getFont(),setForeground(Colorcolor),set看背景(Colorcolor),setIcon(Iconicon)都可以設(shè)置組件的字體。

6.A,B,C,D,EMouseEvent,MouseAdapter,MouseListener,MouseMotionEvent,MouseMotionAdapter都是JavaSwing中的鼠標(biāo)事件。

7.A,B,C,D,EKeyEvent,KeyAdapter,KeyListener,KeyStroke,KeyMap都是JavaSwing中的鍵盤事件。

8.A,B,C,D,EsetBorder(Borderborder),getBorder(),setBorderPainted(booleanpainted),setBorderInsetsInsetsinsets),setBorderThickness(intthickness)都可以設(shè)置組件的邊框。

9.A,B,D,EJOptionPane,Dialog,JDialog,JWindow都是JavaSwing中的對話框組件。

10.A,B,C,D,EsetLocation(intx,inty),setLocationRelativeTo(Componentc),setLocationByPlatform(booleanplatform),setBounds(intx,inty,intwidth,intheight),setSize(intwidth,intheight)都可以設(shè)置組件的位置。

三、判斷題答案及解析:

1.對

2.錯(cuò)不是所有組件都必須是容器組件的子類。

3.錯(cuò)BorderLayout可以放置任意數(shù)量的組件。

4.對

5.對

6.對

7.錯(cuò)JButton的默認(rèn)動(dòng)作是執(zhí)行其動(dòng)作監(jiān)聽器中的操作。

8.對

9.錯(cuò)不是每個(gè)事件都必須有一個(gè)監(jiān)聽器來處理,可以使用適配器模式。

10.錯(cuò)ActionListener接口用于監(jiān)聽鼠標(biāo)事件,KeyListener用于監(jiān)聽鍵盤事件。

四、簡答題答案及解析:

1.JavaSwing的組件層次結(jié)構(gòu)包括容器組件(如JFrame,JPanel)和非容器組件(如JButton,JLabel)。容器組件可以包含其他組件,而非容器組件不能包含其他組件。

2.布局管理器用于確定組件在容器中的位置和大小。常用的布局管理器有BorderLayout,FlowLayout,GridLayout,GridBagLayout和BoxLayout。

3.JavaSwing的事件監(jiān)聽機(jī)制涉及事件源、事件和事件監(jiān)聽器。事件源是觸發(fā)事件的對象,事件是描述事件發(fā)生的情況,事件監(jiān)聽器是等待事件發(fā)生并處理事件的類。

4.JFrame是頂層窗口容器,可以包含其他組件;JP

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論