Getting started series-Actions of netbeans

Source: Internet
Author: User
Tags netbeans

Action is not a very special technique, but it is widely used in Java swing suites. I have written many program rumors that Java swing action is a typical design in Java.

The action of netbeans is also based on the Java swing operating system, which is used in menus and tool bar.
Or some single-action functions. However, netbeans is a platform that provides similar functions. Therefore, it supports action compared to Java
Swing is much richer. I have found an article on the netbeans website that describes the translation action. If you can accept English files, take a look at the actions API.
This article will introduce various actions in netbeans, which will be similar to the articles in netbeans.
Action is the only difference ). In addition, in the subsequent article, we will explain how to design each action one by one.

1. Actions of netbeans

Although netbeans uses the common Java action function, Java swing action cannot meet the needs of a platform. I believe that anyone who has developed the RCP platform will know the truth. Therefore, netbeans has established many different types of systemactions to provide more types of applications, such as: interfaces provided by the Action and actions with condition line. Such design will save a lot of effort for developers who use netbeans to develop their systems.

Actions used in netbeans are divided into five types: Java swing action, callablesystemaction, callbacksystemaction, nodeaction, and cookieaction. In addition to these five action classes, netbeans also provides interfaces for creating user interfaces and some common small tools, which will be introduced in later content.

2. Introduction of Action types

A. Java swing action

This type of action is often used in topcomponentgetActions()And NodegetActions(boolean context)
Method. In the early design of netbeans, systemaction was used instead of Java swing action. However
After version 3.x, you can change it to Java swing action. Provided by top component and node of netbeans
Java swing action will not have any restrictions on semantic or support for functions. Therefore, you must design Java swing
You can design the action.

B. callablesystemaction

This type of action is often used in Main Menu, tool bar, And popup menu, generally, it can be used to provide the main menu, tool bar, or popup menu User Interface (this is because it implements the presenter
Under the interface ). In addition, the enable state of callablesystemaction is defined by callablesystemaction
You must know when the Enable and disable is required when you implement such a case, otherwise, the created interface will be always.
Enable. Generally, we will use callablesystemaction to design features that are very independent and do not have any relationship with others. For example:
About and memory usage. In this way, you can provide a special user interface and make it always enable.
You may think
This action is clearly an interface, which is very different from the Java swing action of the traditional system. Java swing
You can ignore the user interface that calls an action. However, callablesystemaction
What is the user interface. In fact, this is an experimental charge design in netbeans. Early on, when developers developed their own RCP platform, they encountered the following problems:
What should I do if action has the desired user interface? Because not every action can accept menu bar or jbutton, they may want to use
Jcombobox or various other user interfaces. Netbeans developers also encountered similar problems, so they designed the presenter.
And use it to provide different user interfaces. This part will have a more detailed introduction in the subsequent chapter. In addition, although netbeans has designed presenter
This problem can be solved, but it is too difficult to implement a presenter every time you make an action. So netbeans Design
Callablesystemaction provides the actual setting. In the presenter's javadoc
It is mentioned that most users will actually call the systemaction when providing user interfaces.

C. callbacksystemaction

You may find that the callbacksystemaction itself is committed to the callablesystemaction
Therefore, it can also provide user interfaces. Specifically, callbacksystemaction itself is an action that provides the user interface.
In addition, netbeans does not suggest implementing the action program because it will not be called. It is said that everyone may be very reluctant to be called.
Action. The design like netbeans also has its story. At the beginning, the creator was designing his own RCP
The platform has also encountered this problem: Some user interfaces will change the focused window, and they hope to have different semantic, such
Copy, cut, and paste act on text in the text-based window, but in the file-based
In the window, the operations of the copy, cut, paste tool bar and menu
There is only one bar. At this time, RCP will convert the focused window into different actions. Netbeans DesignContextawareactionIt is used to solve this problem. In the same way, netbeans
For the actual work of the regionalization system, they designed callbacksystemaction to deal with such problems. In
In callbacksystemaction, it records the action binding of different focused windows for us.
In the focused window, provide the corresponding actionmap object response. Some common user interfaces in netbeans are also used.
Callbacksystemaction, such as copy, cut, paste, delete, find, print... .

D. nodeaction

Nodeaction is a node-related action. For more information about node, refer to the information related to node on this site.

The usage of nodeaction will be completely different from the three previously introduced actions. It can be regarded as an action with specified row conditions.
When its primary row condition is sufficient, it can be merged. The condition row of nodeaction is actually used to query the node provided by focused window.
Whether to meet the internal requirements. When the focused window changes or the node changes it providesenable(Node[] activatedNodes)The method will be called to determine whether its line conditions are sufficient. If so, the user interface it corresponds to will be used by others.

Many interfaces in netbeans use nodeaction, such as new and ,... .

E. cookieaction

Cookieaction is an action that supports nodeaction. It is also an action that provides condition row, but it is not like the condition row of nodeaction that is related to node, its delimiter lineNode. Cookie
Yes. Cookieaction is usually used as a cookie interface in addition to its own method.
To enable the focused window to provide the rows. For example, the saveaction in netbeans is
Cookieaction, which also provides a savecookie interface, when we have files to provide memory, as long as one
The savecookie is placed in the correct object, and the saveaction will be reused.

Nodeaction and cookieaction are the same actions as each other.
Nodeaction is large, so many functions of netbeans use cookieaction.
For example, save, open, edit, print... .

Nodeaction and cookieaction have very powerful functions. before using it, you may not be able to understand its application. However, in the subsequent articles, we will use them one by one. By now, we will be more able to understand their complexity.

3. tools related to netbeans and action

Netbeans has been around for many years. Many of us may find it difficult to design actions, such as setting mnemonic, icon, and so on... And so on. They have all been designed completely. The following describes a commonly used and action-related tool:

A. Actions

Actions can be used to link a user interface and action.

B. jpopupmenuutils

Jpopupmenuutils allows you to add a new project in a jpopupmenu that has been shown and subsequently added. In addition, it can also protect a jpopupmenu metric, it will not run out of the screen of the entire computer.

C. mnemonics

Mnemonics is a type that is very commonly used by consumers. It can be used to create mnemonic for abstractbutton and label.
It is used in the same way as when VB or other MS-Windows AP menus are developed. You only need to add the "&" symbol, it will set the subsequent characters
Mnemonic, set the text at the same time. For example, save & As will be shown as saveAS

This article describes the actions of netbeans and some common tools, tools or actions described in this article will be used frequently.

 

From: http://fox.jenming.info /? P = 21

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.