Print at Dec 21, 2025, 7:25:04 AM View all posts in this thread on one page
Posted by Bluman at Jan 29, 2011, 3:54:02 PM
confused   How do I add a new button to the toolbar in the Sweet Home 3D applet?
I have only partially figured out how I add a button to the toolbar in the applet. After a lot of work, I managed to add a button without functionality. This button was really supposed to split walls. It disappears when I press another button. How do I add a button permanently to the toolbar, and how do I add functionality to a button? By the way, how do I add an icon to such a button?

Posted by Puybaret at Jan 29, 2011, 5:18:06 PM
Re: How do I add a new button to the toolbar in the Sweet Home 3D applet?
In the method createHomeController of the com.eteks.sweethome3d.applet.AppletApplication class, you should call:
toolBar.add(getToolBarAction(homeView, HomeView.ActionType.SPLIT_WALL));
at the place you want to insert the button.

If you want to program a new button, implement a new Action and its actionPerformed method, then add the action to the toolbar.
If you want to change its icon use the SMALL_ICON value of an action.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator

Posted by Bluman at Jan 30, 2011, 1:54:37 PM
Re: How do I add a new button to the toolbar in the Sweet Home 3D applet?
Thanks a lot. Now I can create buttons with my own actions.
But I still have the problem that the SPLIT_WALL button disappears. Is it because "HomeView.ActionType.SPLIT_WALL" has no action? How do I combine this enum entry with an action?

Posted by Puybaret at Jan 30, 2011, 7:04:43 PM
Re: How do I add a new button to the toolbar in the Sweet Home 3D applet?
It's probably because you didn't define an icon for SPLIT_WALL action.
Edit src/com/eteks/sweethome3d/swing/package.properties file and define in it the HomePane.SPLIT_WALL.SmallIcon property (look at other actions to guess how it works).
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D creator