Posts

Showing posts from May, 2013

How to Open only one JFrame form instance at a time in JAVA using NetBeansIDE

Image
How to Open only one JFrame form instance at a time in JAVA using NetBeansIDE Suppose I want to open JFrame2 after clicking on JFrame1 JButton 1. Open NetBeansIDE 2. Create a JFrame1 and JFrame2 forms in a project 3. Create a JButton in JFrame1 4. Add this Code for JButton Actions>ActionPerformed: JFrame2.getObj().setVisible(true); 5. Add this code in JFrame2 class: private static JFrame2 obj=null; 6. Change the default constructor access modifier to private 7. Make a public static method and write code below in it: public static JFrame2 getObj(){         if(obj==null){             obj=new JFrame2();         }return obj;     } 8. Run the JFrame1 class 9. only one instance of form will be displayed at a time. this is also called Singleton Design Pattern 10. Finish Thank You Like My Facebook Page for more video updates: https://www.facebook.com/pages/Raks/335960303097841

How to Open a Text File with Notepad using JAVA in NetBeans

Image
Here I used Runtime class and Process class to execute the command for opening notepad 1. Create a main class. 2. Enter code in main method { Runtime rt=Runtime.getRuntime(); String file="path of your file"; Process p=load.exec("notepad "+file);              // a space is required after notepad 3. Run the File. 4. Finish Like My Facebook Page for more video updates: https://www.facebook.com/pages/Raks/335960303097841