انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة
الكلية كلية تكنولوجيا المعلومات
القسم قسم البرامجيات
المرحلة 2
أستاذ المادة احمد مهدي محمد سعيد الصالح
31/01/2016 20:58:44
1. GUI Construction A Java technology GUI can be created using either of the following techniques. • Programmatic construction This technique use code to create the GUI. This technique is used for learning GUI construction. However, it is very laborious to use in production environment. • Construction using a GUI builder tool This technique uses a GUI builder tool to create the GUI. The GUI developer uses a visual approach to drag-and-drop containers and components to a work area. 2. Example of programmatic construction This sections a simple GUI that prints a Hello World. The code shown in below create a container JFrame with a title HelloWorldSwing. It later adds a JLabel with the Accessible Name property set to Hello World. 3. Key Methods Methods for setting up the JFrame and adding JLabel: • setDefaultCloseOperationJFrame.EXIT_ON_CLOSE) –Creates the program to exit when the close button is clicked. There are four possible ways of handling this: a. DO_NOTHING_ON_CLOSE: does nothing when the close operation is initiated. This constant is defined in WindowsConstants. b. Hide_ON_ClOSE: invokes any WindowListener objects and hides the frame. This constant is defined in WindowsConstants. c. DISPOSE_ON_CLOSE: invokes any WindowListener objects and hides and disposes the frame. This constant is defined in WindowsConstants.
• setVisible(true)– Makes the JFrame visible. • add(Component c)– this method adds the components to the container.
To handle these tasks efficiently the Swing framework uses threads that are light-weight process . The tasks described can be handled by these threads separately and concurrently. The programmer should utilities these threads. The Swing framework provides a collection of utility methods in the SwingUtilities class. SwingUtilites.invokeLater(new Runnable())
In the java programming language, threads are created using the Runnable interface. This interface defines a method run that should be implemented by all the classes using this interface. The invokeLater method schedule the GUI creations taks to execute the run method a synchronously by the event-handling thread after all the pending events are completed.
المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
|