วันอาทิตย์ที่ 26 มกราคม พ.ศ. 2557

GUI คืออะไร ??....


   
GUI is  ? ? .... 

       GUI is a graphical user interface to the PC such as web browser , this word occurs. Because of the Internet
Interface with the computer in the first version does not use graphics . However, the use of letters and keyboard. Is usually recognized as the DOS operating system in the middle of the user interface to read the menu interface (Menu-based Interface) , which allows the mouse to click commands. In addition to the keyboard
Most operating systems have a GUI in the application to use the elements of the GUI that comes with the operating system and add the interfaces themselves into some GUI using objects to more than one of the actual work , such as the desktop . looking through the Windows GUI to find components , including the Windows menu Pull down, buttons , scroll bars , icons , Wizards, mouse , and includes many things are developing. The increasing use of multimedia such as audio, animation. And interface virtual are now part of the GUI familiar with GUI present in both Mac, Windows operating system and various applications are beginning to Xerox Palo Alto Research Laboratory , later in the 70s . Apple first used in Macintosh computers, Microsoft has embraced the concept later evolved into the Windows operating system with IBM-compatible.

When creating applications tools object-oriented Be written to interface with graphics. Each member of the GUI are called class form when creating the object up. Which can be written or updated by the method (method) to object to those responding to the user .


GUI elements

1.GUI (Graphical User Interface) is a graphics program used to interact with the user. In Java , we can choose a variety of tasks such as - Java Swing - Java AWT - Java Applet - Java Script.

2. AWT (Abstract Windowing Toolkit) is a basic tool for programming GUI features - AWT component - AWT Container is a component , one that can take a component of other input - Layout Manager for exhibit component out of the screen .

3.Swing Component AWT itself due to various problems arising in applications such as the memory . Make up a new class of Java developers with the ability Swing GUI, but less trouble, which did not use the AWT AWT because Swing is also available in the same time , it must still extends some AWT classes of applications.

Type of Component                                                                                                                                      Container Components class is used to create a GUI that can be another Component component has two types.

- Non-top-level Container.
- Top-level Container

GUI creation
l Component will be created and placed in the Container by the placement of the component to be accommodated. Layout Manager as an aid in placement.
l have to order setSise (int, int).
l have to order setShow () or setVisible (true)


..........................................................................................................................................




GUI คืออะไร ??....

       GUI เป็นอินเตอร์เฟซด้วยกราฟฟิกของผู้ใช้กับเครื่องคอมพิวเตอร์ เช่น เว็บบราวเซอร์คำนี้เกิดขึ้น  เนื่องจากการอินเตอร์
เฟซกับคอมพิวเตอร์ในรุ่นแรกไม่ได้ใช้กราฟฟิค แต่เป็นการใช้ตัวอักษรและแป้นพิมพ์ ปกติจะเป็นคำสั่งที่จำได้ เช่น ระบบปฏิบัติการ DOS ในขั้นกลางการอินเตอร์เฟซของผู้ใช้เป็นการอ่านอินเตอร์เฟซแบบเมนู (Menu-based Interface) ซึ่งยอมให้ใช้เมาส์คลิกคำสั่งได้ นอกจากการพิมพ์แป้นพิมพ์

