您现在的位置是:主页 > news > 旅游网站建设费用/最近重大新闻

旅游网站建设费用/最近重大新闻

admin2025/6/6 6:49:55news

简介旅游网站建设费用,最近重大新闻,东莞网站建设及外包,算命网站建设学习心得: 看书->调试示例->查看Java API文档->看书->调试程序...->解决实际问题 只看书,不动手写、改、调试代码,很容易枯燥,如果结合起来,则相辅相成,效果倍增。 Section 12.1Introduct…

旅游网站建设费用,最近重大新闻,东莞网站建设及外包,算命网站建设学习心得: 看书->调试示例->查看Java API文档->看书->调试程序...->解决实际问题 只看书,不动手写、改、调试代码,很容易枯燥,如果结合起来,则相辅相成,效果倍增。 Section 12.1Introduct…

学习心得:

看书->调试示例->查看Java API文档->看书->调试程序...->解决实际问题

只看书,不动手写、改、调试代码,很容易枯燥,如果结合起来,则相辅相成,效果倍增。


Section 12.1Introduction

• A graphical userinterface (GUI; p. 474) presents a user-friendly mechanism for interacting withan application. A GUI gives an application a distinctive look-and-feel (p.474).

• Providing differentapplications with consistent, intuitive user-interface components gives users asense of familiarity with a new application, so that they can learn it morequickly.

• GUIs are built from GUIcomponents (p. 474)—sometimes called controls or widgets.

Section 12.2 Java’sNimbus Look-and-Feel

• As of Java SE 6 update10, Java comes bundled with a new, elegant, cross-platform look-and-feel knownas Nimbus (p. 476).

• To set Nimbus as thedefault for all Java applications, create a swing.properties text file inthe lib folder of your JDK and JRE installation folders. Place the followingline of code in the file: swing.defaultlaf=com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel

• To select Nimbus on anapplication-by-application basis, place the following command-line argument afterthe java command and before the application’s name when you run theapplication: -Dswing.defaultlaf=com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel

Section 12.3Simple GUI-Based Input/Output with JOptionPane

• Most applications usewindows or dialog boxes (p. 476) to interact with the user.

• Class JOptionPane(p. 476) of package javax.swing (p. 474) providesprebuilt dialog boxes for both input and output. JOptionPane static method showInputDialog(p. 477) displays an input dialog (p. 476).

• A prompt typically usessentence-style capitalization—capitalizing only the first letter of the first wordin the text unless the word is a proper noun.

• An input dialog caninput only input Strings. This is typical of most GUI components.

JOptionPanestatic method showMessageDialog (p. 478) displays amessage dialog (p. 476).

Section 12.4Overview of Swing Components

• Most Swing GUIcomponents (p. 474) are located in package javax.swing.

• Together, theappearance and the way in which the user interacts with the application are knownas that application’s look-and-feel. Swing GUI components allow you to specifya uniform lookand-feel for your application across all platforms or to use eachplatform’s custom look-and-feel.

• Lightweight Swingcomponents are not tied to actual GUI components supported by the underlying platformon which an application executes.

• Several Swingcomponents are heavyweight components (p. 480) that require direct interaction withthe local windowing system (p. 480), which may restrict their appearance andfunctionality.

• Class Component (p. 480) ofpackage java.awt declares many of the attributes and behaviors common to the GUIcomponents in packages java.awt (p. 479) and javax.swing.

• Class Container (p. 480) ofpackage java.awt is a subclass of Component. Components areattached to Containers so the Components can be organized and displayed on the screen.

• Class JComponent(p. 480) of package javax.swing is a subclassof Container. JComponent is the superclass of all lightweight Swing components anddeclares their common attributes and behaviors.

• Some common JComponentfeatures include a pluggable look-and-feel (p. 480), shortcutkeys called mnemonics (p. 480), tool tips (p. 480), support for assistivetechnologies and support for user-interface localization (p. 480).

Section 12.5Displaying Text and Images in a Window

• Class JFrame provides thebasic attributes and behaviors of a window.

• A JLabel (p. 481)displays read-only text, an image, or both text and an image. Text in a JLabel normally usessentence-style capitalization.

• Each GUI component mustbe attached to a container, such as a window created with a JFrame (p. 483).

• Many IDEs provide GUIdesign tools (p. 529) in which you can specify the exact size and location of acomponent by using the mouse; then the IDE will generate the GUI code for you.

JComponentmethod setToolTipText (p. 483) specifies the tool tip that’s displayed when the user positionsthe mouse cursor over a lightweight component (p. 480).

Container method add attaches aGUI component to a Container.

• Class ImageIcon (p. 484)supports several image formats, including GIF, PNG and JPEG.

• Method getClass of class Object (p. 484)retrieves a reference to the Class object that represents theclass declaration for the object on which the method is called.

Class method getResource(p. 484) returns the location of its argument as a URL. Themethod getResource uses the Class object’s class loader to determine the location of the resource.

• The horizontal andvertical alignments of a JLabel can be set with methods setHorizontal-Alignment(p. 484) and setVerticalAlignment (p. 484),respectively.

JLabel methods setText (p. 484) and getText (p. 484) setand get the text displayed on a label.

JLabel methods setIcon (p. 484) and getIcon (p. 484) setand get the Icon (p. 484) on a label.

JLabel methods setHorizontalTextPosition(p. 484) and setVerticalTextPosition (p. 484) specifythe text position in the label.

JFrame method setDefaultCloseOperation(p. 485) with constant JFrame.EXIT_ON_CLOSE as the argumentindicates that the program should terminate when the window is closed by theuser.

Component method setSize (p. 485)specifies the width and height of a component.

Component method setVisible(p. 485) with the argument true displays a JFrame on thescreen.


未完待续...