In this tutorial you will learn about the Java IDE and its application with practical example.
Java IDE
IDE(Integrated Development Environment ) did our work easy. Till now we were using notepad to write our program and then we used to compile on command line, but now we do not need to do hard work .We will learn here that how to use IDE and make Desktop Application. Here I have used Netbeans IDE for creation of Swing project. Follow below steps for making our first Desktop application. If you do not have NetBeans so please download it from “” this link.
1st Step: After successful installation of Netbeans , click on File option which is on top left corner in IDE. Like below image.
Step 2nd : Click on New Project and you will get screen like below image.
Step 3rd : Click on “Java” and then select “Java Application” and then click on next you will next sceen like below image.
Finally click on Finish option and you are set with your first application. Few steps are remaining for creation and need some coding also. Checkout below steps for it.
Step 4th : Right click on Project and then go to “New” and create your first JFrame. Like below images. Fill details about your JFrame and click on “Finish” .
Step 5th : So now we do not want to do coding for our design part. You can directly drag and drop whatever you want to add on Frame, it will appear on Frame. Checkout below images .
So it is simple design of login form.
Step 6th: In this step you will see that how we can directly use On click Action of button. Check below image .
Step 7th: In this step we will see that how can we move from one frame to another frame. I have already created one more frame using same steps. Please you too create. On Click of button we will move this frame to another frame checkout below code for it. And use it in your code. I have also used JOptionPane here which is used to show alert message. You can try it by entering wrong username and password.
1 2 3 4 5 6 7 8 9 10 |
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String str_username=et_username.getText().toString(); String str_password=et_password.getText().toString(); if(str_username.equals("w3adda") && str_password.equals("1234")){ HomeFrame home=new HomeFrame(); home.setVisible(true); this.dispose(); //used to dismiss current frame. } else{ JOptionPane.showMessageDialog(null, "Incorrect Username or Password", "W3Adda.com", JOptionPane.PLAIN_MESSAGE); } } |
// on click of Login Button Welcome frame will be disposed and Home Frame will appear.
// Below Alert will appear when you entered wrong “Username” Or “Password”.
So this was an example of our first application, In Next Article we will learn about connection with database and Building Jar file. I hope this will help you to understand basic of Java Application with IDE.