Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of Swing control in J2SE

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what is the use of the Swing control in J2SE. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

An interesting Swing feature has been added to J2SE version 1.4. The Swing control can now provide auditory feedback to respond to specific events, although this feature is disabled by default. This new feature helps Swing controls better mimic the behavior of controls in the system's local operating system.

Swing uses a pluggable look and feel (Pluggable Look-and-Feel,PLAF) architecture. Developers do not have to hard-code settings such as colors and fonts for different components; instead, the component will request these settings from the User Interface (UI) Manager. As a developer, you can tell the UI manager what kind of interface you want users to see; you can choose Windows, Motif, or Metal styles, and so on. The UI manager can then actually tell each component how it should display itself. For components such as buttons, the foreground color is controlled by setting the Button.foreground property, as follows:

Anager.put ("Button.foreground", Color.red)

In this case, Button.foreground is the user interface property name, while Color.red represents a specific setting. After you change the setting, the foreground color of all new buttons will be red. (there are also ways to change the foreground color of previously created buttons. Although different preset look and feel provide default values for these settings, you can still reset them

Under J2SE 1.4, you can enable auditory feedback in a similar way. All you need to know is the name of the UI property and the appropriate settings. The property is named AuditoryCues.playList here, and the setting is a String array of auditory prompt names. The UI Manager then maps these names to the sound files that will be played when a particular operation occurs.

A list of sounds supported in the look and feel provided by the system is given below. Their names themselves are quite explanatory.

CheckBoxMenuItem.commandSound InternalFrame.closeSound InternalFrame.maximizeSound InternalFrame.minimizeSound InternalFrame.restoreDownSound InternalFrame.restoreUpSound MenuItem.commandSound OptionPane.errorSound OptionPane.informationSound OptionPane.questionSound OptionPane.warningSound PopupMenu.popupSound RadioButtonMenuItem.commandSound

This is the case with the array of String names provided to the AuditoryCues.playList property-a collection of event names. The UI Manager is responsible for mapping these names to sounds specific to look and feel.

This is the end of this article on "what is the use of Swing controls in J2SE". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report