2

I'm just doing a simple bookmark app, and I want to open up a webpage from a URL in new tab when I double click on my bookmark in my table. I did the listener waiting for the double click but I have no idea how to open a new tab with URL:

table_1.addListener(new ItemClickEvent.ItemClickListener() {
            public void itemClick(ItemClickEvent event) {
                if (event.isDoubleClick()) {
                    System.out.println("double click");
                    BrowserWindowOpener open = new BrowserWindowOpener(new ExternalResource("http://www.google.com"));

                }
            }
        });

I tried with the BrowserWindowOpener, but when I extend a composite, for example this table it works like I have to double click on my table item, and after that I have to click again anywhere on the table to open up the new tab. How to change that to a simple double click -> open new window?

shnek
  • 19
  • 3

1 Answers1

0

I am afraid you will have to use Javascript.

    VerticalLayout layout = new VerticalLayout();
    layout.setWidth("200px");
    layout.setHeight("200px");
    layout.addLayoutClickListener(new LayoutClickListener()
    {
        @Override
        public void layoutClick(LayoutClickEvent event)
        {
            if(event.isDoubleClick()){
                JavaScript.eval("var win = window.open('http://www.penny4nasa.org', '_blank');win.focus();");
            }
        }
    });
    setContent(layout);

The second approach would be writing your own custom component using GWT.

kukis
  • 4,489
  • 6
  • 27
  • 50