April 2000
JP219 : JAVA PROGRAMMING

QUESTION 4

Total Marks: 15 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 4

(a)Briefly explain the major differences between the AWT library and the Swing library.[2 marks ]

(b)(i)Define a class,called FrameClass which extends the JFrame superclass.Your class should contain a constructor which creates the frame with a named title bar.[3 marks ]
(ii)Define a method,called main which is a member of the class FrameClass
which creates an object of type FrameClass with “My Swing Application” as the title.The member methods of the JFrame class should then set the size of the frame to 100 by 200 pixels,and display the frame.[4 marks ]
(iii)Write the statements (which could be added to your main function) necessary to declare and add a JButton to the north of the frame,using a BorderLayout manager.The title of the button should read “Press Me!”.
public void MyButtonAdd(); [4 marks ]
(iv)Give the statements necessary to ensure that the AWT and Swing packages
would be correctly made available to your class.[2 marks ]