22
Netbeans IDE Netbeans IDE

Ravi Sharma - GUI (netbeans ide) - HconGroupsgroups.hcon.in/.../hgd_ravi_sharma_-_gui_netbeans_ide.pdf · 2019-12-07 · 1. Title Bar 2. Menu Bar with pull down menus 3. Toolbars

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Netbeans IDENetbeans IDE

GUI is a type of user interface that allows users to interact with electronic devices through graphical icons and visual indicators such as secondary notation, as opposed to text-based interfaces, typed command labels or text navigation. GUIs were introduced in reaction to the perceived steep learning curve of command-line interfaces(CLI), which require commands to be typed on the keyboard.The actions in GUI are usually performed through direct manipulation of the graphical elements. Besides in computers, GUIs can be found in hand-held devices such as MP3 players, portable media players, gaming devices, household appliances, office, and industry equipment. The term GUI is usually not applied to other low-resolution types of interfaces with display resolutions, such as video other low-resolution types of interfaces with display resolutions, such as video games (where HUD is preferred), or not restricted to flat screens, like volumetric displays because the term is restricted to the scope of two-dimensional display screens able to describe generic information, in the tradition of the computer science research at the PARC (Palo Alto Research Center).

NetBeans is an integrated development environment (IDE) for developing primarily with Java,but also with other languages, in particular PHP, C/C++, and HTML5. It is also an application platform framework for Java desktop applications and others.The NetBeans IDE is written in Java and can run on Windows, OS X, Linux, Solaris and other platforms supporting a compatible JVM.The NetBeans Platform allows applications to be developed from a set of modularsoftware components called modules. Applications based on the NetBeans Platform (including the NetBeans IDE itself) can be extended by third party developers.

NetBeans IDE allows us to develop applications by dragging and positioning GUIcomponents from a palette onto a container. The GUI builder automatically takescare of the correct spacing and alignment of the different components relative toeach other. The JFrame acts as a container for the elements like the JLabel,JButton, JTextArea and allows direct editing of their associated properties at thethedesign time and run time. The related methods are used in the code to developapplications for a specific task. The concept of variables and control structuresare used to simplify the code of the applications.

1. Title Bar

2. Menu Bar with pull down menus

3. Toolbars

4. GUI builder: It is an area to place components on the form visually. There are twoviews of the GUI builder- the Design View and the Source View. We can switch overfrom one view to another by simply clicking on the source and design tabs directlyabove the Design Area.above the Design Area.

5. Palette: Palette contains controls or components used to create GUI applications.

6. Inspector Window: This window is used to display a hierarchy of all the componentsor controls placed on the current form.

7. Properties Window: Using this window we can make changes in the properties ofcurrently selected control on the form.

8. Code Editor Window: - It is the area where we write code for our java application.

Components:

Components (also known as "widgets") are the basic interface elements the user interactswith: jlabels, jbuttons, jtextfields etc. Components are placed on a container (like thejFrame). There are two types of controls :Parent or container controls:They act as a background for other controls. Forexample-Frame. When we delete a parent control, all its child controls getexample-Frame. When we delete a parent control, all its child controls getdeleted. When we move a parent control all its child controls also move alongwith it.Child controls:controls placed inside a container control are called childcontrols. For example-Text Field, Label, Button etc.

Creating a New ProjectThe steps to create a new project are:

1. Select New Project from the File menu. You can also click the New Project button inthe IDE toolbar.

2. In the Categories pane, select the General node. In the Projects pane, choose theJava Application type. Click the Next button.

3. Enter the name of the project in the Project Name field and specify the projectlocation. Do not create a Main class here.

4. Click the Finish button.4. Click the Finish button.

Properties and methods description of jTextfields :

Properties and methods descriptions of jlabel:

A simple Netbeans design for multiple checker

Its source code

private voidjRadioButton1ActionPerformed(java.awt.event.ActionEvent evt){double Number=Double.parseDouble(jTextField1.getText());if (Number%3==0)JOptionPane.showMessageDialog(this,"It is multiple of 3");elseelseJOptionPane.showMessageDialog(this,"It is NOT multiple of 3");}

A Netbeans design for creating business calculator

Its source code://Business Calculatorprivate voidjButton1ActionPerformed(java.awt.event.ActionEvent evt){double CP,Profit=0,SP;CP=Double.parseDouble(jTextField1.getText());Profit=jComboBox1.getSelectedIndex();SP=CP+CP*(Profit/100);SP=CP+CP*(Profit/100);jTextField2.setText(Double.toString(SP));} private voidjButton2ActionPerformed(java.awt.event.ActionEvent evt){jTextField1.setText("");jComboBox1.setSelectedIndex(0);jTextField2.setText("");

}

private voidjButton1ActionPerformed(java.awt.event.ActionEventevt){double CP,Profit=0,SP;CP=Double.parseDouble(jTextField1.getText());switch (jComboBox1.getSelectedIndex()){case 0:Profit=5;break;//if first item selected profit is 5case 0:Profit=5;break;//if first item selected profit is 5case 1:Profit=10;break;//if second item selected profit is 10case 2:Profit=15;break;case 3:Profit=20;break;case 4:Profit=25;break;default:Profit=0;break;}

Netbeans design to check whether a number is palindrome or not

//Reverse Number Program with Palindrome Checkprivate voidjButton1ActionPerformed(java.awt.event.ActionEvent evt){long Number,Temp,RevNumber=0;Number=Long.parseLong(jTextField1.getText());Temp=Number;while (Temp>0) // till temp > 0 continue to perform the loop{RevNumber=(RevNumber*10)+(Temp%10);RevNumber=(RevNumber*10)+(Temp%10);// RevNumber is multiplied by 10 and added to the// remainder of temp divided by 100Temp=Temp/10;}jTextField2.setText(Long.toString(RevNumber));if (Number==RevNumber)JOptionPane.showMessageDialog(this,"Number is Palindrome");elseJOptionPane.showMessageDialog(this,"Number is not a Palindrome");}

private voidjButton2ActionPerformed(java.awt.event.ActionEvent evt){jTextField1.setText("");jTextField2.setText("");}

Ravi Rebellious SharmaRavi Rebellious SharmaRavi Rebellious SharmaRavi Rebellious SharmaRavi Rebellious SharmaRavi Rebellious SharmaRavi Rebellious SharmaRavi Rebellious Sharma