当前页面: 开发资料首页 → Netbeans 专题 → 添加按钮的功能(初学者指南)(2)
摘要: This tutorial teaches you how to build a simple GUI with back-end functionality. This tutorial is geared to the beginner and introduces the basic construction of a GUI with functionality. A basic understanding of the Java Programming Language is required.
After creating the new application, you may have noticed that the Source Packages
folder in the Projects window contains an empty <default package>
node. To proceed with building our interface, we need to create a Java container
within which we will place the other required GUI components. In this step we'll
create a container using the JFrame
component and place the container
in a new package.
my.NumberAddition
as the package.
The IDE creates the NumberAdditionUI
form and the
NumberAdditionUI
class within the NumberAdditionUI.java
application, and opens the NumberAdditionUI
form in the
GUI Builder. Notice that the my.NumberAddition
package replaces the default package.
Next we are going to populate our application's front end with one JPanel, and three JLabels, JTextFields and JButtons each. The JFrame with the aforementioned components will look like this.
Select Windows > Palette to open the Palette if you don't see it. You use the Palette to drag and drop UI components to the design area.
Number Addition
in the Title field.
Click OK to save the changes and exit the dialog.