Skip to content

Negative Number in fillRect()

I am using a negative number to have fillRect() go the opposite way. It works well on my computer, but my friends cannot see it working properly. What do I do? Answer My guess is that you and your freind are using 2 different versions of Java. your supports fillrect with a negative value and your freind&#8217…

How to start Activity in adapter?

I have a ListActivity with my customized adapter and inside each of the view, it may have some buttons, in which I need to implement OnClickListener. I need to implement the OnClickListener in the adapter. However, I don’t know how to call the function like startActivity() or setResult(). Since the adap…

Comparing XML in java

Here are two XMLs , I am trying to compare and put the respective data in excel sheet. I have a multidimensional array called provisions. AND Now this XML data is for 2 plans and my provisions array contains provisions == [[Plan Features,,][Deductible,,][Individual,,]…..] This is what I have done The pr…

Editing PDF text using Java

Is there a way I can edit a PDF from Java? I have a PDF document which contains placeholders for text that I need to be replaced using Java, but all the libraries that I saw created PDF from scratch and small editing functionality. Is there anyway I can edit a PDF or is this impossible? Answer You can do

Convert RGB values to color name

How can I convert a color in RGB format into a color name? Examples: (0, 0, 255) -> “blue” (255, 0, 0) -> “red” (128, 128, 128) -> “grey” Answer Populate a list of “known” colors. For each known color compute: Return the name of colorI for which rgbDist…

Remove all empty lines

I thought that wasn’t that hard to do, but I want to remove all empty lines (or lines just containing blanks and tabs in Java) with String.replaceAll. My regex looks like this: But it doesn’t work. I looked around, but only found regexes for removing empty lines without blanks or tabs. Answer Try …