How to add uniocde to JOptionPane.showInputDialog in java – Uniocde example

This slideshow requires JavaScript.

In this example i will show create Unicode based Input dialog to your application.In here you can see lot of information’s about Unicode based java applications.First of all i had to define Unicode font for my input dialog.Because when i type Sinhala text in my text box which i used to get name from user it showed me only boxes.But after i set default font my application it has solved.See the code

Read More »

Simple date picker for Java Applications – ( Best Java UI Development )

This slideshow requires JavaScript.


In this application you can learn how to add a simple date picker for your java swing application.I wanted this for one of my project and i enhanced GUI by using look and feel theme and some images.I believe that you will like to this simple but attractive implementation.You can add this functionality for your application and thank for Rose India web site for develop this class.

I created this application by using Netbeans IDE 6.9 and you can open this project after download from below link and customize it with your requirements.

Download

Source (http://www.roseindia.net/tutorial/java/swing/datePicker.html)

How to insert Unicode values to MySQL using Java-Part 3

This is the last part of our Unicode based project and in this project we will see how to retrieve our inserted values from MySQL table to our GUI.

You can see  i have a button and  one combo box retrieve data and display it.Once i click my button it will go to database and get values to array list and fill my combo box. See the below code i did that.

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        ArrayList names = new ArrayList();

        try
        {
            conn=getcon.creatConnection();//getting connection

            //execute query

             ResultSet rs = conn.createStatement().executeQuery("select name from unicode");

             while (rs.next())
             {

                 String Cusname = rs.getString("name");
                 names.add(Cusname);

            }

             rs.close();
             DefaultComboBoxModel model = new DefaultComboBoxModel(names.toArray());
             cmboUnicode.setModel(model);

        }
        catch(Exception ex)
        {
            JOptionPane.showMessageDialog(rootPane, ex);
        }

    }

same as my previous post i have to create the object top of my class like this.

connection getcon = new connection();
Connection conn;

This method will called once i click the find button.These things normal than any other program.But you must concert clearly about my connection class. Here important things of the program are

Connection class , Use general Unicode font, Use java latest version, Handle exception while you are testing or develop it

Below you can download my complete project and if you have any problem comment on me.Thank you and best of luck

Download this video
Download Project

How to insert Unicode values to MySQL using Java-Part 2

This is the second part of my How to insert Unicode values to MySQL using Java tutorial and in this tutorial you will see how to insert Unicode format value to your MySQL table.Now we already have created a database,table and also nice GUI to communicate with our back end database. You can see below picture and that is the UI i use to insert and retrieve values from the MySQL table

In my GUI i have two text-boxes to insert values. I have assigned a variable to each and those are txtname and txtjob. See the below code how did i used to get values from text boxes and inserted into my table.

 private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
//connection getcon = new connection();
//Connection conn; 

// you can also create object like above my code.But you have to crate again and again if you have several functions in your program.
        try{

         getcon.creatConnection().createStatement().executeUpdate("insert into unicode(name,job) values ('" + txtname.getText() + "','"+ txtjob.getText()+"')");

          JOptionPane.showMessageDialog(null, "Done") ;

         txtname.setText(null);
         txtjob.setText(null);

         txtname.requestFocus();
      }
      catch(Exception ex){

         JOptionPane.showMessageDialog(null,"Cannot insert data."+ ex.getMessage(), "Contact Editor",JOptionPane.ERROR_MESSAGE, null);//exeption hanling

      }

        // TODO add your handling code here:
    }

In my class i have created a new object top of my class and based on that i can access my connection class.

connection getcon = new connection();
Connection conn;

you can also create object like above my code.But you have to crate again and again if you have several functions in your program.After you download your complete project at the end of this tutorial you can see clearly and understand the full code.I used

JOptionPane.showMessageDialog

to display my successful message to user.

In next tutorials we will see how to retrieve data and display to simple combo box.