Disabling right click


I’m trying to disable right click in whole applicaton. I found one solution with empty LayoutClickListener, but it doesn’t solve the same problec with window headers and notifications. Can any one advise another solution for this?

yo utilizo este metodo con el componente Window y me funciona perfectamente:

		ventana.addListener(new com.vaadin.event.MouseEvents.ClickListener() {
			private static final long serialVersionUID = 3479705318460232113L;

			public void click(ClickEvent event) {
				if (event.getButton() == 2) {

Thanks for the answer! But you solution does not cover window captions and vaadin notifications. I looking for solutions for them.

ventana.addListener(new com.vaadin.event.MouseEvents.ClickListener() {
2 private static final long serialVersionUID = 3479705318460232113L;
4 @Override
5 public void click(ClickEvent event) {
6 if (event.getButton() == 2) {
7 }
8 }
9 });

it’s not working pls provide another

if (


== 2) in this case getnutton will return
MouseButton type only… for me it’s not working…

You might want to place everything where you want to disable right click/context menu in a CustomLayout:

            CustomLayout noRightClickLayout= new CustomLayout(
                    new ByteArrayInputStream(
                            "<div location=\"mylocation\" oncontextmenu=\"return false\"></div>"
            noRightClickLayout.addComponent(YOUR_COMPONTENT, "mylocation");


oncontextmenu=“return false”

helps, you could also potentially add it for another layout with a very simple JavaScriptExtension.