ระบบปฏิบัติการส่วนใหญ่จะเป็นแบบ GUI ในส่วนโปรแกรมประยุกต์จะใช้องค์ประกอบของ GUI ที่มากับระบบปฏิบัติการและเพิ่มการอินเตอร์เฟซของตัวเองเข้าไป บางครั้ง GUI ใช้อ็อบเจคมากกว่าหนึ่งในการทำงานจริง เช่น ในเครื่องตั้งโต๊ะ การมองผ่าน Windows จะพบส่วนประกอบของ GUI ได้รวมถึง Windows เมนูแบบ Pull down, ปุ่ม, แถบเลื่อน, ไอคอน, Wizards, เมาส์ และรวมถึงอีกหลายสิ่งที่กำลังพัฒนา การเพิ่มขึ้นของการใช้มัลติมีเดีย เช่นเสียง ภาพเคลื่อนไหว และการอินเตอร์เฟซแบบเสมือนจริงกำลังเข้ามาเป็นส่วนหนึ่งของ GUI ความคุ้นเคยกับ GUI ในปัจจุบันทั้ง Mac, ระบบปฏิบัติการ Windows และโปรแกรมประยุกต์ต่าง ๆ ได้มีจุดเริ่มต้นที่ Xerox Palo Alto Research Laboratory ต่อมาในทศวรรษที่ 70 Apple ใช้ครั้งแรกในเครื่องคอมพิวเตอร์แมคอินทอช ต่อมา Microsoft ได้นำเอาแนวคิดมาพัฒนาเป็นระบบปฏิบัติการ Windows กับเครื่อง IBM-compatible
เมื่อมีการสร้างโปรแกรมประยุกต์ เครื่องมือแบบ object-oriented จะเขียนการอินเตอร์เฟซด้วยกราฟฟิก ในแต่ละสมาชิกของ GUI จะเรียกว่า class form เมื่อสร้างอ็อบเจคขึ้นมาแล้ว ซึ่งสามารถเขียนคำสั่งหรือปรับปรุงด้วยเมธอด (method) เพื่อทำให้อ็อบเจคเหล่านั้นตอบสนองต่อการใช้งานของผู้ใช้

องค์ประกอบของ GUI                                                                                         1.GUI (Graphical User Interface)                                                                                                                                                                                                                                                                           2. AWT (Abstract Windowing Toolkit)                                                                                                         

          3.Swing Component    

                                                                    

ประเภทของ Component                                            Container Components คือ คลาสที่ใช้ในการสร้าง GUI ที่สามารถนำเอา Component อื่นมาเป็นส่วนประกอบได้มีสองประเภท คือ

- Non-top-level Container
- Top-level Container

การสร้าง GUI                                                                                                                                         

Component จะถูกสร้างขึ้นมาแล้ววางใน Container โดยที่การจัดวาง component นั้นจะอาศัย                             
          Layout Manager เป็นตัวช่วยในการจัดวาง
จะต้องมีคำสั่ง setSise(int, int)
จะต้องมีคำสั่ง setShow() หรือ setVisible(true)

Java GUI การใส่ภาพพื้นหลังให้โปรแกรม

เทคนิคการนำภาพมาทำ Background ของโปรแกรม

ในบางโปรแกรมเราก็จะมีฉากพื้นหลังมาวางไว้ในหน้าหลัก เพื่อความสวยงาม อย่างในระบบพวก intranet application หรือบางทีใน software package เองก็มีการนำภาพมาเป็นพื้นหลังเช่นกัน ในตัวอย่างนี้ผมจะพาทำโดยใช้วิธีการง่าย ๆ

เริ่มต้นสร้างโปรเจกชื่อ MyBG





จากนั้นสร้าง JFrame ตั้งชื่อว่า MyFrame



         กำหนด layout




 นำภาพไปวางในโปรเจก โฟลเดอร์ src/image





refresh project เพื่อโหลดภาพเมื่อกี้เข้ามาในโปรเจก




วาง JLabel ลงไป ลากให้มีขนาดตามต้องการ




จากนั้นกำหนด properties icon เลือกภาพที่ต้องการได้เลย




เลือกภาพ





ผลที่ได้



ผลการรันโปรแกรม



เพียงเท่านี้เราก็สามารถใส่ภาพลงในโปรแกรมได้ตามต้องการแล้วครับ ไม่ว่าจะเป็นภาพประกอบเล็ก ๆ น้อย ๆ หรือภาพพื้นหลัง ก็ใช้วิธีนี้ได้เลย







...........................................................................................................................................







8 ความคิดเห็น: