Tuesday, November 26, 2019

How to Define or Change Default Main Class in Java NetBeans

How to Define or Change Default Main Class in Java NetBeans

This article related to the jFrame class for Execution time to define as default. By Using Netbeans for Java programming, there is simple process to Define or Change Main Class in Java any time.

Suppose, When I was designing a GUI Swing application in java through NetBeans, Suppose, we add two jFrame class, First jFrame class has designed as entry form and Second has designed as Login class. And I Want to define Login Form class as main class in first priority. But, because we first use Entry Form jFrame, then during run time it default show this as Main Class in Java.

So, for this solution, SKOTechLearn describe that how to Define or Change Main Class in Java NetBeans.

How To Set or Change Any jFrame as Main Class in Java?

Here we will learn very interesting point that we can change main class with two simple ways.

  • Change Main Class in Java at Design Time in NetBeans
  • Change Main Class from Jar file After Build jar

Design or Add jFrame to Create Swing GUI Project in Java NetBeans

 Change Main Class in Java at Design Time in Netbeans :
During design time, you just have to change some settings as described below:
  1. If you create a Project or design application in NetBeans, just go to “Projects” Tab in NetBeans.
  2. After that find your Project and target to right click and find “Properties” option from drop down list and click on it.
  3. You will find that, “Project Properties” window will display including your Project Name.
  4. In this Screen there is “Categories” tree view box containing many option. In this Tree view find “Run” option and select it. 
  5. Now, we will proceed in Changing Main Class in Java Process. So, Find “Main Class:” option. Press “Browse…” Button related to “Main Class:” option. 
  6. Now “Browse Main Classes” Dialog Box will show. In this dialog box, you will find the number of class related to your project will be listed. Just select any one class which you want to define as Main class for your Project.

So, finally, the time to Learn through image description, which are described below.
Main Class Setting in NetBeans

(Simple Tips)How to Open other jFrame through existing jFrame in Java?

So, in this way you can easily change default main class in Java NetBeans.

 Change Main Class from Jar file After Build jar (Executable Jar File) :

Suppose, you have created your jar file or you have to build jar. For Some reason, you want to change the main class. So, what will you do? The answer is given in following way with step by step process.

  • (1):  Go to the jar file’s location, and find your application’s jar file.
  • (2):  Now, right click on jar file and open it as “archive”. I am using 7-Zip to open as archive.
  • (3):  Jar archive contain two folder as “META-INF” and Project name folder. Go to “META-INF” folder and Extract “MANIFEST.MF” file from “META-INF” folder.
  • (4): Open “MANIFEST.MF” file in Notepad. In the last line of Notepad, you will find “Main Class:” containing project name with default class like bellow:
eg.: Main-Class: simple_java. Simple_Java_App 

(Suppose, you have added two class on your application like: “TestJFrame.class” and “Second_Jframe.class”. And you want to make “Second_Jframe.class” as default main class.)

  • (5): So, replace “Simple_Java_App” with “Second_Jframe” like : “ Main-Class: simple_java.Second_Jframe” from Notepad. After that, save Notepad.

Now, If there is complication to understand this process, you can follow the image indication describe bellow.
Change Main Class through Jar MANIFEST
Change Main Class Through Jar File

  • (6): Next step to drag your modified “MANIFEST.MF” file and drop on your jar’s archive’s as “META-INF” folder. Then close archive like bellow.
Modified MANIFEST MF file save in Jar
Drag Modified MANIFEST.MF file on Jar's Archive

  • (7): Finally, Run jar file, you will see that your jar file will be execute with defining or modified main class.

How to Change any Class as Main Executable Class in Java?

So, the above given two process where you can find that how to Define or Change Main Class in Java NetBeans with Complete description through SKOTechLearn.

Also Read another Interesting Tips:

Auto Resizing or Auto Adjust Controls in Java Swing

jLabel Using and Designing Settings and Tips

Sunday, November 24, 2019

Show Files In Jlist In Java Swing From Specific Path In Netbeans With Complete Details

If you want to make project related with files and want to implement your project with files’ list procedure, you can use jlist. In java, jlist play a very important role for exploring the list of files, database data, dynamic data and static data. Here SKOTechLearn will describe how can we Show Files in jList  in Java Swing from specific path in NetBeans?

First Learn How to Show or Add Data or Items in jList in Java Swing?

So, what will we do for it? There is following steps to Learn it.

Drag jList from “Palette” and find “Swing Contol” and Select “List” control and put it on your Java Swing form and change it’s variable name as “MyFiles_Lst”.

After that you can add jButton with change variable nameBrowseBtn” and Text “Browse..” . And add another jButton with variable nameShowFileBtn” and Text “Show Files”. And add jLabel with variable nameMyPath_lbl”. And Last and one more jLabel with change variable name “MyTotalFiles_Lbl”.
Swing Controls Variable Name Use
jList MyFiles_Lst To show files from specific selected location
jButton BrowseBtn To browse path for and set specific location
jButton ShowFileBtn This will show the files in jList
jLabel MyPath_lbl Get path which was selected from “BrowseBtn”.
jLabel MyTotalFiles_Lbl Get the total number of items from “MyFiles_Lst” control.
Now the following image shows these controls with arrow indication.
Swing Controls with Variable Name in java
After adjusting controls according to desire just as mention above image. Now come to the coding point, what we should do for showing files in jList from specific path in java? The answer is described in below steps.

Example to Show Files in jList in Java

First we import some classes that helps for proceeding above process. The Imported class listed as following:
import java.awt.event.KeyEvent;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;

Also Learn Types of Messages using jOptionPane in Java Swing.

Write code for browsing files’ path from ‘ActionPerformed’ event of “BrowseBtn” .
private void BrowseBtnActionPerformed(java.awt.event.ActionEvent evt) { 
        JFileChooser myfileChooser = new JFileChooser();
        // Use JFileChooser for Open Folder Dialog Box.
        if (Files.isDirectory(Paths.get(MyPath_lbl.getText()))) {
            myfileChooser.setCurrentDirectory(new File(MyPath_lbl.getText()));
        int findresult = myfileChooser.showOpenDialog(this);
        if (findresult == myfileChooser.APPROVE_OPTION) {
            // If We Select any file and click on "Open" button. The specified path will be show in "MyPath_lbl" jLabel

When you click on “BrowseBtn”, a Dailog box “Open” will appear. Now, select then path and select any one of listed file.

Note: In “Open” dialog box, you have to select at least one file for defining the path. Then Click on “Open” Button.

Secret to Design jRadioButton in Java Swing with Stylish Look.

Now SKOTechLearn will write code for listing all files in jList. So, we will choose “ShowFileBtn” jButton and go to its “ActionPerformed” event and will write following code.
private void ShowFileBtnActionPerformed(java.awt.event.ActionEvent evt) {
        String mypath = MyPath_lbl.getText();
        String myfiles = null;
        File myfolder = new File(mypath);
        File[] MylistOfFiles = myfolder.listFiles();
        // 'MylistOfFiles' stores all files' list on array
        DefaultListModel MyJlistModel = new DefaultListModel();
        for (int i = 0; i < MylistOfFiles.length; i++) {
            //Loop 'MylistOfFiles' to get the files in jlist
            if (MylistOfFiles[i].isFile()) {
                myfiles = MylistOfFiles[i].getName();
                    // addElemet will add file's name in jList
  // "MyFiles_Lst.getModel().getSize()" - indicate the total number of files in jList

Now This Action Performed will show the Files in jList.

SkoTechLearn suggest you to please proceed step by step, if you want to get proper result on your project in swing java.

Learn How to Change Look or Design jLabel in Java Swing with Example.

Now we will understand by the image indication.
Process to show file in jList in java
Process to show file in jList
As you can see, first we click on “Browse..” button. Then, a “Open” dialog will appear, just input or select your files’ path and then select any file from it.

And press “Open” button. After that the file’s path as string will show in “Files’ Path” jLabel.

Go to “Show Files” button and press it. This process will show the files in jList. And the total number of items will show in “Total Files:” jLabel.

Hidden Tips to Open jFrame from Another Jframe's Controls in Java

There is the easiest way to guide you how you can Show Files in jList in java in swing java from Specific path in Netbeans with SKOTechLearn.

Wednesday, September 11, 2019

Knowledge to Learn Website Design in ASP.Net Easy Tips

Knowledge to Learn Website Design in ASP.Net easy Tips

If you have knowledge about any one programming language, then this is easy to switch to any other programming languages. In same case apply in Asp dot net. If there is some knowledge in C# or VB, it is easy to work on Website Design in ASP.Net.

When start designing and writing some code for further webpage process, you can gain more knowledge about it. If you are new to know webpage development, this web developing platform is right way.
Now, first SKOTechlearn will tell that install Microsoft Visual Studio. After installing visual studio, open it. 

 Start Visual Studio Application:
Start Page’ tab will open in visual studio window. Select ‘New Project..’ option from it. You can Also select ‘New Project...’ option from “File” menu.

New Project” window will be open. Go to Templates on the left side of this window. And select “Visual basic” then select “Web” option from it. Now select “ASP.NET Empty Web Application”.


Visual Studio >> File (menu) >> New Project... >> Visual Basic (Templates) >> Web >> ASP.NET Empty Web Application

After apply all these step, browse file's path for save project and also give Project Name to specify project.

 Create New Project:
Create New Web Project in ASP.net
Create New Web Project

After creating new project, go to “Solution Explorer” window and right click on project name.

A drop down menu will appear, select “Add” option then select “New Item..”. “Add New Item” window will appear.

Select “Web Form” and input Form Name and after that press “Add” button. Now, by apply this process web form will be add to project window.

Learn about Menu design in ASP.Net with simple easy way.


Solution Explorer >> (Project Name) Right Click >> Add >> New Item >> Web Form >> Add

 Add Web Form:

Add web Form development in ASP.net
Add web Form
Go to system and apply these steps.

Now, let’s learn some basic important point of web page design.
1. ToolBox
2. Solution Explorer
3. Properties
4. Error List
5. Design
6. Source
 Different types of Screen Description
There is following types of window include during design any application or web application in Visual Studio 2010.

1. ToolBox:
Like other programming language (like Visual Basic, Netbeans, VB.net, PHP etc.), Toolbox play a main roll to design any project. Toolbox contain many controls (like: Textbox, Label, Combo,List etc.) to setup according project requirement. Without these controls any developer cannot complete their application development. In easy word, a person’s life is incomplete without Tools, like this way a developer is incomplete their development without Toolbox.

2. Solution Explorer:
Solution Explorer window contains or shows application’s files like: Web From, DLL, CSS etc. In this window switch to any web form to web application. Without this window, it’s difficult to reach other form. This window contain many feature Like: Build, Clean, Publish, Add Item etc.

3. Properties:
This window defines the setting of every control. Properties window contain many settings related with controls. Every control have predefine settings which we have change according to requirement. The properties window contain settings like: BackColor, BorderColor, BorderStyle, Font, ForeColor, Height, Width etc.

4. Error List :
When developing any website, may be, coding mistake will happen. This window shows errors and warning List related to forms while writing code. The advantage of this window is that when we click on any error message, it will show error location on code window to easily correct coding error.

5. Design:
Design view tab in web form which shows what type webpage will looks in browser. In Design view, you can edit your page looks. You can put controls in design view and adjust size and position according to requirement. This will provide to test design view after running application.

6. Source:
The source view displays the HTML and script coding, where you can write HTML code or write script for web page. This window provide setting page controls through editing that Particular HTML code. You can also write CSS Style code here. Every form contain separate Source view window.
ASP.NET Important Feature for web development
ASP.NET Important Feature
There is main necessary understanding point which you have to remember during start web application development in ASP.NET.

Start webpage design in ASP.Net with step by step Process. SKOTechLearn will help as much as possible.

Monday, July 15, 2019

Connect Sql Server Database in Netbeans with Sqljdbc Driver

Connect Sql Server Database in Netbeans with Sqljdbc Driver

In Netbeans, there is facility to connect any type of database through server or locally. But there is point that, you have to use particular driver for it. Suppose, if you want to View database and related tables on your system, and want to implement or create database or tables in related SQL server, So, it provides the easy way of performing these kinds of things.

So, In this post we will learn, how to connect MS SQL server database in Netbeans with sqljdbc driver with SKOTechLearn Tips.

First remember one thing; you need a driver for it. And this name is sqljdbc4.jar or maybe you find latest version of it. There is many downloading site available there, you can download from here.

 What is the Use of Services Tab in Netbeans:
One main thing you have to understand that, in Netbeans, there is "Services" Tab which is use for database connection, web services etc. for more details of "Services" go Service Tab In Netbeans. Mainly we can use it for hosted or local database connection.

Now come to the point, After downloading sqljdbc4.jar file. Follow the steps Bellow.

 How to connect sqljdbc driver with Netbeans?

For it, just follow the step by step process as given follows:
  1. Open this application and there are three tabs with name “Projects”, “Files” and “Services”. Go to “Services” tab in Left side of screen.
  2. After that the “Services” tab containing the tree list like “Databases”, “Web Services”, “Servers” etc.
  3. Go to “Databases” Option. And Expand it through the plus sign .
  4. This will also show you sub tree list with options “Java DB”, “Drivers” etc.
  5. Right click on “Drivers” option and select “New Driver…” option from drop down menu.
  6. New JDBC Driver” screen will show. Find “Add..” button and click on it.
  7. A “Select Driver” screen will appear. Just go to path where the sqljdbc is exists. And select it and Press “Open” button.
  8. After that press “OK” button from “New JDBC Driver” screen.
Just figure out following image.
sqljdbc driver with Netbeans
Driver process in Netbeans
Now the SQL server driver will be connected to Netbeans Database services.

MS SQL Server Connect with Netbeans' Services.

 How to connect SQL Server with Netbeans?

After completion of above process, now it’s time for database connectivity from server. So First you have to again go to “Services” tab and proceed in following process.
  1. Again go to “Databases” option from Tree list and right click on it.
  2. Right click and select “New Connection…” option.
  3. A “New Connection Wizard” window will appear.
  4. Here find “Driver” combo box and select your created connection here. Then press “Next” Button.
  5. This will proceed in “Customize Connection” screen.
  6. Here fill up Field with following way.
Host: xxx.xxx.xx.xx
Database:SKOTechLearn (Whatever your database name)
Instance Name:
User Name:SA (or anything which you have defined)

 7. Now, Press on “Test Connection” button. If Test Connection Success, then press on “Next” button.
 8. Next Screen will be for “Choose Database Schema”. Here, select schema like “dbo”.
 9. After that “Choose name for connection” screen will show, input your desire name and then click on “Finish” button.
SQL Server Connection Process in Netbeans
SQL Server Connection Process
As you can see the related database connection has been established with input connection name eg. “MYDB_SKOTechLearn”. Now when you expand it, it will show “SKOTechLearn” Database and inside this, there is table details you find there. Now you can easily create your table inside it.

So, Here SKOTechLearn Tips describe the way, where you can Connect SQL Server Database in Netbeans with Sqljdbc Driver.

Saturday, June 29, 2019

Types and Use of JOptionPane in Java Swing for Messages in NetBeans

Types and Use of JOptionPane in Java Swing for Messages in NetBeans

In java, if you want to show message box, you have to use jOptionPane class to handle message dialog box. If you know, how to show Message box in vb or vb.net. Then you will not face any problem in java, basically every programming language contains some same things in coding.

So, in this post SKOTechLearn will describe the process of showing different types of messages through  jOptionPane  in java  Swing NetBeans.

What is jOptionPane in Java?

It is simply a message box in which you can define a message and show in different types as we learn in this post. 

There is following types of Msg dialog appearance that we will learn:

 (1). Show simple Plain MsgBox
 (2). Msgbox with Custom image icon dialog
 (3). MsgBox in Yes/No option with image dialog
 (4). Error MsgBox dialog
 (5). Information MsgBox dialog

So, let's find step by step every message process.

Now first we learn how to show simple MsgBox dialog.

First, we drag some jButton for every MsgBox. And will write code for it, then see what happen in every different jbutton's ActionPerformed event's process.

 (1). Show simple jOptionPane Msg dialog :
For showing this dialog, you have to simply import its class. Then call it in any component or run time process.
import javax.swing.JOptionPane; 
If there is only simple Msg dialog requirement, this is called plain MsgBox. We want to show it through butons’s click activity. So, type following code as we written.
private void MsgBtnActionPerformed(java.awt.event.ActionEvent evt) {
       JOptionPane.showMessageDialog(null, "Basic Plain Msg", "Plain MsgBox", JOptionPane.PLAIN_MESSAGE);
When you run it, it will show the following output.
Plain Message box in Netbeans
Plain Msg dialogbox
 (2). jOptionPane with Custom image icon dialog :
Suppose you have an image icon, which you want to show with containing message box, which indicate your application process. Then create an image icon and save it as .png or .jpg format and drag it to your package.
Suppose we have a file with name "msgicon.png" Message Icon in java . Then write code like:
private void ImgMsgBtnActionPerformed(java.awt.event.ActionEvent evt) { 
        BufferedImage imageicn1 = ImageIO.read(getClass().getResource("msgicon.png"));
        ImageIcon iconsk = new ImageIcon(imageicn1);
        JOptionPane.showConfirmDialog(null, "Custome Image Base Msg", "Msg with Image icon", JOptionPane.PLAIN_MESSAGE, 3, iconsk);
  }catch(Exception msex1){}
After that this code will present a custom icon base msg.
Custom Image base Message box in Netbeans
Custom Image Base Msg DialogBox

SQL Server Database Connectivity in Netbeans with Easy Tech Tips

 (3). jOptionPane with Yes No option with image dialog :
For saving or editing or some other action you need a MsgBox that show Yes/No option for that process. You have to add if else statement for it.

For clear description we add some jLabel and will see the output of Yes/No button press, which show in jLabel.

For more understanding purpose, just look at following code:
private void YesNoMsgBtnActionPerformed(java.awt.event.ActionEvent evt) {
   BufferedImage imageicn1 = ImageIO.read(getClass().getResource("msgicon.png"));
        ImageIcon iconsk = new ImageIcon(imageicn1);
  //Condition if you press “Yess” Button.
          if (JOptionPane.showConfirmDialog(null, "Sure for this process", "Ye No Option",  JOptionPane.YES_NO_OPTION,3, iconsk) == JOptionPane.YES_OPTION) {
    //Otherwise if you press “No” Button.
     else {
  }catch(Exception msgl){} 
And run-time this will show like:
YesNoOption Msg Box in Netbeans
Yes/No Msg Dialog
As you can see when pressing on “Yes” button, the result is showing in jLabel2 as “Yes” and pressing on “No” button, the result is showing in jLabel2 as “No”.

jList to Display data or Items in Java Swing

 (4). jOptionPane with error dialog :
If you want to show an error Msgbox, there is simple code for it.
private void ErrMsgBtnActionPerformed(java.awt.event.ActionEvent evt) { 
   JOptionPane.showMessageDialog(null, "Sorry Activity Fail", "Activity Fail Error" , JOptionPane.ERROR_MESSAGE);
Error Msg dialog in Netbeans
Error Dialog Box
 (5). jOptionPane with information dialog :
For successful saving, editing, deleting and listing information, you need to show the information MsgBox. Just change some code inside error dialog. And the Msg dialog will be change in information dialog.
private void InfoMsgBtnActionPerformed(java.awt.event.ActionEvent evt) {
JOptionPane.showMessageDialog(null, "Successfully Done Activity", "Activity Done Information" , JOptionPane.INFORMATION_MESSAGE);
information Message box in java
Information Dialog Box
So, there is some Types and Use of JOptionPane in Java Swing for Messages in NetBeans as described above with step by step process, just do same as SKOTechLearn Tips mention above.