Thanks for your quick reply, Etienne. I understand that the getPreferredSize
would fail, but I was hoping that there would be good solutions to these
very common problems - I really, really don't like the idea of creating
extensions to solve these types of things. Perhaps I can try using
ULCFillers, but it just feels that there should be a more elegant way of
emulating simple Swing stuff like this.
-Stuart
----- Original Message -----
From: "Etienne Studer" <[EMAIL PROTECTED]>
To: "Stuart Booth" <[EMAIL PROTECTED]>; <[email protected]>
Sent: Tuesday, August 15, 2006 10:12 PM
Subject: RE: [ULC-developer] ULCComboBox getPreferredSize/setMaximumSize
Hi Stuart
At the time you set the max size, the preferred size is not known (you
are on the server-side and no Swing component has been created yet).
combo.setMaximumSize(combo.getPreferredSize());
If I were you, I'd write a combo box extension that returns the
preferred size when asked for the max size or maybe play around with
adding a trailing ULCFiller and see if this helps you achieve the
toolbar layout that you want.
Etienne
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Stuart Booth
Sent: Tuesday, August 15, 2006 7:07 PM
To: [email protected]
Subject: [ULC-developer] ULCComboBox getPreferredSize/setMaximumSize
Converting a program from Swing to ULC, I notice a change of behavior,
which
I hope you can give me some advise on.
I have included below a class that demonstrates the problem, followed by
a
Swing class that is working as expected. Basically, the combobox in the
toolbar is being extended to the end. This happens by default in Swing,
but
there a simple setMaximumSize of the preferred size sets the width to a
reasonable size. In ULC, this isn't working as it does in Swing. Can you
look at this, please, and offer any suggestions on how I might rework
this
to get it working like Swing?
Thanks!
-Stuart Booth (Abacus Research)
public class BugsFrameApp extends AbstractApplication {
public void start() {
new BugsFrame().setVisible(true);
}
public static void main(String[] args) {
DevelopmentRunner.setApplicationClass(BugsFrameApp.class);
DevelopmentRunner.run();
}
class BugsFrame extends ULCFrame {
public BugsFrame() {
super("Bugs");
setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
setSize(800, 900);
addComponents();
}
private void addComponents() {
ULCToolBar toolbar = new ULCToolBar();
toolbar.add(new ULCButton("A"));
toolbar.add(new ULCButton("B"));
toolbar.addSeparator();
ULCComboBox combo = new ULCComboBox(new String[]{"Red",
"Green",
"Blue"});
toolbar.add(combo);
combo.setMaximumSize(combo.getPreferredSize());
add(toolbar, ULCBorderLayoutPane.NORTH);
}
}
}
This is the Swing class that works perfectly:
public class BugsFrameApp extends JFrame {
public static void main(String[] args) {
new BugsFrameApp().setVisible(true);
}
public BugsFrameApp() {
super("Bugs");
setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
setSize(800, 900);
addComponents();
}
private void addComponents() {
JToolBar toolbar = new JToolBar();
toolbar.add(new JButton("A"));
toolbar.add(new JButton("B"));
toolbar.addSeparator();
JComboBox combo = new JComboBox(new String[]{"Red", "Green",
"Blue"});
toolbar.add(combo);
combo.setMaximumSize(combo.getPreferredSize());
add(toolbar, BorderLayout.NORTH);
}
}
_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer
_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer