Skip to main content



      Home
Home » Archived » Visual Editor (VE) » separators, struts, etc.
separators, struts, etc. [message #13021] Wed, 31 December 2003 07:18 Go to next message
Eclipse UserFriend
Originally posted by: mb.thomas-daily.de

Hello,

I added separators to the code of my JToolBar "toolBar.addSeparator();")
and struts to my JPanel ("panel.add(Box.createVerticalStrut(10));").

None of these are displayed in the VE. What am I doing wrong?

Is there a way to add these "separator things" with help of the VE?

thanx!
Marcus
Re: separators, struts, etc. [message #13107 is a reply to message #13021] Wed, 31 December 2003 09:53 Go to previous messageGo to next message
Eclipse UserFriend
Hi Marcus,

> I added separators to the code of my JToolBar "toolBar.addSeparator();")
> and struts to my JPanel ("panel.add(Box.createVerticalStrut(10));"). None
> of these are displayed in the VE. What am I doing wrong?

The problem is how the VE parses the code and builds up its model of the
JavaBeans. It looks for objects and their properties only right now, so the
method addSeparator() is not a property and gets ignored. To be a property
setter the method must have an argument. Therefore something like this
works

toolbar.addSeparator(new javax.swing.JToolBar.Separator());

This is basically what the addSeparator() methods does anyway, except that
the default orientation for the innerclass is horizontal and not vertical
(which is wierd considering most toolbars are probably horizontal and want
vertical separators). The technique that works best right now is to use the
ChooseBean dialog (the third one down in the palette), select Separator in
the search field and then chose the JToolBar$Separator inner class. Drop
this onto the toolbar and the code gets generated OK with a field created
for the separator but it will be horizontal. Select this (either in the
visual canvas or the JavaBeans tree view) and use the Properties view to
change the orientation to vertical.

For the Box strut the problem is that the Visual Editor right now wants
every component to have its own instance variable. You can't do this
visually for a Box strut, but in the code add a field for the strut as
follows:

private java.awt.Component vStrut;

then create a getter for it

private getVStrut(){
if(vStrut == null){
vStrut = javax.swing.Box.createVerticalStrut(10);
}
return vStrut;
}

and then add it to your panel

panel.add(getVStrut());

I know that for Box Scott Stanchfield created some Java Beans that
encapsulated the Box functionality and you can get these from
http://www.javadude.com/tools/ and navigate to "BoxBeans". These would then
allow you to just select the Box struts from ChooseBean and use them as
though they were regular JavaBeans.

However, we should make both of these scenarios easier. For the toolbar we
do have a line item to work with ad-hoc method invocations so addSeparator()
would be parsed into the model. Likewise for the box strut we should accept
ad-hoc method arguments to Container.add(...) methods. An optimal
implementation however might be that you can just add separators right from
a pop-up menu beside components on a toolbar, and for Box struts you could
do likewise to add vertical and horizontal struts around existing components
when they are on a BoxLayout. I'll open open a bugzilla feature requesting
that we take a look at these.

Best regards,

Joe Winchester
Re: separators, struts, etc. [message #13168 is a reply to message #13107] Wed, 31 December 2003 11:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mb.thomas-daily.de

First of all: thank you very much for your help!

>>I added separators to the code of my JToolBar "toolBar.addSeparator();")
>>and struts to my JPanel ("panel.add(Box.createVerticalStrut(10));"). None
>>of these are displayed in the VE. What am I doing wrong?
>
>
> The problem is how the VE parses the code and builds up its model of the
> JavaBeans. It looks for objects and their properties only right now, so the
> method addSeparator() is not a property and gets ignored. To be a property
> setter the method must have an argument. Therefore something like this
> works
>
> toolbar.addSeparator(new javax.swing.JToolBar.Separator());

You probably mean: toolBar.add(new javax.swing.JToolBar.Separator());

> This is basically what the addSeparator() methods does anyway, except that
> the default orientation for the innerclass is horizontal and not vertical
> (which is wierd considering most toolbars are probably horizontal and want
> vertical separators).

