Skip to content

Tag: java

Call itemStateChanged() only after user interaction

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

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…

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 …

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…