Basic steps for NetBeans GUI programming

Source: Internet
Author: User
Tags netbeans


First, NetBeans design graphical user interface Step 1

1. Directly create JFrame class: Right-click "Package" | new | JFrame form

2. Redefine class name-form class Loginframe

Click Finish to open Design view

Code view

Second, the NetBeans design graphical user interface Step 2

1. Set form Properties

Select Form | Set the values of each property of a form in the Properties panel

Common Properties

Title: Set the caption bar of the form

Resizable: Set whether the form can be resized (depending on the situation)

Defaultcloseoperation: Set form close mode

2. Set the form layout

Right-click the form--Set layout--Select layout mode

The default is free layout

Third, the NetBeans design graphical user interface Step 3

1. Add components and set component properties and variable names

Example 1: Add a label JLabel

property settings

Text: Label text (another: Right-click Label-Edit text)

Font: Format for fonts

Foreground: Font Color

Change variable name (object name)


Right-click Label | Change the name of a variable

Label variable name: Lblusername

Example 2: Adding a text field

property settings

Columns: Number of initial columns of text field

Text: Literal field initial value

Editable: Whether you can edit

Change variable name (object name)


Right-click the Text field | Change the name of a variable

Text field variable name: txtUserName

Example 3: Add a button

property settings

Text: Button text

Font: Button text Format

Foreground: Font Color

Change variable name (object name)


Right-click Button | Change the name of a variable

Button variable Name: Btnlogin

Iv. NetBeans Design Graphical user interface Step 4

V. NetBeans design graphical user interface Step 5

1. Event handling (Take the button as an example)

Method 1: Right-click the button | Events | Action | Actionperformed

Method Two: Double-click the button

2. Write Event handling code

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.