Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 622801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:01:25+00:00 2026-05-13T19:01:25+00:00

i’ve started on some basic java coding with gwt, and im getting a bit

  • 0

i’ve started on some basic java coding with gwt, and im getting a bit concerned about the heft of my main class.

For instance – how does one compartmentalize the keyhandlers, since they trigger a number of changes to the UI, how could i move this into a separate .class file and still be able to access all the various widgets in the main class, without having to pass everything to the handler (ie. all the widgets i manipulate after the click event).

i’ve googled but didnt come across any particularly good examples – know of any readily legible code-bases i could read to see how it should be done? (gwt’s own tuts are pretty basic, and just kitchen-sink every thing into a single file)

thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:01:25+00:00Added an answer on May 13, 2026 at 7:01 pm

    I hate to say something so unimaginative, but MVC works–it’s not the ultimate, but it can start getting you organized.

    EDIT: While searching on a semi-related topic, I came across this which has similar ideas to mine but goes into more detail.

    What that means in terms of GWT is that you should think of just laying out your GUI components in one class, put all your event handling in a second and put your object model objects separate from the other two.

    One way to accomplish this is to make most or all the controls on your GUI public members. This sounds kind of lame, but their usage is encapsulated inside the controller so it’s not like you have uncontrollable access–in fact your access is clearer/better defined than if all your members were private but your view code was combined with the controller.

    Specific tricks:

    Have listeners be their own class. You can often reuse them– in other words, avoid anonymous inner classes. I sometimes create a listener class and instantiate a new instance for each button/control that needs to have a similar effect when pressed. If I need it to act slightly differently for a given button, I’ll pass something into the constructor of the “special” handlers so that they know to act a little differently. You can also create different handler sub-classes if necessary–I’m just saying don’t forget that event handlers are classes, you can use inheritance and everything if need be.

    One Very Old GUI Trick I learned a long time ago, try not to have various mini-handlers modifying the GUI in different ways, instead have all the “active” buttons and controls set a state within your GUI and then call a single method that applies that state to ALL the controls on your GUI. When you get beyond a trivial GUI this can be a life-saver. If I’m not being clear, leave a comment and I’ll leave an example for you.

    Property sheets:

    There is a special case for GUIs–the property sheet style GUI. I’ve done a LOT of these and they are irritating as HELL. They tend to have dozens or hundreds of controls on them, each GUI control tends to be tied to a specific field in your model and there are just hundreds of lines of copy and paste boilerplate code connecting them, each group copied and pasted with a few items changed–at minimum it’s like 3 lines of code per control (Create control, copy value in and copy value out).

    I always write these with a “Smart” controller–one that can intelligently bind the control to some data without any unique code. This can get tricky and if this is your problem let me know in the comments and I can give you some general advice as to some tricks you might try. I’ve gone from a minimal reflective solution to a full-on XML based solution. Were I to do it again, I might consider annotation-based.


    Example of MVC:

    Note, this is just an example, there are a MILLION ways to do MVC.

    In your MAIN:

    • Instantiate MyView
    • Instantiate MyModel
    • Instantiate MyController(myView, myModel)
    • myView.setVisible(true)

    in MyView

    • probably extends Frame
    • Most components are public final (public final Button b=new Button())
    • If public members make you nervous, use getters–same EXACT effect as public final members with a little extra syntax.
    • Remember that you can set final members in your constructor.
    • May have general methods such as reset(), but MyController may be a better place for this.

    in MyController

    • saves references to myView and myModel
    • adds listeners to myView where necessary (see advice on listeners above)
    • configures myView based on state of myModel
    • when “done” button pressed, copies state from myView to myModel
    • notifies myModel that it’s data has been updated and destroys itself.

    in MyModel:

    This would be a typical model class, it would contain your business logic (mostly not used as part of the GUI, that’s more like GUI logic in MyController. The controller would tend to set values in your business logic then call some method like updated() to cause some business logic to take control. It should know nothing of a GUI–this is your “pure” business class.

    Sometimes the GUI might call an update() or some other method to trigger some data change and then reload the GUI controls from the Model–this is a fairly good way to integrate your business logic with your GUI without your model knowing about the GUI…

    Also, as I said above, I would put more work into MyController if I was working with property sheets just due to the sheer number of lines of boilerplate that you end up with if you aren’t smart about it.

    Note that View and Controller are nearly always paired. You can’t just replace a Swing view with a web view and expect the controller to remain unmolested–but the model should not ever change for the view or controller.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 494k
  • Answers 494k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Renaming a file while it is open is fine, regardless… May 16, 2026 at 10:58 am
  • Editorial Team
    Editorial Team added an answer Stick with the tried and tested - MySQL (or PostgreSQL)… May 16, 2026 at 10:58 am
  • Editorial Team
    Editorial Team added an answer If you need to enforce limits then use quotas May 16, 2026 at 10:58 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.