Learning Swing with Java Foundation Classes (JFC) and Swing

Slide Note
Embed
Share

Java Foundation Classes (JFC) and Swing provide a powerful set of tools for building graphical user interfaces in Java applications. This includes Swing GUI components, pluggable look-and-feel support, accessibility APIs, Java 2D graphics, and internationalization capabilities. By learning Swing with the NetBeans IDE, you can create applications with ease and focus on functionality over infrastructure.


Uploaded on Sep 12, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. JAVA JAVA

  2. User Interface JFC and Swing JFC is short for Java Foundation Classes, which encompass a group of features for building graphical user interfaces (GUIs) and adding rich graphics functionality and interactivity to Java applications. It is defined as containing the features shown in the table below.

  3. User Interface JFC and Swing Swing GUI Components Includes everything from buttons to split panes to tables. Many components are capable of sorting, printing, and drag and drop, to name a few of the supported features. Pluggable Look-and-Feel Support The look and feel of Swing applications is pluggable, allowing a choice of look and feel. For example, the same program can use either the Java or the Windows look and feel. Additionally, the Java platform supports the GTK+ look and feel, which makes hundreds of existing look and feels available to Swing programs. Many more look-and-feel packages are available from various sources. Accessibility API Enables assistive technologies, such as screen readers and Braille displays, to get information from the user interface. Java 2D API Enables developers to easily incorporate high-quality 2D graphics, text, and images in applications and applets. Java 2D includes extensive APIs for generating and sending high-quality output to printing devices. Internationalization Allows developers to build applications that can interact with users worldwide in their own languages and cultural conventions. With the input method framework developers can build applications that accept text in languages that use thousands of different characters, such as Japanese, Chinese, or Korean.

  4. User Interface JFC and Swing Which Swing Packages Should I Use? The Swing API is powerful, flexible and immense. The Swing API has 18 public packages: javax.accessibility javax.swing.plaf javax.swing.text javax.swing javax.swing.plaf.basic javax.swing.text.html javax.swing.border javax.swing.plaf.metal javax.swing.text.html.parser javax.swing.colorchooser javax.swing.plaf.multi javax.swing.text.rtf javax.swing.event javax.swing.plaf.synth javax.swing.tree javax.swing.filechooser javax.swing.table javax.swing.undo

  5. User Interface JFC and Swing Fortunately, most programs use only a small subset of the API. This lesson sorts out the API for you, giving you examples of common code and pointing you to methods and classes you're likely to need. Most of the code in this lesson uses only one or two Swing packages: javax.swing javax.swing.event (not always required)

  6. User Interface Learning Swing with the NetBeans IDE The goal of this lesson is to introduce the Swing API by designing a simple application that converts temperature from Celsius to Fahrenheit. Its GUI will be basic, focusing on only a subset of the available Swing components. We will use the NetBeans IDE GUI builder, which makes user interface creation a simple matter of drag and drop. Its automatic code generation feature simplifies the GUI development process, letting you focus on the application logic instead of the underlying infrastructure.

  7. User Interface The Design Area The Design Area is where you will visually construct your GUI. It has two views: source view, and design view. Design view is the default, as shown below. You can toggle between views at any time by clicking their respective tabs

  8. User Interface The Design Area A quick look at the source view reveals that the IDE has created a private method named init Components, which initializes the various components of the GUI. It also tells the application to "exit on close", performs some layout- specific tasks, then packs the (soon to be added) components together on screen.

  9. User Interface The Palette The Palette contains all of the components offered by the Swing API. You can probably already guess what many of these components are for, even if this is your first time using them (JLabel is a text label, JList is a drop-down list, etc.)

  10. User Interface The Poperty Editor The Property Editor does what its name implies: it allows you to edit the properties of each component. The Property Editor is intuitive to use; in it you will see a series of rows one row per property that you can click and edit without entering the source code directly. The following figure shows the Property Editor for the newly added JFrame object

  11. User Interface Exercise Temperature Conversion Use the link listed on Moodle and follow the instructions

Related