Skip to main content



      Home
Home » Archived » Visual Editor (VE) » Swing: using factory methods to build GUI
Swing: using factory methods to build GUI [message #607917] Fri, 10 June 2005 14:27
Eclipse UserFriend
[I'm sorry, I forgot to setup my mail address before posting the message]

Hello,

Using VE version 1.0.1.1 (the latest stable), I tried building a JPanel
subclass with many JButtons. I want all of the buttons have the same
properties - except for the text - so I thought of this approach:

// class MyPanel extends JPanel
private JButton getRedButton(String text) {
JButton button=new JButton(text);
button.setBackground(java.awt.Color.red);
button.set...(..);
return button;
}

Then, every button's getter method looks like this:

private JButton getFirst() {
if (first==null) {
first=getRedButton("First");
first.setSomeUniqueProperty(...);
}
return first;
}

Of-course, MyPanel.initialize() adds get*() to the panel.

This approach works, but... The Visual Editor doesn't show these buttons
on the panel. It doesn't even show them in the Java Beans tree. This
behavior makes it very hard to design complex UIs. In fact, it also
makes the VE useless for this case.

What am I doing wrong? I know, I can do everything in the "regular" way
- set all properties in the getters. But that means a lot of code
duplication.

Please suggest ways to fix the problem.

Thanks,
Noam.
Previous Topic:Swing: using factory methods to build GUI
Next Topic:Candidate build available for VE 1.1M2
Goto Forum:
  


Current Time: Thu Jun 12 15:19:34 EDT 2025

Powered by FUDForum. Page generated in 0.04801 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top