Use swing components in NetBeans 4.1

Source: Internet
Author: User
Tags netbeans

We create an application called Colorswitcher. It can switch the color of the panel from light to Gray and black.
First, create a new Colorswitcher Application project: Select "File"--> "New Project" (Ctrl+shift+n). Alternatively, you can click the New Project icon in the IDE toolbar.

In the Categories pane, select the General folder. In the Projects pane, select Java Application, and then click Next.

Enter "Colorswitcher" in the Project Name field and specify the project location D:\APP.

Make sure the Set as main project check box is selected and deselect create main class If the option is selected.

Click Finish.

The IDE creates the D:\App\ColorSwitcher folder at the specified location in the system. This folder contains the associated files for all projects,
You can view the structure using the Files window. As shown in figure:

Second, create the container we need to create a Java container for other GUI components that need to be placed. After you create a new application, you may notice that the Source Packages folder in the Projects window contains an empty < Default Package > node. Now we will use the JFrame component to create a container and place the container in a new package.

To create a JFrame container:

Right-click the Colorswitcher node in the Projects window and choose New--> JFrame form.

Enter Colorswitch as the class name.

Enter java3z.com as the package.

Click Finish.
The IDE creates the Colorswitch form and the Colorswitch class in the Colorswitch.java application. The java3z.com package replaces < default package >, and the Colorswitcher form opens in the editor window in Design view. As shown in figure:

After you add the JFrame container, the IDE opens the newly created Colorswitch form in an editor tab with a toolbar that contains a toggle button for source and design. By using these toggle buttons in the toolbar, you can choose to view the source code of the Colorswitch class or the graphical view of its GUI components. The Colorswitch class will initially open in Design view, and we will use the following three panels primarily, which can be turned on or off by window in the menu.

Component Panel. Contains labels for various jfc/swing, AWT, and JavaBeans components, as well as a series of layout managers.
Inspector. Provides representations of all components, including visual and non-visual components that are represented in the application as a tree hierarchy. The inspector also provides visual feedback about which component in the tree is being edited in the editor, and allows you to organize the components in the available panels.
Property. Displays the properties of the currently selected component in the Inspector, editor, project, or File window.
Click the source button to display the Java source code for the application and the portion of the code generated by the IDE (represented in blue protection blocks, not editable in Source view). When you are in Source view, you can only type in the white area of the editor. Clicking the Design button returns the IDE's editor to the graphical view.

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.