These tips all depend on using Eclipse.
Start with all the ClickListeners and do them all at once. Use Eclipse "Java Search": Search String = ClickListener, Search For = Type, Limit To = References.
For simple click situations, copy these lines:
.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event)
{
and paste them in to replace every instance of
.addClickListener(new ClickListener() {
public void onClick(Widget sender)
{
Here's an extra tip: Instead of pasting the above code from here, paste it once into one of your classes. Once you get it valid there, copy that and paste it in to replace all your listeners. When you copy and paste this way, eclipse automatically pulls in the imports for you as well.
If the sender parameter had been used, replace references to it with event.getSource(). You will probably have to cast it.
For other situations, make heavy use of auto-complete (CTRL-SPACE). For example
myObject.addCl<CTRL-SPACE><ENTER> -> myObject.addClickHandler()
myObject.addClickHandler(new <CTRL-SPACE><ENTER>) -> myObject.addClickHandler(new ClickHander)
myObject.addClickHandler(new ClickHander() {<ENTER>) ->
myObject.addClickHandler(new ClickHander() {
})
myObject.addClickHandler(new ClickHander() {
<CTRL-SPACE><ENTER>
})
->
myObject.addClickHandler(new ClickHander() {
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
}
})
Final tip: Put your cursor at the end of a listener class name (ex: new ClickListener|()) and press <CTRL-SPACE>. This will bring up the class along with other suggestions in a list. But it will also show the Java Doc for that class, which will tell you what handler(s) you should use instead. The same works for methods like addClickListener().
As an Amazon Associate I earn from qualifying purchases.
My favorite quotations..
“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.” by Robert A. Heinlein
"We are but habits and memories we chose to carry along." ~ Uki D. Lucas
Recommended pages
Popular Recent Articles
-
O'REILLY 201 0011 031 10110100180 000110111 01100041 001100010010000 5011011001010 1101110011 000100000 00000 10 1000012 Escaping the Bu...
-
I have noticed a very unsettling statistic on my blog. This prompted a fascinating question about AI, blogs' future, and maybe even the...
-
We went with my cousin, Igor, family to a hibachi restaurant. It was a great fun for both kids as well as adults. As an anthropology nerd I...
-
First day of Lincoln Technical Institute school last night. Nothing exciting at all, just a very long 6 hours. I hope to get by those boring...
-
Last night, as a fitting conclusion to our family trip to Maui , I re-watched Moana , probably my favorite movie of the kids’ genre. I can ...
-
"Ariowie Słowianie Polacy" by Mariusz Kowalski is a book that delves into the controversial and debated topic of the ethnic and cu...
-
Subclade R1b1b2a1a1d1* (23andMe.com nomenclature) or R1b1a2a1a1a4 (FTDNA nomenclature) is a men linage descended from the region that wa...
-
https://arxiv.org/abs/2402.14531#:~:text=This%20phenomenon%20suggests%20that%20LLMs,language%20processing%20and%20LLM%20usage
-
for(int i = 0; i { loopName: for(Organization org: organizations) { if(org.getId() .equals( new Long("5"))) ...
-
Our gut microbiom might one of the most important precursors of our good health. Our digestion and ability to extract microelements from fo...