Sunday, August 01, 2010

Posts Tagged ‘HQ Library’

Membatasi Jumlah Karakter pada JTextField

Sekali-sekali posting tutorial Java pake Bahasa Indonesia

Kadangkala, dalam membuat suatu program yang mengharuskan user mengisi suatu textfield, kita perlu membatasi jumlah karakter yang diketikkan. Dalam Java, class JTextField biasa tidak didesain untuk secara otomatis melakukannya. Coba saja Anda ketikkan satu juta karakter di sana, pasti masih bisa terpampang di layar. Nah, coba bayangkan kalau yang harus diinputkan adalah field kode barang, atau nomor telepon, atau apapun yang memiliki batas panjang. Tentu akan merepotkan kalau di program harus mengecek itu.

Untuk itu lebih mudah jika kita membatasi jumlah karakter yang bisa diinputkan dalam JTextField. Salah satu gunanya adalah saat field yang Anda perlukan itu harus disimpan dalam kolom database yang memiliki lebar karakter terbatas. Dalam HQLibrary, saya juga berencana membuat utility yang menangani hal simpel ini. Yah, meskipun ini sebenarnya hal sederhana, rasanya tetap perlu dimasukkan untuk mempermudah nantinya.


Java Tutorial – Create Icon Reflection

Just a simple Swing make over

Recently, I just wrote posts about my own world. For now, I will write about another Java Tutorial. Still in the progress of HQLibrary that is suspended, this is another simple class in my library. From the image you can see beside, you will understand that I will show you how to make a label that automatically create a reflection if we add an icon. More over, this class can be used in NetBeans GUI form, so you can add an icon using the parameter panel.

Before we go to create an extended class of JLabel, first we need to know how to automatically create a reflection of an image. Using Java 2D API, we can easily finish that problem. Those useful class packaged in java.awt package. We need to do simple 2D manipulation to create a new image that has reflection. So, I created some methods in another class (not in extended JLabel), with static modifier, so that it can be used by another class. I wrapped that methods in a class named HQIconUtil.


Java Tutorial – Wrap Text into JLabel

Another Java tutorial, hope it will be useful.

Again, this post is from my previous blog post

Coding in Java is my hobby. So I am happy when my subject is about programming in Java. Although I’m still not a great Java programmer, I want to share this tutorial. It is about how to wrap text in to JLabel, so that whenever the text reach the right side of JLabel, it will go to the next line. Sometimes we will face this condition. For example, when we want to create a bunch of information text such as dialog box that display “about” information. We have very long text to display, but if we place it in a JLabel with ordinary process, it will grow horizontally until the end of the text, and never go to the next line.


Java Tutorial – Write and Read File

Repost from my previous blog, about Java tutorial.

This post is similar with my post before

Inspired by Eko with his USU Library, now I am creating my own Java library. Of course, I will make it open source, as soon as I think it is finished with version 1.0. Hope that I will focus in this project. I think you who are a programmer should make your own library too. Because it will be useful whenever you get a project, and it will be your trademark. You know, although you decide that your library will become open source, the real author is you. So the only one who know most of your program is YOU. Don’t afraid to be open source.


 

My Tweets

Banners

Tag Cloud

Get Adobe Flash playerPlugin by wpburn.com wordpress themes