cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Praveen_Durbha
Level 6

Disabling Text Field when a Radio Button is Selected

I am trying to disable a text field when a radio button is selected. The selection of the radio button triggers the following event.

The following code doesn't disable the text field(proxy_server)

public void checkedproxy_server_no com.installshield.event.ui.ISControlContext arg0)
{
try{

ISFrame frame = ((SwingPanel)arg0.getISContainer()).getISFrame();
ISTextField field1 = frame.getTextField("proxy_server");
field1.setEnabled(false);


}catch(Exception ex){

arg0.getServices().logEvent(this, Log.ERROR, "Caught an exception........");
}

}

I am unable to figure out how to get a handle on the proxy_server in the event above, so I can just disable it by using setEnabled(false).

Any ideas?
Labels (1)
0 Kudos
(6) Replies
jweber
Level 6

Heres a snippet i use:

    
public void checkeddb_rb_existing_provider(com.installshield.event.ui.ISControlContext arg0)
{
ISTextField dsHelperTF = (ISTextField)arg0.getISContainer().getControl("db_tf_datasource_helper");
dsHelperTF.setEnabled(false);
dsHelperTF.setBackgroundColor(new Color(192,192,192));

setProviderConfig("existing", arg0);

}
0 Kudos
Praveen_Durbha
Level 6

This code doesn't work. I did't see a getISControl(String textFieldvariableName) when I did a . on getISContainer(). I used the getISHtmlControl() instead, as below.

public void checkedproxy_server_no(com.installshield.event.ui.ISControlContext arg0)
{
ISTextField prxysrvr = (ISTextField)arg0.getISContainer().getISHtmlControl("proxy_server");
prxysrvr.setEnabled(false);
prxysrvr.setBackgroundColor(new Color(192,192,192));

//setProviderConfig("existing",arg0);

}

When I stepped through the code, the execution came to a halt on Line 2 prxysrvr.setEnabled(false)

I also commented out setProviderConfig, as it was throwing compiler errors.

I am not sure what to do next..

Thanks
0 Kudos
jweber
Level 6

Dont know man... This code does work, and has for a long time now. Dont know if you made a typo or what but it isnt getISControl(), its getControl()...


ISTextField prxysrvr = (ISTextField)arg0.getISContainer().getISHtmlControl("proxy_server");

probably wont work because your trying to cast an ISHtmlControl to a ISTextfield. You should wrap everything in a try/catch and print out the exception...
0 Kudos
Praveen_Durbha
Level 6

Ok..I changed the code but the problem remains. Here is my updated code.

A NullPointerException is being thrown on line 2. Looks like "prxysrvr" is not getting initialized on Line 1 to some value before i do a . on it on Line 2.

try{
ISTextField prxysrvr = (ISTextField)arg0.getISContainer().getControl("proxy_server");
prxysrvr.setEnabled(false);
prxysrvr.setBackgroundColor(new Color(192,192,192));
}catch(Exception ex){
System.out.println(ex.getMessage());
ex.printStackTrace();
}

Here is the complete trace:

null
java.lang.NullPointerException
at com.installshield.insite_2_0.event.dialog.swing.Panelinsite2_proxy_server.checkedproxy_server_no(Panelinsite2_proxy_server.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.installshield.event.ActionSequenceEngine$ActionTask.invokeJavaMethod(Unknown Source)
at com.installshield.event.ActionSequenceEngine$ActionTask.executeAction(Unknown Source)
at com.installshield.event.ActionSequenceEngine$ActionTask.run(Unknown Source)
at com.installshield.event.ThreadPool.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
0 Kudos
jweber
Level 6

In my experience that means that the current panel does not have a field by that name ("proxy_server"). Check your panel and make sure that the control is named accordingly. Im a previous post you said your method was

proxy_server_no


seems like that should be the name you would use:


ISTextField prxysrvr = (ISTextField)arg0.getISContainer().getControl("proxy_server_no");
0 Kudos
Praveen_Durbha
Level 6

Here is the right code.

try{
ISTextField proxy_server = arg0.getISContainer().getTextField("ISTextFieldDef2");
proxy_server.setEnabled(false);
proxy_server.setBackgroundColor(new Color(192,192,192));

}catch(Exception ex){
System.out.println(ex.getMessage());
ex.printStackTrace();
}
0 Kudos