I’m trying to make an app for create custom cards. I’d like to add some text over a custom background (a jpg image). What is the best way of doing it? I’d need to show the user a preview of the card before send it to the server. Thanks Answer Use below code to achieve your requirement You ha…
Tag: java
Cast Double to Integer in Java
Any way to cast java.lang.Double to java.lang.Integer? It throws an exception “java.lang.ClassCastException: java.lang.Double incompatible with java.lang.Integer” Answer A Double is not an Integer, so the cast won’t work. Note the difference between the Double class and the double primitive.…
Unix grep for Java logs
I am new to Unix grep and i would like some help to come up with a grep command. Currently, i have the following types of error in my application logs: 2012-02-31 10:21:41,333 ERROR [65] (GeneralAppliancesBean.java:135) – Exception java.net.ConnectException: Connection timed out 2012-01-31 10:24:41,843 …
Lucene: Multi-word phrases as search terms
I’m trying to make a searchable phone/local business directory using Apache Lucene. I have fields for street name, business name, phone number etc. The problem that I’m having is that when I try to search by street where the street name has multiple words (e.g. ‘the crescent’), no resu…
How to change background color of JOptionPane?
I have added JOptionPane to my application but I do not know how to change background color to white? Answer By using the UIManager class or
data from sqlite into ArrayList
i am using code this blog to have a draggable list. This tutorial is using a custom DragNDropAdapter that takes the content as an ArrayList. In my listActivity i query a table with returned column name.It has 11 values inserted. i tried to convert it to ArrayList from String[] with many ways such as : or what…
Regex to match words of a certain length
I would like to know the regex to match words such that the words have a maximum length. for eg, if a word is of maximum 10 characters in length, I would like the regex to match, but if the length exceeds 10, then the regex should not match. I tried but that brings me matches only if the minimum
What sort of configuration issues or problems might make Maven Assembly plugin go slowly?
Our multi-module Maven project used to take 4-6 minutes to build. Over the past few months, it has increased to 20+ minutes per build. One symptom is that sometimes the build appears to pause until I hit <enter>. However, the Maven build still runs fine (6 minutes, no pauses) on our build server. The bu…
Does using an Iterator over a TreeMap in Java interfere with the order of keys?
I want to know that if using an Iterator over a TreeMap in Java interfere with the order of keys? Answer From http://docs.oracle.com/javase/6/docs/api/java/util/TreeMap.html#keySet() : Returns a Set view of the keys contained in this map. The set’s iterator returns the keys in ascending order. If for so…
Convert LocalDate to LocalDateTime or java.sql.Timestamp
I am using JodaTime 1.6.2. I have a LocalDate that I need to convert to either a (Joda) LocalDateTime, or a java.sqlTimestamp for ormapping. The reason for this is I have figured out how to convert between a LocalDateTime and a java.sql.Timestamp: So, if I can just convert between LocalDate and LocalDateTime,…