How to set JTable Titile with Sinhala Unicode value

This is regarding request of chathura and today i am going to add Unicode based title to JTable. First create a new project using NetBeans and add a new form to project. Then add a new table to JFrame and edit the default table headers with Unicode values.

RC on JTable -> Properties -> Go to Model -> and add your new table headers to there.

Add a new Class called MyFont and i use that class to set fonts to my application

Go to your Main method and add this code inside main method.

MyFont.setUIFont(new javax.swing.plaf.FontUIResource("Iskoola pota",Font.PLAIN,18));

Compile and Run your project and see the output.

To Download the full NetBeans Project click on the below button

Download

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.

How to change Tooltips font in java / customize java Tooltips

Welcome again. Now i have different code for customize the  Tool tips in java programs. You can see i changed default tool tip font in to my own native language. It shows based on my Unicode language. I will show you how change this is.

String html =
            "<html><p><font color=\"#000\" " +
            "size=\"5\" face=\"Iskoola pota\">ආයුබෝවන් මෙම පනිවිඩය ඔබට සින්හලෙන් දිස්වන්නේ<br /> මෙම ජාවා වැඩසටහන සින්හල වැඩසටහනක්<br /> ලෙස සකසා ඇති නිසාය.." +
            "</font></p></html>";

        jButton1.setToolTipText(html);

See i told you this is easy. OK i have set tool tips for my jButton1 using my native language. You want to call this inside your constructors. I think you got it know. If not see code

public class joption extends javax.swing.JFrame {

    /** Creates new form joption */
    public joption() {
        initComponents();
        String html =
            "<html><p><font color=\"#000\" " +
            "size=\"5\" face=\"Iskoola pota\">ආයුබෝවන් මෙම පනිවිඩය ඔබට සින්හලෙන් දිස්වන්නේ<br /> මෙම ජාවා වැඩසටහන සින්හල වැඩසටහනක්<br /> ලෙස සකසා ඇති නිසාය.." +
            "</font></p></html>";

        jButton1.setToolTipText(html);

    }

I am using Netbeans as my IDE for develop java. If you have any problem please comment on this. Hope this was helpful to you friends.

how to set unicode(sinhala) font to JoptionPane in java / customize JoptionPane

Hi all now i am going to say you how to customize the JoptionPane in java. In here i  added Unicode type font to my message. Now we will see how to do it. Below you can see how you can customize your code for Unicode font..

String html =
            "<html><p><font color=\"#000\" " +
            "size=\"5\" face=\"Iskoola pota\">ආයුබෝවන් මෙම පනිවිඩය ඔබට සින්හලෙන් දිස්වන්නේ<br /> මෙම ජාවා වැඩසටහන සින්හල වැඩසටහනක්<br /> ලෙස සකසා ඇති නිසාය.." +
            "</font></p></html>";

        JOptionPane.showMessageDialog(null, html,"තොරතුරු පනිවිඩය",JOptionPane.INFORMATION_MESSAGE);

How nice it has changed know.. OK friends we will see in next post..