About Resources in the Swing Application Framework
See Also
- The Swing Application Framework (JSR 296) is no longer developed and will not become part of the official Java Development Kit as was originally planned. It is still included in the IDE and you can use this library as it is, but no further development is expected. If you are looking for a Swing-based application framework, consider using the NetBeans Platform.
The main difference between the Swing Application Framework and the NetBeans Platform
in this regard is scope. The Swing Application Framework is more lightweight and
easier to get started with. The NetBeans Platform is more full-featured and
better suited for large and extensible applications.
The Swing Application Framework simplifies the handling of resources in
applications and makes it possible for more things to be stored in resource bundles.
A typical Swing Application Framework application has resource bundles
at both the application level and the class level. The class-level resource bundles have the same names as their
corresponding .java classes except that they contain the .properties
extension. All of these bundles are encapsulated by a ResourceMap object.
You can edit some standard application level resources (such as
application name) in the
Project Properties dialog box. Any application-level resources not
included in the Project Properties dialog box (such as resources that
you define yourself) can be edited in the
the .properties file that corresponds with the name of the main
application class.
You can open the Project Properties dialog box by right-clicking the project's node and
choosing Properties. Application properties appear in the Application panel
and the Desktop Application panel.
When you start an application from the Java Desktop Application project template,
by default your code is generated with the Swing Application Framework's conventions for
managing resources, such as UI text. The values of component properties that you
set are stored as resources as well.
Notes:
- You can configure the way that code is generated to handle resources.
Select the root form node in the Inspector window. In the Properties window,
select one of the following from
the Automatic Resource Management drop-down list.
- Off. All property values are hard-coded in the .java file.
- Internationalization. Resource code is generated for all
strings, and the string values are stored in a .properties file.
- All Resources. Resource code is generated for all
strings, colors, fonts, and icons. The values for these properties
are stored in a .properties file.
- Resources + Injection. Code is generated so that
resource values are injected into the application from
.properties files at runtime.
- If you do not want the value for a specific property to be stored in
a .properties file, click the ellipsis (...)
button next to the given property in the Properties window. Then clear the
Define as Resource property.
You can read more about resource management in the Swing Application Framework's
API documentation. Choose
Help > Javadoc References > org.jdesktop.application (Swing Application Framework [JSR-296]).
- See Also
- About the Swing Application Framework
- About Java GUIs
- GUI Builder Tasks: Quick Reference
- Designing Java GUIs with the GUI Builder
Legal Notices