It does not work anyway: only the first one is displayed in VE :(
The other 8 on my example toolbar are not shown. But why not?
Is it a bug? Otherwise this would be the solution:

toolBar.add(new FixedJToolBarSeparator());

/**
* Fixes the weird default orientation (from horizontal to vertical).
*/
public class FixedJToolBarSeparator extends JToolBar.Separator
{
public FixedJToolBarSeparator()
{
setOrientation(SwingConstants.VERTICAL);
}
}

> The technique that works best right now is to use the
> ChooseBean dialog (the third one down in the palette), select Separator in
> the search field and then chose the JToolBar$Separator inner class. Drop
> this onto the toolbar and the code gets generated OK with a field created
> for the separator but it will be horizontal. Select this (either in the
> visual canvas or the JavaBeans tree view) and use the Properties view to
> change the orientation to vertical.

The result is more than ugly: nine identical methods in my example.

> For the Box strut the problem is that the Visual Editor right now wants
> every component to have its own instance variable. You can't do this
> visually for a Box strut, but in the code add a field for the strut as
> follows:
>
> private java.awt.Component vStrut;
>
> then create a getter for it
>
> private getVStrut(){
> if(vStrut == null){
> vStrut = javax.swing.Box.createVerticalStrut(10);
> }
> return vStrut;
> }
>
> and then add it to your panel
>
> panel.add(getVStrut());

Hmm, again X identical methods ...

> However, we should make both of these scenarios easier. For the toolbar we
> do have a line item to work with ad-hoc method invocations so addSeparator()
> would be parsed into the model.

"line item"? Ehm, what does it mean?

> Likewise for the box strut we should accept
> ad-hoc method arguments to Container.add(...) methods. An optimal
> implementation however might be that you can just add separators right from
> a pop-up menu beside components on a toolbar, and for Box struts you could
> do likewise to add vertical and horizontal struts around existing components
> when they are on a BoxLayout. I'll open open a bugzilla feature requesting
> that we take a look at these.

Fine!!

thanx!
Marcus
Re: separators, struts, etc. [message #13222 is a reply to message #13168] Wed, 31 December 2003 18:28 Go to previous messageGo to next message
Eclipse UserFriend
Hi Marcus Beyer,

> It does not work anyway: only the first one is displayed in VE :(
> The other 8 on my example toolbar are not shown. But why not?
> Is it a bug?

What you described with the FixedJToolBarSeparator should have worked fine. For
a test I created class com.foo.MyToolBarSeparator.

import javax.swing.SwingConstants;
import javax.swing.JToolBar.Separator;
public class MyToolBarSeparator extends Separator {
public MyToolBarSeparator(){
super.setOrientation(SwingConstants.VERTICAL);
}
}

then I created com.foo.TestToolBar and dropped the a JButton from the palette
(changing its text property to "Cut"), then MyToolBarSepartor from the ChooseBean
dialog, then another JButton (changing its text property to "Copy" and then two
more MyToolBarSepartor instances from ChooseBean. The GUI looked OK, so can you
test this example and tell me whether you get the same results ?

package com.foo;
import javax.swing.*;
public class TestToolBarSeparator extends JToolBar {
private javax.swing.JButton jButton = null;
private com.foo.MyToolBarSeparator myToolBarSeparator = null;
private javax.swing.JButton jButton1 = null;
private com.foo.MyToolBarSeparator myToolBarSeparator1 = null;
private com.foo.MyToolBarSeparator myToolBarSeparator2 = null;
public TestToolBarSeparator() {
super();
initialize();
}
private void initialize() {
this.add(getJButton());
this.add(getMyToolBarSeparator());
this.add(getJButton1());
this.add(getMyToolBarSeparator1());
this.add(getMyToolBarSeparator2());
}
private javax.swing.JButton getJButton() {
if(jButton == null) {
jButton = new javax.swing.JButton();
jButton.setText("Cut");
}
return jButton;
}
private com.foo.MyToolBarSeparator getMyToolBarSeparator() {
if(myToolBarSeparator == null) {
myToolBarSeparator = new com.foo.MyToolBarSeparator();
}
return myToolBarSeparator;
}
private javax.swing.JButton getJButton1() {
if(jButton1 == null) {
jButton1 = new javax.swing.JButton();
jButton1.setText("Copy");
}
return jButton1;
}
private com.foo.MyToolBarSeparator getMyToolBarSeparator1() {
if(myToolBarSeparator1 == null) {
myToolBarSeparator1 = new com.foo.MyToolBarSeparator();
}
return myToolBarSeparator1;
}
private com.foo.MyToolBarSeparator getMyToolBarSeparator2() {
if(myToolBarSeparator2 == null) {
myToolBarSeparator2 = new com.foo.MyToolBarSeparator();
}
return myToolBarSeparator2;
}
}

> > For the Box strut the problem ...

> Hmm, again X identical methods ...

The code below worked for me where I created a JavaBean called com.foo.MyStrut
that has properties of strutWidth and strutHeight with defaults of 10.

package com.foo;
import javax.swing.Box.Filler;
import java.awt.*;
public class MyStrut extends Filler {
public MyStrut(){
super(new Dimension(10,10),new Dimension(10,10),new Dimension(10,10));
}
public void setStrutWidth(int width){
changeShape(
new Dimension(width,getMinimumSize().height),
new Dimension(width,getPreferredSize().height),
new Dimension(width,getMaximumSize().height)
);
invalidate();
}
public int getStrutWidth(){
return getPreferredSize().width;
}
public void setStrutHeight(int height){
changeShape(
new Dimension(getMinimumSize().width,height),
new Dimension(getPreferredSize().width,height),
new Dimension(getMaximumSize().width,height)
);
invalidate();
}
public int getStrutHeight(){
return getPreferredSize().height;
}
}

Because this is a regular JavaBean it can be dropped onto a container using
ChooseBean dialog. I created the following test class com.foo.MyStrutTest with
three buttons, and between then two struts. One the struts I changed the
strutWidth and strutHeight using the property sheet. This worked OK for me and
shows the two stuts and the three buttons OK in the GUI and the Java Beans tree
view. Can you test it and see if you get the same result.

package com.foo;
import javax.swing.JPanel;
public class MyStrutTest extends JPanel {
private javax.swing.JButton jButton = null;
private javax.swing.JButton jButton1 = null;
private javax.swing.JButton jButton2 = null;
private com.foo.MyStrut myStrut = null;
private com.foo.MyStrut myStrut1 = null;
public MyStrutTest() {
super();
initialize();
}
private void initialize() {
this.setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS));
this.add(getJButton(), null);
this.add(getMyStrut(), null);
this.add(getJButton1(), null);
this.add(getMyStrut1(), null);
this.add(getJButton2(), null);
this.setSize(403, 200);
}
private javax.swing.JButton getJButton() {
if(jButton == null) {
jButton = new javax.swing.JButton();
jButton.setText("ButtonOne");
}
return jButton;
}
private javax.swing.JButton getJButton1() {
if(jButton1 == null) {
jButton1 = new javax.swing.JButton();
jButton1.setText("ButtonTwo");
}
return jButton1;
}
private javax.swing.JButton getJButton2() {
if(jButton2 == null) {
jButton2 = new javax.swing.JButton();
jButton2.setText("ButtonThree");
}
return jButton2;
}
private com.foo.MyStrut getMyStrut() {
if(myStrut == null) {
myStrut = new com.foo.MyStrut();
myStrut.setStrutWidth(60);
}
return myStrut;
}
private com.foo.MyStrut getMyStrut1() {
if(myStrut1 == null) {
myStrut1 = new com.foo.MyStrut();
myStrut1.setStrutHeight(50);
}
return myStrut1;
}
}

> "line item"? Ehm, what does it mean?

Sorry - IBM speak. We have things called "line items" that are management babble
for "a bit of work someone is going to do".

Best regards,

Joe
Re: separators, struts, etc. [message #13313 is a reply to message #13222] Fri, 02 January 2004 12:04 Go to previous message
Eclipse UserFriend
Originally posted by: mb.thomas-daily.de

Joe Winchester wrote:
> then I created com.foo.TestToolBar and dropped the a JButton from the palette
> (changing its text property to "Cut"), then MyToolBarSepartor from the ChooseBean
> dialog, then another JButton (changing its text property to "Copy" and then two
> more MyToolBarSepartor instances from ChooseBean. The GUI looked OK, so can you
> test this example and tell me whether you get the same results ?

Ah, this way it works. Thank you! The only thing that's not nice is that
a lot of method are added where I only want default separators. But
I can live with that :)

> The code below worked for me where I created a JavaBean called com.foo.MyStrut
> that has properties of strutWidth and strutHeight with defaults of 10.

Nice. Here comes mine. It has two advantages:
- high maximum high means easy to be selected on the Visual Editor
- setPreferredSize can be used, what is quite intuitive

import java.awt.Dimension;
import javax.swing.Box.Filler;
/**
* Created for easier working with Eclipse: Visual Editor.
*/
public class SpaceFiller extends Filler
{
/**
* Minimum size of the filler.
* Perhaps 0, because it is of no big importance?
*/
public final static int MIN = 0;
/**
* Preferred size of the filler.
* This is the most interesting value.
* Time will show, what is reasonable.
*/
public final static int PREFERRED = 20;
/**
* Maximum size of the filler.
* Should be quite high, so that it can be selected easily be selected
in the editor.
*/
public final static int MAX = Integer.MAX_VALUE;
private final static Dimension D_MIN = new Dimension(MIN, MIN);
private final static Dimension D_PRF = new Dimension(PREFERRED, PREFERRED);
private final static Dimension D_MAX = new Dimension(MAX, MAX);
/**
* The constructor must not have arguments,
* in order to be used with Eclipse: Visual Editor.
*/
public SpaceFiller()
{
super(D_MIN, D_PRF, D_MAX);
}
/**
* Overriding that method, because there was no effect on the original one.
*/
public void setPreferredSize(Dimension preferredSize)
{
super.setPreferredSize(preferredSize);
changeShape(D_MIN, preferredSize, D_MAX);
}
}

>>"line item"? Ehm, what does it mean?
>
>
> Sorry - IBM speak. We have things called "line items" that are management babble
> for "a bit of work someone is going to do".

:) Thanks a lot for your fast help and for this great tool!

Marcus
Re: separators, struts, etc. [message #576368 is a reply to message #13021] Wed, 31 December 2003 09:53 Go to previous message
Eclipse UserFriend
Hi Marcus,

> I added separators to the code of my JToolBar "toolBar.addSeparator();")
> and struts to my JPanel ("panel.add(Box.createVerticalStrut(10));"). None
> of these are displayed in the VE. What am I doing wrong?

The problem is how the VE parses the code and builds up its model of the
JavaBeans. It looks for objects and their properties only right now, so the
method addSeparator() is not a property and gets ignored. To be a property
setter the method must have an argument. Therefore something like this
works

toolbar.addSeparator(new javax.swing.JToolBar.Separator());

This is basically what the addSeparator() methods does anyway, except that
the default orientation for the innerclass is horizontal and not vertical
(which is wierd considering most toolbars are probably horizontal and want
vertical separators). The technique that works best right now is to use the
ChooseBean dialog (the third one down in the palette), select Separator in
the search field and then chose the JToolBar$Separator inner class. Drop
this onto the toolbar and the code gets generated OK with a field created
for the separator but it will be horizontal. Select this (either in the
visual canvas or the JavaBeans tree view) and use the Properties view to
change the orientation to vertical.

For the Box strut the problem is that the Visual Editor right now wants
every component to have its own instance variable. You can't do this
visually for a Box strut, but in the code add a field for the strut as
follows:

private java.awt.Component vStrut;

then create a getter for it

private getVStrut(){
if(vStrut == null){
vStrut = javax.swing.Box.createVerticalStrut(10);
}
return vStrut;
}

and then add it to your panel

panel.add(getVStrut());

I know that for Box Scott Stanchfield created some Java Beans that
encapsulated the Box functionality and you can get these from
http://www.javadude.com/tools/ and navigate to "BoxBeans". These would then
allow you to just select the Box struts from ChooseBean and use them as
though they were regular JavaBeans.

However, we should make both of these scenarios easier. For the toolbar we
do have a line item to work with ad-hoc method invocations so addSeparator()
would be parsed into the model. Likewise for the box strut we should accept
ad-hoc method arguments to Container.add(...) methods. An optimal
implementation however might be that you can just add separators right from
a pop-up menu beside components on a toolbar, and for Box struts you could
do likewise to add vertical and horizontal struts around existing components
when they are on a BoxLayout. I'll open open a bugzilla feature requesting
that we take a look at these.

Best regards,

Joe Winchester
Re: separators, struts, etc. [message #576483 is a reply to message #13107] Wed, 31 December 2003 11:06 Go to previous message
Eclipse UserFriend
First of all: thank you very much for your help!

>>I added separators to the code of my JToolBar "toolBar.addSeparator();")
>>and struts to my JPanel ("panel.add(Box.createVerticalStrut(10));"). None
>>of these are displayed in the VE. What am I doing wrong?
>
>
> The problem is how the VE parses the code and builds up its model of the
> JavaBeans. It looks for objects and their properties only right now, so the
> method addSeparator() is not a property and gets ignored. To be a property
> setter the method must have an argument. Therefore something like this
> works
>
> toolbar.addSeparator(new javax.swing.JToolBar.Separator());

You probably mean: toolBar.add(new javax.swing.JToolBar.Separator());

> This is basically what the addSeparator() methods does anyway, except that
> the default orientation for the innerclass is horizontal and not vertical
> (which is wierd considering most toolbars are probably horizontal and want
> vertical separators).

It does not work anyway: only the first one is displayed in VE :(
The other 8 on my example toolbar are not shown. But why not?
Is it a bug? Otherwise this would be the solution:

toolBar.add(new FixedJToolBarSeparator());

/**
* Fixes the weird default orientation (from horizontal to vertical).
*/
public class FixedJToolBarSeparator extends JToolBar.Separator
{
public FixedJToolBarSeparator()
{
setOrientation(SwingConstants.VERTICAL);
}
}

> The technique that works best right now is to use the
> ChooseBean dialog (the third one down in the palette), select Separator in
> the search field and then chose the JToolBar$Separator inner class. Drop
> this onto the toolbar and the code gets generated OK with a field created
> for the separator but it will be horizontal. Select this (either in the
> visual canvas or the JavaBeans tree view) and use the Properties view to
> change the orientation to vertical.

The result is more than ugly: nine identical methods in my example.

> For the Box strut the problem is that the Visual Editor right now wants
> every component to have its own instance variable. You can't do this
> visually for a Box strut, but in the code add a field for the strut as
> follows:
>
> private java.awt.Component vStrut;
>
> then create a getter for it
>
> private getVStrut(){
> if(vStrut == null){
> vStrut = javax.swing.Box.createVerticalStrut(10);
> }
> return vStrut;
> }
>
> and then add it to your panel
>
> panel.add(getVStrut());

Hmm, again X identical methods ...

> However, we should make both of these scenarios easier. For the toolbar we
> do have a line item to work with ad-hoc method invocations so addSeparator()
> would be parsed into the model.

"line item"? Ehm, what does it mean?

> Likewise for the box strut we should accept
> ad-hoc method arguments to Container.add(...) methods. An optimal
> implementation however might be that you can just add separators right from
> a pop-up menu beside components on a toolbar, and for Box struts you could
> do likewise to add vertical and horizontal struts around existing components
> when they are on a BoxLayout. I'll open open a bugzilla feature requesting
> that we take a look at these.

Fine!!

thanx!
Marcus
Re: separators, struts, etc. [message #576555 is a reply to message #13168] Wed, 31 December 2003 18:28 Go to previous message
Eclipse UserFriend
Hi Marcus Beyer,

> It does not work anyway: only the first one is displayed in VE :(
> The other 8 on my example toolbar are not shown. But why not?
> Is it a bug?

What you described with the FixedJToolBarSeparator should have worked fine. For
a test I created class com.foo.MyToolBarSeparator.

import javax.swing.SwingConstants;
import javax.swing.JToolBar.Separator;
public class MyToolBarSeparator extends Separator {
public MyToolBarSeparator(){
super.setOrientation(SwingConstants.VERTICAL);
}
}

then I created com.foo.TestToolBar and dropped the a JButton from the palette
(changing its text property to "Cut"), then MyToolBarSepartor from the ChooseBean
dialog, then another JButton (changing its text property to "Copy" and then two
more MyToolBarSepartor instances from ChooseBean. The GUI looked OK, so can you
test this example and tell me whether you get the same results ?

package com.foo;
import javax.swing.*;
public class TestToolBarSeparator extends JToolBar {
private javax.swing.JButton jButton = null;
private com.foo.MyToolBarSeparator myToolBarSeparator = null;
private javax.swing.JButton jButton1 = null;
private com.foo.MyToolBarSeparator myToolBarSeparator1 = null;
private com.foo.MyToolBarSeparator myToolBarSeparator2 = null;
public TestToolBarSeparator() {
super();
initialize();
}
private void initialize() {
this.add(getJButton());
this.add(getMyToolBarSeparator());
this.add(getJButton1());
this.add(getMyToolBarSeparator1());
this.add(getMyToolBarSeparator2());
}
private javax.swing.JButton getJButton() {
if(jButton == null) {
jButton = new javax.swing.JButton();
jButton.setText("Cut");
}
return jButton;
}
private com.foo.MyToolBarSeparator getMyToolBarSeparator() {
if(myToolBarSeparator == null) {
myToolBarSeparator = new com.foo.MyToolBarSeparator();
}
return myToolBarSeparator;
}
private javax.swing.JButton getJButton1() {
if(jButton1 == null) {
jButton1 = new javax.swing.JButton();
jButton1.setText("Copy");
}
return jButton1;
}
private com.foo.MyToolBarSeparator getMyToolBarSeparator1() {
if(myToolBarSeparator1 == null) {
myToolBarSeparator1 = new com.foo.MyToolBarSeparator();
}
return myToolBarSeparator1;
}
private com.foo.MyToolBarSeparator getMyToolBarSeparator2() {
if(myToolBarSeparator2 == null) {
myToolBarSeparator2 = new com.foo.MyToolBarSeparator();
}
return myToolBarSeparator2;
}
}

> > For the Box strut the problem ...

> Hmm, again X identical methods ...

The code below worked for me where I created a JavaBean called com.foo.MyStrut
that has properties of strutWidth and strutHeight with defaults of 10.

package com.foo;
import javax.swing.Box.Filler;
import java.awt.*;
public class MyStrut extends Filler {
public MyStrut(){
super(new Dimension(10,10),new Dimension(10,10),new Dimension(10,10));
}
public void setStrutWidth(int width){
changeShape(
new Dimension(width,getMinimumSize().height),
new Dimension(width,getPreferredSize().height),
new Dimension(width,getMaximumSize().height)
);
invalidate();
}
public int getStrutWidth(){
return getPreferredSize().width;
}
public void setStrutHeight(int height){
changeShape(
new Dimension(getMinimumSize().width,height),
new Dimension(getPreferredSize().width,height),
new Dimension(getMaximumSize().width,height)
);
invalidate();
}
public int getStrutHeight(){
return getPreferredSize().height;
}
}

Because this is a regular JavaBean it can be dropped onto a container using
ChooseBean dialog. I created the following test class com.foo.MyStrutTest with
three buttons, and between then two struts. One the struts I changed the
strutWidth and strutHeight using the property sheet. This worked OK for me and
shows the two stuts and the three buttons OK in the GUI and the Java Beans tree
view. Can you test it and see if you get the same result.

package com.foo;
import javax.swing.JPanel;
public class MyStrutTest extends JPanel {
private javax.swing.JButton jButton = null;
private javax.swing.JButton jButton1 = null;
private javax.swing.JButton jButton2 = null;
private com.foo.MyStrut myStrut = null;
private com.foo.MyStrut myStrut1 = null;
public MyStrutTest() {
super();
initialize();
}
private void initialize() {
this.setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS));
this.add(getJButton(), null);
this.add(getMyStrut(), null);
this.add(getJButton1(), null);
this.add(getMyStrut1(), null);
this.add(getJButton2(), null);
this.setSize(403, 200);
}
private javax.swing.JButton getJButton() {
if(jButton == null) {
jButton = new javax.swing.JButton();
jButton.setText("ButtonOne");
}
return jButton;
}
private javax.swing.JButton getJButton1() {
if(jButton1 == null) {
jButton1 = new javax.swing.JButton();
jButton1.setText("ButtonTwo");
}
return jButton1;
}
private javax.swing.JButton getJButton2() {
if(jButton2 == null) {
jButton2 = new javax.swing.JButton();
jButton2.setText("ButtonThree");
}
return jButton2;
}
private com.foo.MyStrut getMyStrut() {
if(myStrut == null) {
myStrut = new com.foo.MyStrut();
myStrut.setStrutWidth(60);
}
return myStrut;
}
private com.foo.MyStrut getMyStrut1() {
if(myStrut1 == null) {
myStrut1 = new com.foo.MyStrut();
myStrut1.setStrutHeight(50);
}
return myStrut1;
}
}

> "line item"? Ehm, what does it mean?

Sorry - IBM speak. We have things called "line items" that are management babble
for "a bit of work someone is going to do".

Best regards,

Joe
Re: separators, struts, etc. [message #576697 is a reply to message #13222] Fri, 02 January 2004 12:04 Go to previous message
Eclipse UserFriend
Joe Winchester wrote:
> then I created com.foo.TestToolBar and dropped the a JButton from the palette
> (changing its text property to "Cut"), then MyToolBarSepartor from the ChooseBean
> dialog, then another JButton (changing its text property to "Copy" and then two
> more MyToolBarSepartor instances from ChooseBean. The GUI looked OK, so can you
> test this example and tell me whether you get the same results ?

Ah, this way it works. Thank you! The only thing that's not nice is that
a lot of method are added where I only want default separators. But
I can live with that :)

> The code below worked for me where I created a JavaBean called com.foo.MyStrut
> that has properties of strutWidth and strutHeight with defaults of 10.

Nice. Here comes mine. It has two advantages:
- high maximum high means easy to be selected on the Visual Editor
- setPreferredSize can be used, what is quite intuitive

import java.awt.Dimension;
import javax.swing.Box.Filler;
/**
* Created for easier working with Eclipse: Visual Editor.
*/
public class SpaceFiller extends Filler
{
/**
* Minimum size of the filler.
* Perhaps 0, because it is of no big importance?
*/
public final static int MIN = 0;
/**
* Preferred size of the filler.
* This is the most interesting value.
* Time will show, what is reasonable.
*/
public final static int PREFERRED = 20;
/**
* Maximum size of the filler.
* Should be quite high, so that it can be selected easily be selected
in the editor.
*/
public final static int MAX = Integer.MAX_VALUE;
private final static Dimension D_MIN = new Dimension(MIN, MIN);
private final static Dimension D_PRF = new Dimension(PREFERRED, PREFERRED);
private final static Dimension D_MAX = new Dimension(MAX, MAX);
/**
* The constructor must not have arguments,
* in order to be used with Eclipse: Visual Editor.
*/
public SpaceFiller()
{
super(D_MIN, D_PRF, D_MAX);
}
/**
* Overriding that method, because there was no effect on the original one.
*/
public void setPreferredSize(Dimension preferredSize)
{
super.setPreferredSize(preferredSize);
changeShape(D_MIN, preferredSize, D_MAX);
}
}

>>"line item"? Ehm, what does it mean?
>
>
> Sorry - IBM speak. We have things called "line items" that are management babble
> for "a bit of work someone is going to do".

:) Thanks a lot for your fast help and for this great tool!

Marcus
Previous Topic:Creating a new Visual Class
Next Topic:Installing plugins (CSharp feature)
Goto Forum:
  


Current Time: Thu May 01 12:32:02 EDT 2025

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

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

Back to the top