confused High priority How do I add a new button to the toolbar in the Sweet Home 3D applet?

This topic has been viewed 4339 times and has 3 replies
Thread status: Active
Questions about extending features and developing plug-ins [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
Post Reply New Topic
Bluman
Posts: 2
Joined: Sat Jan 29, 2011 3:42 pm

How do I add a new button to the toolbar in the Sweet Home 3D applet?

Post by Bluman »

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?
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: How do I add a new button to the toolbar in the Sweet Home 3D applet?

Post by Puybaret »

In the method createHomeController of the com.eteks.sweethome3d.applet.AppletApplication class, you should call:

Code: Select all

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
Bluman
Posts: 2
Joined: Sat Jan 29, 2011 3:42 pm

Re: How do I add a new button to the toolbar in the Sweet Home 3D applet?

Post by Bluman »

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?
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: How do I add a new button to the toolbar in the Sweet Home 3D applet?

Post by Puybaret »

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
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 1 guest