It sounds like that button is in a web page. Is that correct? And the variable: where is that located? Is it a Javascript variable on the web page, or is it in some kind of server component?
And when you say you want to check "in Java", does that mean you want to write an
applet to check the variable, or does it really mean that you want to check in Javascript? Or if the variable was in a server component, was that component written in Java or some other language?