Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
AhmadLang / Introduction to Programming Using Java-1.pdf
Скачиваний:
71
Добавлен:
31.05.2015
Размер:
5.27 Mб
Скачать

Quiz

309

Quiz on Chapter 6

(answers)

1.Programs written for a graphical user interface have to deal with “events.” Explain what is meant by the term event. Give at least two di erent examples of events, and discuss how a program might respond to those events.

2.Explain carefully what the repaint() method does.

3.What is HTML?

4.Java has a standard class called JPanel. Discuss two ways in which JPanels can be used.

5.Draw the picture that will be produced by the following paintComponent() method:

public static void paintComponent(Graphics g) { super.paintComponent(g);

for (int i=10; i <= 210; i = i + 50)

for (int j = 10; j <= 210; j = j + 50) g.drawLine(i,10,j,60);

}

6.Suppose you would like a panel that displays a green square inside a red circle, as illustrated. Write a paintComponent() method for the panel class that will draw the image.

7.Java has a standard class called MouseEvent. What is the purpose of this class? What does an object of type MouseEvent do?

8.One of the main classes in Swing is the JComponent class. What is meant by a component? What are some examples?

9.What is the function of a LayoutManager in Java?

10.What type of layout manager is being used for each of the three panels in the following illustration from Section 6.7?

Quiz

310

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

11.Explain how Timers are used to do animation.

12.What is a JCheckBox and how is it used?