窗口生成器和摆动中的设计时间异常 [英] design time anomaly in window builder and swing
问题描述
我正在尝试使用窗口生成器来进行月食和摆动.
Im experimenting with window builder for eclipse and Swing.
我使用自定义的JPanel创建了一个演示计算器项目
I created a demo calculator project with a custom JPanel
DigitBoardView extends JPanel
并使用for循环分配了键
and assigned the keys using a for loop
String[] digits = {"1", ...}
for(String digit : digits){
JButton digButton = new JButton(digit);
add(digButton);
}
第一个问题- DigitBoardView 设计器没有显示它,
尽管常见问题解答说它不会生成并显示依赖于运行时的GUI
在设计时(可以),这与运行时无关.
即使我在编译时以明确已知的方式遍历数字
for(int i = 0; i < 10; i++)
循环设计器没有优势
1st problem - DigitBoardView designer doesn't show it,
though FAQ says it will not generate and show runtime dependant GUI
in design time (which is OK), nothing here is runtime dependant.
Even if I iterate over the digits with an explicitly known at compile time
for(int i = 0; i < 10; i++)
loop designer doesn't edge
第二个问题- JFrame 设计器确实显示了它! 如果我将JFrame的内容窗格设置为新的DigitBoardView 它会在设计时显示出来...
2nd problem - JFrame designer does show it! If I set the content pane of a JFrame to be new DigitBoardView it will be shown in design time...
为什么这么奇怪? 是虫子吗?
Why so strange? Is it bug?
我应该通过展平循环来绕过它吗?
这不是很丑吗?
违反了不重复自己原则的目的吗?
Should I bypass it by flattening the loop?
Isn't it extremely ugly?
Defeats the purpose of not repeating myself principle?
推荐答案
尽管与设计者问题有关,但您可能希望检查动作和键绑定来实现具有简单GridLayout
的简单数字键盘.
Although it's tangential to the designer issue, you might like to examine KeyPadPanel
, which uses actions and key bindings to implement a simple numeric keypad having a simple GridLayout
.
这篇关于窗口生成器和摆动中的设计时间异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!