Posts

How to take snapshot of screen in Java using NetBeansIDE

Image
How to take snapshot of screen in Java using NetBeansIDE. 1. Open NetBeansIDE. 2. Make a JFrame Form and design it. 3. RC on a button and Goto Events~action~actionPerformed 4. Write following code in it. Note: createScreenCapture(Rectangle rect) method is used to capture screen. It is the method of Robot class. try{ BufferedImage image=new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); ImageIO.write(image,"jpeg",new File(your path)); ImageIcon icon=new ImageIcon(image); jLabel1.setIcon(icon); }catch(Exception e) { e.printStackTrace(); } 5. Run your Project. 6. Finish. Thank You :) Facebook Page

How to get Image from Database(MySQL) in Java with NetBeansIDE.

Image
How to get Image from Database(MySQL) in Java with NetBeansIDE Note: Image is of Blob/LongBlob type in Database. 1. Open NetBeansIDE. 2. In your project make a JFrame form (say NewForm)    2.1 Add a button and a label(to display the image) in it. 3. Right Click on Button and Goto Events~action~actionPerformed    3.1 In actionPerformed method write code for connection.    3.2 Get the image in Byte array. 4. Import mysql connector jar file. 5. Run the JFrame Form file. 6. Finish. Thank You :) Facebook Page

How to insert Image in MySQL Database with Java in NetBeansIDE

Image
How to insert Image in MySQL Database with Java in NetBeansIDE. 1. Open NetBeansIDE 2. Make a new Java Application project. 3. Make a JFrame Form and Design it as in this project. 4. Right Click on 'Choose File' button and Goto events~action~actionPerformed 5. Make a table in your MySQL DB say 'Image' with one Image column of LongBlob type. 6. Enter the code in it(in actionPerformed for Choose File Button).    (Fix all imports)         JFileChooser fc=new JFileChooser();         fc.showOpenDialog(this);         File f=fc.getSelectedFile();         String path=f.getAbsolutePath();         jLabel1.setIcon(new ImageIcon(path));         try{                    ...

How to Perform DES Encryption and Decryption of TXT file in JAVA with NetBeansIDE

Image
1. Open NetBeansIDE. 2. Make a JFrame Form say EncryptTXT.java , I have already made it.               3. Make a class named DESEncrypt.java enter codes and Fix All Imports(It is necessary)     3.1 Write code in it            public static void encrypt(String key, InputStream is, OutputStream os) throws Exception {                                 encryptOrDecrypt(key, Cipher.ENCRYPT_MODE, is, os);                 }                 public static void decrypt(String key, InputStream is, O...

How to make a simple Login page using Servlet & Session in NetBeans IDE

Image
How to make a simple Login page using Servlet & Session in NetBeans IDE 1. Open NetBeans IDE 2. Make a new Project as:    2.1 File~NewProject~Java Web~WebApplication 3. Make a servlet(say First.java) as:    3.1 RightClick on Source Package~New~Other~Web~Servlet    3.2 Name your Servlet    3.3 Check Add Information to deployment descriptor(web.xml file) 4. Make another servlet(say Second.java). 5. Make an HTML file as:    5.1 RC on Web Pages folder and select New~Other~Web~HTML    5.2 Design a simple form in HTML    5.3 Give the url-pattern of First Servlet in the 'action' attribute(say '/First') 6. Write code for First.java to authenticate the user       6.1 In this servlet set the session attribute with a 'key' and its 'value'. 7. Write code for Second.java to view the profile    7.1 In this get the attribute of session. 8. Run the Project(let serve...

How to validate 'email' using Regular Expression in Java with NetBeansIDE

Image
How to validate 'email' using Regular Expression in Java with NetBeansIDE 1. Open NetBeansIDE 2. In your project Make a java form(e.g. JFrame Form)    2.1 Design this Form with one JTextField and a button in it. 3. Make Validate.java class        3.1 In this class make a static method with code:        public static boolean validateEmail(String email) {                                                boolean status=false;           String EMAIL_PATTERN =         "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"         + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";     ...

How to use Properties File in JAVA

  How to use Properties files of JAVA in NetBeansIDE 1. Open NetBeansIDE. 2. In your project,         2.1 right click on package(any package)     2.2 choose>new>others>others>properties file 3. In properties file, write the 'key' and its 'value'    as     (key)=(value)     (key)=(value)     ..... 4. To access the properties file, make a new java class file and write your code(in video)... 5. Run the file. 6. Finish.   Thank You Click here to visit my facebook page for more videos