Example : How to start/open a Java (offline project) using NetBeans IDE 8.2?
- Open Netbeans IDE 8.2 - File - New Project - Select 'Java' from Categories - Select 'Java Applications' from Projects - Next - Put name of project in 'Project Name' box say 'Java Application1' - Select the project saving location such as C/D/E drive etc. - Uncheck 'Create Main Class' option strictly - Finish - Now Java project window appears with 'Projects,Files & Services' Tabs in left side pane.
Example : How to create a new Java Page to create a Java Form or Design Page using NetBeans IDE 8.2?
Open Net Beans 8.2 - Open your project - Right click on 'project name' folder or
'src' - New - Choose and click 'JFrame Form' - Put the name in the 'Class name'
box - Finish - Blank JFrame Form appears - select 'Jpanel' from 'Palette' tab,
from rightward pane - Now, on Jpanel create design by drag and drop desired
controls using 'free design' layout.
Example : How to select or change the Layout of a Java Page to create a Java Form or Design Page using NetBeans IDE 8.2?
- Right click on the Page - click 'set layout' - choose desired layout from appeared
option(free design).
Example : How to select multiple Controls on a Java Form or Design Page in NetBeans IDE 8.2?
- Select all the controls using mouse in the Jframe form.
- Press 'shift' button - select desired controls using mouse in the panel .
Example : How to create multiple Controls by using/copying a single control on a Java Form or Design Page in NetBeans IDE 8.2?
Select that control - Press 'ctrl' button and any arrow key, usually left or right.
Example : How to create a new Java package/change the ‘default package’ name of Java Applications using NetBeans IDE 8.2?
- Right click on the created 'Source Package' of Project name (Java Applications) list - New - Java Package - change the name as per need - ok.
Example : How to create a new JFrame / jInternalFrame / jPanel / jDialog form file using NetBeans IDE 8.2?
- Right click on the created 'Source Package/Default Package' name - New - Other - Swing GUI Forms - choose needed form file - change the name of chosen form file - finish.
Example : How to change the Coding or Variable Names of Java Controls (Box/Buttons, etc.) in form design using NetBeans IDE 8.2?
Step 1 : Open the Java Form in design mode/tab.
Step 2 : Click/Select the controls or buttons or boxes in Design View - In the Right side panel, open the 'Properties' window - Click the 'Code' tab - choose 'Variable Name' and type the coding name in the box(JBtnLogin) - Press Enter - NetBeans 8.2 automatically updates coding names.
Example : How to recover the disappeared Palette / Properties window / Projects tabs / Files tabs / Services tabs in NetBeans IDE 8.2?
- Click on 'Window' menu in Net Beans IDE 8.2 - choose 'Projects/Files/Services' or 'IDE Tools' - choose 'Palette/Properties' option.
Example : How to recover the disappeared Source Code Editor / Design Window in NetBeans IDE 8.2?
- Open Netbeans IDE 8.2 - View menu - check 'show Editor Toolbar'.
-------------- OR -------------
- Open Netbeans IDE 8.2 - View menu - click 'Editors' and choose required one.
-------------- OR -------------
- Open Netbeans IDE 8.2 - open the Page - Right click on open Page tab - Editors - Choose one.
Example : How to run/execute a Java application form in NetBeans IDE 8.2?
3 ways to run the file -
- Right click on JFrame Form list in 'Source Package' of java project in 'Projects' tab - click 'Run File'.
- click on 'Run Project' icon (Triangle Symbol) in the toolbar of Net Beans IDE - Select 'JFrame Form' to execute it.
- Open 'JFrame Form' we want to execute - select 'Source' tab at upper left portion of page - Right click in the page - Select 'Run File'.
Example : How to close/exit a Java application form in NetBeans IDE 8.2?
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
System.exit(0);
//super.dispose();
}
Example : How to convert a String into an Integer and its vice-versa in Java using NetBeans IDE 8.2?
import static javax.swing.JOptionPane.*;
public NumConverion() {
initComponents();
int x1 =Integer.parseInt("1015"); //Code for String into Integer Conversion.
showMessageDialog(null,x1);
int x2 =Integer.parseInt("1025");
showMessageDialog(null,x2);
int x3 = x1+x2;
showMessageDialog(null,x3);
String Str= Integer.toString(x3); //Code for Integer into String Conversion.
showMessageDialog(null,"Total Value = "+ x1+ "+" + x2+ " is "+Str,"Calculation Result",
INFORMATION_MESSAGE);
}
Example : How to move the cursor to the next Java control on pressing the Enter key in Java using NetBeans IDE 8.2? [Enter Event Code]
private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) {
int x= evt.getKeyCode(); // evt is default event.
if (x == 10) // 10 is KeyCode for enter key.
{
jTextField2.requestFocus();
}
----------- OR -----------
private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) {
if(evt.getKeyCode()== KeyEvent.VK_ENTER)
{
jTextField2.grabFocus();
}
}
NB : Path = Right click on the text field – Events – Key – Keypressed. Now write above Code is in appeared code area. Do same for all the remaining java controls.
Example : How to move the cursor to the next Java control on pressing the Up & Down arrow keys in Java using NetBeans IDE 8.2. [Arrow Key Event Code]
private void jTextField2KeyPressed(java.awt.event.KeyEvent evt) {
if (evt.getKeyCode() == KeyEvent.VK_UP)
{
jTextField1.requestFocus();
}
---------------------------
if (evt.getKeyCode() == KeyEvent.VK_DOWN)
{
jTextField3.requestFocus();
}
}
Example : How to maximize the JFrame automatically on the load event?
public registration()
{
initComponents();
setExtendedState(java.awt.Frame.MAXIMIZED_BOTH); // to maximize the jFrame window.
//this.setExtendedState(this.MAXIMIZED_BOTH); // to maximize the jFrame window.
}
![]()
0 Comments