I was wondering how it is possible to highlight a phrase and use some hotkeys for example "ctrl+1" in java to search that phrase by google?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I was wondering how it is possible to highlight a phrase and use some hotkeys for example "ctrl+1" in java to search that phrase by google?
Check out Desktop#browse(URI)
You will need to build up a suitable URI from the selected phrase in the form that Google expects, something likewhere word1, word2 ... are split from the search phrase."http://www.google.com/search?q=" + word1 + "+" + word2 ...
You may need to convert special characters into their HTML entities (not sure about that).
db
thx, but how should I recognize google language.
URLEncoder (Java Platform SE 6)
nasi, you may wish to review google's terms of use to make sure what you want to accomplish doesn't violate it. There are other tiny issues you may have with doing what I think you wish to do, such as parsing/displaying the html output as well as receiving correct output from google (in my experience is wasn't as simple as D.B.'s suggestion - one suggestion: if accessing via a URLConnection make sure you set the user-agent request property, for example to Mozilla)
I have checked their guidelines, I am not going to send lots of queries simultaniously.
Sorry Copeg, but I don't know how to set user-agent request property. I can not find any method regarding it in URLConnection class
Thanks Copeg, done.
in java , i have no idea
but in a diffrent programming language i know a really
easy way to do that
if ur on a windows machine check out autohotkey
i've used it for all kinds of small things , including
doing some tedious homework and a little thing
that types in what i need in the cmd to compile classes
Programming: the art that fights back