I have created a simple view, but it would be nice to add buttons to it. For example, I drew two blue buttons into the view below. Is there a way to add similar buttons to my Eclipse view? I know that I can add a pulldown menu, from this question, but buttons are preferable.
My example below is just a demonstration - the location/size/color of the buttons does not matter as long as the buttons are inside the view.
In case you are using SWT: For a start you could install WindowBuilder. It lets you work on the UI level without caring to much about implementation. The generated code however is not layed out in the way that you can work with, when you are creating views with more than a few buttons.
The implementation depends on your Eclipse version.
In the old Eclipse 3.x, a Button could be set up by Overriding the method createPartControl
:
@Override
public void createPartControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new GridLayout(1, false));
Button btnMybutton = new Button(container, SWT.NONE);
btnMybutton.setBounds(0, 10, 75, 25);
btnMybutton.setText("MyButton");
//do anything else here
}
If you are familiar with other UI Frameworks and don't like SWT, you might as well switch to e.g. Vaadin or JavaFX. There's a blog articleabout changing the renderer of your application.