in my swing application I have a combo box with an ItemListener that does X if the user changes the value (via itemStateChanged()). However I also have a different function that changes the value of that combo box. In this case I do not want X to be done. Is there a way to find out if the state change
Tag: java
Use variables in pattern matcher
I have the following: But would like to replace the {6,20} with variable values due to them been dynamic in some cases. I.e. How can I include variables in the Reg Exp? Thanks Answer Use Java’s simple string concatenation, using the plus sign. Indeed, as Michael suggested compiling it is better for perf…
Negate unary operator in Hibernate QL
I’m trying to switch boolean field using the following hql: Unfortunately “QuerySyntaxException: unexpected token: not near…” was thrown. My question is: is there some unary operator for hibernate that supports such expression? Or any well known trick? sql supports such queries (postgr…
soap communication using Java socket works, but switching over to java soapconnection does not
I recently asked a question about building a SOAP message using the java provided soap library Changing default soap URI, so that question may end up bleeding into this one a bit depending on what the answer to the last one may be (and in fact, the answer to this question may mean that I don’t have to w…
java get week of year for given a date
how can I get a week of the year given a date? I tried the following code: and i obtain: sDateCalendar lun apr 23 11:58:39 CEST 2012 iStartWeek 2012 3 while the correct week of year is 17. Can someone help me ? Answer You are using sDateCalendar.WEEK_OF_YEAR, which is the static integer WEEK_OF_YEAR, see the …
Format a BigDecimal as String with max 2 decimal digits, removing 0 on decimal part
I have a BigDecimal number and i consider only 2 decimal places of it so i truncate it using: Now I want to print it as String but removing the decimal part if it is 0, for example: 1.00 -> 1 1.50 -> 1.5 1.99 -> 1.99 I tried using a Formatter, formatter.format but i always get the 2 decimal
Getting error while trying to create HttpsURLConnection through proxy
I am getting this error when I am try to make url connection through proxy It produce error while opening connection and if I am trying with out proxy its working fine. Please see the java code described bellow Answer I think there is no need of code change. This means proxy server is not able to tunnel you m…
Canonical equivalence in Pattern
I am referring to the test harness listed here http://docs.oracle.com/javase/tutorial/essential/regex/test_harness.html The only change I made to the class is that the pattern is created as below: As the tutorial at http://docs.oracle.com/javase/tutorial/essential/regex/pattern.html suggests I put in the patt…
How to traverse an order list of node properties in neo4j?
I’m new to neo4j , so your help is appreciated. I have a neo4j database with nodes that have a property “Color” and two relationship types, “Previous” and “Next”. I have …
Check if a String is in an ArrayList of Strings
How can I check if a String is there in the List? I want to assign 1 to temp if there is a result, 2 otherwise. My current code is: Answer