Hi Priya, When in the Java language a variable is declared 'final', it cannot be changed after initialisation. When a final variable is initialised and you attempt to assign it a new value, this will generate a compile error. Final variables are similar to constants in other programming languages. In your example it means that the JLabel label can not be changed. It can not be assigned another JLabel object, nor can it's caption be changed. Hope this helped, Tim [ May 05, 2003: Message edited by: Tim B. ]
hi Priya final JLabel label = new JLabel("Hello world"); It means that the reference of the label as a final reference,the reference of label points to something once when it declares.It can not make any changing of pointer which point to the other thing.If you do it,the compiler error occurs Lets consider the case case 1 give you compiler error case 1: final JLabel jlabel=new JLabel(); jlabel=new JLabel("Hello"); case 2 compile fine case 2 JLabel tlabel=new JLabel("Hello"); tlabel= new JLabel(""); If it is not clear,please post again
[ May 05, 2003: Message edited by: siu chung man ]
Tim B, welcome to JavaRanch, and thanks for helping out by responding to the questions placed in the forums. However, there is a problem with your displayed name. Please change it to conform with JavaRanch's Naming Policy. An initial letter with a last name are OK, but not a first name with a letter for the last name. Thanks in advance. -Barry [ May 05, 2003: Message edited by: Barry Gaunt ]
Thanks guys. I have another doubt. How do I put a text area under a text field in a swing GUI. Will the code be different from the one where I put a text area to the side of a text field? How do we determine the position of the text field and text area relative to each other?