Rohit Kumar

Ranch Hand
+ Follow
since Sep 20, 2007
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rohit Kumar


I am new to JSP.

I want to know, how to call javascript function which is present in say "one.jsp", from another jsp's (say "two.jsp") javascript function.

thanks in advance.
I am simply creating ImageWriter as,

(ImageWriter) ImageIO.getImageWritersBySuffix("png").next();

And then create ImageWriterParam as,


But it gives exception as "Compression not supported" on statement,

15 years ago
Is it possible to get format or mime type (eg. PNG or JPG) of a buffered image?
15 years ago

I have a jepg image. (39 KB size)
First I create a bufferedImage using
Then from the buffered image i create again jepg file (71 kb size).

why the size of new image is almost double? How to prevent it, and get back image with same size?

I simply used,

BufferedImage buffImg =; //create buffered imaeg from jepg file

ImageIO.write(buffImg, "jpg", newFile); //create jepg file from buffered image
15 years ago

I have a big string buffer, which has data in xml format.
I wann to change a particular small stings from the String buffer.
I don't think String's find/replace policy, or even xml parsing is good option here.

What would be best option in this senarieo?

15 years ago

I was preparing and planning to give SCDJWS 4. But now i have come to know that SCDJWS 5 is comming. (beta in jan 09 i guess).

I have sun certification voicher which is expiring in jan 09 end.

I am confused abt, should i give SCDJWS 4 or not. (Or to go for other sun exam.)

Is it possible to give SCDJWS 4 now and to go for only new topics from SCDJWS 5?

Please let me knwo your comments.

Thanks in advance.

I want a file chooser in html to choose a folder.
I tried with <input="file"...., but it only selects file(not folder).
Is there any way?

If not then, is there any way to add a java component say, JFileChooser in javascript.

Is it possible to get height and width of an image without loading it in memory?

15 years ago
I have a JPanel on which a JFileChooser is added.
Now the focus (cursor) is always set to TextBox, which contains the file we choose from file chooser.

Now the problem is, I have to capture a key on this panel.
But as the cursor always on the text box of JFileChooser, the key pressed event is not fired.
If i remove the JFileChooser, the keyPressed event is fired.

How to fire a keyPressed event when JFileChooser is there on the panel, and i press a key.

Is there any way to remove focus from the text box?
15 years ago
Well if check box from the dialog is not set, then there is no any connnection of key and dialog.

The key event comes into the picture only if the check box is already set.

If the check box is already set, then normal procedure is not to show the dialog and procede further.

But if check box is set, and user want to see the dialog, he can see by pressing a particular key.


a) if check box is not already set, dialog will always appear
b) if check box is set, dialog will not appear
c) if check box is set, and user still want to see dialog, he can get it by pressing a particular key.

So i am checking whether key is set or not as a condition before displaying dialog. But key event is fired after control comes to this key check condition.

So i was looking for new thread.
15 years ago
The senario is something like this.
User gets a dialog box, and if he selects check box, he will not get this dialog box further.

Now suppose he has already selected the check box (so will not get dialog box), but want to get dialog back, so he can get it back by pressing a particular key.

Now while if user already selected 'not to show dialog' while showing dialog i check whether the key is pressed or not(so dialog can be show again).
But this condition is cheked first and then keyPressed event is fired (if pressed key).

Certanly i can't do this condition checking in keyPressed.
So i thought of another thread.

Any clue?
15 years ago

I have a class which implements KeyListener and in keyPressed() chek whether a a particular key pressed or not?

In same class i have to take a decision on the basis of whether that particular key is pressed or not?

But i found that control comes to keyPressed() after the decision is taken.

I used sleep(), but still the control comes later at keyPRessed().

How to do it in differnt Thred, so that keyPressed() will execute first and then that decision?
15 years ago
Well i am creating array of pixels from image.
Now i want to create image back from that array of pixels.
I want to remove few pixels from it, so i can reduce the size of the image.

Actually i want to reduce either the size (disk size) of image or resolution (height and width) of image.

I used different ways to do it like compressionQuality etc.
But with different apis i foudn that when i just read image and save back the "disk size" of the resultant image is very less than source image.

any help on,
1) creating image from array of pixels (the resultant image shoud look same like original)

2) creating new image from an image with same disk size.
15 years ago
How to create image from array of pixels?

We can get pixels of an image from PixelGrabber.
Is there any API which does reverse?
Create an image from array of pixels?
15 years ago