This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hello, I'am learning java and i would like to know how to write code for a jtable column and also for a Jtextfield in order to have this format: "DD/MM/YYYY". If you have code examples , it would be great. Thanks Tina
Joined: Sep 23, 2002
I forget to say that i'm using visualage for java4 (jdk1.3) thanks Tina
In JTable, there are two components used in every column. 1. Renderer :
Renderer is responsible for rendering the data and display it in the table. Default renderer extends from JLabel, You can write your own custom renderer to format data to whatever format you want it to be displayed. But, the underlying data is not changed. 2. Editor: Editors are kind of wrapper around the actual editing component. Components can be anything extends from JComponent. Default editor is JTextField. You can create your own custom editor for your editing needs. If you edit the value in a cell and move focus to next cell/row, the value will be updated in the Model by the Editor. (I am just telling this because you said you are new. If you already know it, please ignore it) Ok.. here is the code for CustomDateCellRenderer
CustomDateEditor is little bit hard. If you like to have a it as a mask field, you have to write lots of code.. I can give you a skeleton only.
[ October 25, 2002: Message edited by: Sankar Subbiah ]
Joined: Jul 06, 2001
Is there any tag for code?? Added later : Found it.. [ October 25, 2002: Message edited by: Sankar Subbiah ]