You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Zulfi Khan <zu...@yahoo.com.INVALID> on 2021/11/12 04:24:44 UTC

JTextField and JButton variables can't use setEnabled(false) methods

Hi,I am working on Apache NetBeans 12.5.
 
I have createdJbutton and JTextField controls and changed their default variable names to:




privatejavax.swing.JButton btnCalInterest;

privatejavax.swing.JTextField cNumTF;




public classRButtArrListJFrame extends javax.swing.JFrame {

 :

 :

 btnCalInterest.setEnabled(false);

 cNumTF.setEnabled(false);


I am getting following error messages:
<identifier> expected 

illegal start of types
package CNumTF does not exist
Surround with ....


I have attached the images of variable names and error messages.
Somebody please guide me.

Zulfi.

Re: JTextField and JButton variables can't use setEnabled(false) methods

Posted by Scott Palmer <sw...@gmail.com>.
Or put it in an initialization block by surrounding the code with { }

Scott

> On Nov 12, 2021, at 5:00 AM, Pieter van den Hombergh <pi...@gmail.com> wrote:
> 
> 
> you are calling a method in the class body, but there you can only do declarations (of fields and methods). To do this kind of call you must be inside a method. Move the call to setEnabled(...)to inside a method or into the constructor. The most appropriate method for this might be something init() like.
> 
> Op vr 12 nov. 2021 05:25 schreef Zulfi Khan <zu...@yahoo.com.invalid>:
>> Hi,
>> I am working on Apache NetBeans 12.5.
>> I have created Jbutton and JTextField controls and changed their default variable names to:
>> 
>> private javax.swing.JButton btnCalInterest;
>> private javax.swing.JTextField cNumTF;
>> 
>> public class RButtArrListJFrame extends javax.swing.JFrame {
>> :
>> :
>> btnCalInterest.setEnabled(false);
>> cNumTF.setEnabled(false);
>> 
>> 
>> I am getting following error messages:
>> 
>> <identifier> expected 
>> 
>> illegal start of types
>> 
>> package CNumTF does not exist
>> 
>> Surround with ....
>> 
>> 
>> 
>> I have attached the images of variable names and error messages.
>> 
>> Somebody please guide me.
>> 
>> Zulfi.
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
>> For additional commands, e-mail: users-help@netbeans.apache.org
>> 
>> For further information about the NetBeans mailing lists, visit:
>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Re: JTextField and JButton variables can't use setEnabled(false) methods

Posted by Pieter van den Hombergh <pi...@gmail.com>.
you are calling a method in the class body, but there you can only do
declarations (of fields and methods). To do this kind of call you must be
inside a method. Move the call to setEnabled(...)to inside a method or into
the constructor. The most appropriate method for this might be something
init() like.

Op vr 12 nov. 2021 05:25 schreef Zulfi Khan <zu...@yahoo.com.invalid>:

> Hi,
> I am working on Apache Net*Beans 12.5.*
>
> I have created Jbutton and JTextField controls and changed their default
> variable names to:
>
>
> private javax.swing.JButton btnCalInterest;
>
> private javax.swing.JTextField cNumTF;
>
>
> public class RButtArrListJFrame extends javax.swing.JFrame {
>
> :
>
> :
>
> btnCalInterest.setEnabled(false);
>
> cNumTF.setEnabled(false);
>
>
> I am getting following error messages:
>
> <identifier> expected
>
> illegal start of types
>
> package CNumTF does not exist
>
> Surround with ....
>
>
>
> I have attached the images of variable names and error messages.
>
> Somebody please guide me.
>
> Zulfi.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
> For additional commands, e-mail: users-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists