Java AWT/SWT/Swing: How to plan a GUI?

前端 未结 10 2172
广开言路
广开言路 2020-12-02 04:46

I\'ve already realized some applications with a small graphical user interface. Nothing complex, but I\'ve encountered several problems that components aren\'t displayed or

10条回答
  •  心在旅途
    2020-12-02 05:33

    Do it by hand. GUI builders aren't good unless you have the 'partial class' concept in C#, and even then they often cause more problems than they solve. Use the GUI builder tools to make a prototype - sure, but not for production code.

    Also, another little trick I've used over the years to good effect when trying to debug layout or "which panel am I really seeing here" problems is to give each 'container' panel a really garish background color (yellow, blue, etc). Something obvious enough that you'll see it even if it's only one pixel wide.

    And my favorite layout for simple dialogs is BoxLayout. It's not great, you have to write a lot of boilerplate, but at least it generally works the way you would expect it to in your head. Don't overthink layouts until you have to.

提交回复
热议问题