You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestForWindowOpen.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests;
  17. import com.vaadin.ui.Button;
  18. import com.vaadin.ui.Button.ClickEvent;
  19. import com.vaadin.ui.CustomComponent;
  20. import com.vaadin.ui.UI;
  21. import com.vaadin.ui.VerticalLayout;
  22. public class TestForWindowOpen extends CustomComponent {
  23. public TestForWindowOpen() {
  24. final VerticalLayout main = new VerticalLayout();
  25. setCompositionRoot(main);
  26. main.addComponent(new Button("Open in this window",
  27. new Button.ClickListener() {
  28. @Override
  29. public void buttonClick(ClickEvent event) {
  30. UI.getCurrent().getPage()
  31. .setLocation("http://www.google.com");
  32. }
  33. }));
  34. main.addComponent(new Button("Open in target \"mytarget\"",
  35. new Button.ClickListener() {
  36. @Override
  37. public void buttonClick(ClickEvent event) {
  38. UI.getCurrent().getPage()
  39. .open("http://www.google.com", "mytarget");
  40. }
  41. }));
  42. main.addComponent(new Button("Open in target \"secondtarget\"",
  43. new Button.ClickListener() {
  44. @Override
  45. public void buttonClick(ClickEvent event) {
  46. UI.getCurrent().getPage()
  47. .open("http://www.google.com", "secondtarget");
  48. }
  49. }));
  50. }
  51. }