Documentation

The Java™ Tutorials
Hide TOC
Creating a Project创建项目
Trail: JavaBeans(TM)
Lesson: Quick Start

Creating a Project创建项目

The easiest way to learn about JavaBeans is to start using them. To begin, download and install the latest version of NetBeans. This tutorial describes how to use NetBeans version 7.0.了解JavaBeans最简单的方法是开始使用它们。首先,下载并安装最新版本的NetBeans。本教程介绍如何使用NetBeans 7.0版。

NetBeans is a bean builder tool, which means it recognizes JavaBeans components (beans) and enables you to snap components together into an application with ease.NetBeans是一个bean构建器工具,这意味着它可以识别JavaBeans组件(bean),并使您能够轻松地将组件组合到应用程序中。

A Button is a Bean按钮是一个Bean

Start NetBeans. Choose File > New Project... from the menu.启动NetBeans。从菜单上选择“文件”>“新建项目…”。

Choose Java and Java Application
Click for full image单击查看完整图像

Select Java from the Categories list and select Java Application from the Projects list. Click Next >.从类别列表中选择Java,然后从项目列表中选择JavaApplication。单击下一步>

Enter a project name
Click for full image单击查看完整图像

Enter SnapApp as the application name. Uncheck Create Main Class and click Finish. NetBeans creates the new project and you can see it in NetBeans' Projects pane:输入SnapApp作为应用程序名称。取消选中创建主类,然后单击完成。NetBeans创建了新项目,您可以在NetBeans的项目窗格中看到它:

SnapApp in the Projects pane

Control-click on the SnapApp project and choose New > JFrame Form... from the popup menu.控制单击SnapApp项目,然后从弹出菜单中选择新建>JFrame窗体。

Create a new frame
Click for full image单击击查看完整图片

Fill in SnapFrame for the class name and snapapp as the package. Click Finish. NetBeans creates the new class and shows its visual designer:填写SnapFrame作为类名,并将snapapp作为包。单击“完成”。NetBeans创建新类并显示其可视化设计器:

NetBeans' visual designer
Click for full image点击查看完整图片

In the Projects pane on the left, you can see the newly created SnapFrame class. 在左侧的项目窗格中,您可以看到新创建的SnapFrame类。In the center of the screen is the NetBeans visual designer. On the right side is the Palette, which contains all the components you can add to the frame in the visual designer.屏幕中央是NetBeans可视化设计器。右侧是调色板,其中包含您可以在可视化设计器中添加到框架中的所有组件。


Previous page: Quick Start
Next page: A Button is a Bean