com.vaadin.ui.Window.center()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中com.vaadin.ui.Window.center()方法的一些代码示例,展示了Window.center()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.center()方法的具体详情如下:
包路径:com.vaadin.ui.Window
类名称:Window
方法名:center

Window.center介绍

[英]Sets this window to be centered relative to its parent window. Affects windows only. If the window is resized as a result of the size of its content changing, it will keep itself centered as long as its position is not explicitly changed programmatically or by the user.

NOTE: This method has several issues as currently implemented. Please refer to http://dev.vaadin.com/ticket/8971 for details.
[中]将此窗口设置为相对于其父窗口居中。仅影响windows。如果窗口的大小因其内容的大小而改变,则只要其位置没有以编程方式或用户明确更改,它就会保持居中。
注意:该方法在当前实施时存在几个问题。请参阅http://dev.vaadin.com/ticket/8971详细信息。

代码示例

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Sets window modality. When a modal window is open, components outside
 * that window cannot be accessed.
 * <p>
 * Keyboard navigation is restricted by blocking the tab key at the top and
 * bottom of the window by activating the tab stop function internally.
 *
 * @param modal
 *            true if modality is to be turned on
 */
public void setModal(boolean modal) {
  getState().modal = modal;
  center();
}

代码示例来源:origin: com.vaadin/vaadin-server

@Override
public void readDesign(Element design, DesignContext context) {
  super.readDesign(design, context);
  if (design.hasAttr("center")) {
    center();
  }
  if (design.hasAttr("position")) {
    String[] position = design.attr("position").split(",");
    setPositionX(Integer.parseInt(position[0]));
    setPositionY(Integer.parseInt(position[1]));
  }
  // Parse shortcuts if defined, otherwise rely on default behavior
  if (design.hasAttr("close-shortcut")) {
    // Parse shortcuts
    String[] shortcutStrings = DesignAttributeHandler
        .readAttribute("close-shortcut", design.attributes(),
            String.class)
        .split("\\s+");
    removeAllCloseShortcuts();
    for (String part : shortcutStrings) {
      if (!part.isEmpty()) {
        ShortcutAction shortcut = DesignAttributeHandler
            .getFormatter()
            .parse(part.trim(), ShortcutAction.class);
        addCloseShortcut(shortcut.getKeyCode(),
            shortcut.getModifiers());
      }
    }
  }
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * @see org.opencms.ui.I_CmsDialogContext#onViewChange()
 */
public void onViewChange() {
  if (m_window != null) {
    m_window.center();
  }
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * @see org.opencms.ui.I_CmsDialogContext#onViewChange()
 */
public void onViewChange() {
  if (m_window != null) {
    m_window.center();
  }
}

代码示例来源:origin: org.opencms/opencms-core

public void run() {
    Window wnd = CmsVaadinUtils.getWindow(CmsBasicDialog.this);
    if (wnd != null) {
      wnd.center();
    }
  }
});

代码示例来源:origin: stackoverflow.com

public class MyUI extends UI {

 @Override
 protected void init(VaadinRequest request) {
  // You need to have some content on the UI, even if it's empty - otherwise it looks odd
  // Here, I'm just adding an empty layout
  VerticalLayout content = new VerticalLayout();
  content.setSizeFull();
  setContent(content);

  // Adding a child window, and centering it for kicks
  Window window = new Window("Help me SO", new SOComplicatedComponent());
  window.center();
  addWindow(window);

 }
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * Toggles the details visibility.<p>
 */
void toggleDetails() {
  m_details.setVisible(!m_details.isVisible());
  if (m_window != null) {
    m_window.center();
  }
}

代码示例来源:origin: org.opencms/opencms-core

public void buttonClick(ClickEvent event) {
  window.setContent(oldContent);
  window.setCaption(oldCaption);
  window.center();
}

代码示例来源:origin: com.haulmont.thirdparty/popupbutton

public void buttonClick(ClickEvent event) {
    Window w = new Window();
    w.center();
    w.setContent(createPopupButton());
    addWindow(w);
  }
});

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework

public Window buildAndOpen() {
    Window window = new Window();
    window.setCaption(this.title);
    window.setContent(this.build());
    window.center();
    window.setModal(this.modal);
    UI.getCurrent().addWindow(window);
    return window;
  }
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * Replaces the ui content with a single dialog.<p>
 *
 * @param caption the caption
 * @param dialog the dialog content
 */
public void setContentToDialog(String caption, CmsBasicDialog dialog) {
  setContent(new Label());
  Window window = CmsBasicDialog.prepareWindow(DialogWidth.narrow);
  window.setContent(dialog);
  window.setCaption(caption);
  window.setClosable(false);
  addWindow(window);
  window.center();
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework

public Window build() {
  Window dialog = new Window();
  dialog.addStyleName("light-box");
  dialog.setDraggable(false);
  dialog.setResizable(false);
  dialog.setModal(true);
  dialog.setWidth(95, Sizeable.Unit.PERCENTAGE);
  CssLayout contentWrapper = new CssLayout(content);
  contentWrapper.setSizeFull();
  contentWrapper.setStyleName("light-box-content");
  dialog.setContent(contentWrapper);
  dialog.center();
  return dialog;
}

代码示例来源:origin: org.opencms/opencms-core

break;
window.center();
return window;

代码示例来源:origin: org.ikasan/ikasan-dashboard-jar

@Override
  public void itemClick(ItemClickEvent event)
  {
    Window subWindow = new Window("Sub-window");
    VerticalLayout subContent = new VerticalLayout();
    subContent.setMargin(true);
    subWindow.setContent(subContent);
    
    Item item = event.getItem();
    
    final Property<String> moduleProperty =
        item.getItemProperty("Module");
    
    // Put some components in it
    subContent.addComponent(new Label(moduleProperty.getValue()));
    subContent.addComponent(new Button("Awlright"));
    
    // Center it in the browser window
    subWindow.center();
    
    // Open it in the UI
    UI.getCurrent().addWindow(subWindow);
  }
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * Replaces the ui content with a single dialog.<p>
 *
 * TODO: In the future this should only handle window creation, refactor dialog contents to CmsBasicDialog
 *
 * @param caption the caption
 * @param component the dialog content
 */
public void setContentToDialog(String caption, Component component) {
  setContent(new Label());
  Window window = CmsBasicDialog.prepareWindow(DialogWidth.narrow);
  CmsBasicDialog dialog = new CmsBasicDialog();
  VerticalLayout result = new VerticalLayout();
  dialog.setContent(result);
  window.setContent(dialog);
  window.setCaption(caption);
  window.setClosable(false);
  addWindow(window);
  window.center();
  if (component instanceof I_CmsHasButtons) {
    I_CmsHasButtons hasButtons = (I_CmsHasButtons)component;
    for (Button button : hasButtons.getButtons()) {
      dialog.addButton(button);
    }
  }
  result.addComponent(component);
}

代码示例来源:origin: org.ikasan/ikasan-dashboard-jar

/**
   * Helper method to initialise this object.
   * 
   * @param message
   */
  protected void init(String text)
  {
    super.setWidth("50%");
    super.setHeight("50%");
    super.setModal(true);
    super.setResizable(true);
    super.center();
    
    TextArea ta = new TextArea();
    ta.setSizeFull();
    ta.setValue(text);
    ta.setWordwrap(false);
        HorizontalLayout layout = new HorizontalLayout();
    layout.setMargin(true);
    layout.addComponent(ta);
    layout.setSizeFull();
        Panel p = new Panel();
    p.setSizeFull();
    p.setContent(layout);
    
    super.setContent(p);
  }
}

代码示例来源:origin: org.opencms/opencms-core

/**
 * Shows the password reset dialog.<p>
 */
public void showPasswordResetDialog() {
  String caption = CmsVaadinUtils.getMessageText(Messages.GUI_PWCHANGE_FORGOT_PASSWORD_0);
  A_CmsUI r = A_CmsUI.get();
  r.setContent(new Label());
  Window window = CmsBasicDialog.prepareWindow(DialogWidth.narrow);
  CmsBasicDialog dialog = new CmsBasicDialog();
  VerticalLayout result = new VerticalLayout();
  dialog.setContent(result);
  window.setContent(dialog);
  window.setCaption(caption);
  window.setClosable(true);
  final CmsForgotPasswordDialog forgotPassword = new CmsForgotPasswordDialog();
  window.addCloseListener(new CloseListener() {
    /** Serial version id. */
    private static final long serialVersionUID = 1L;
    public void windowClose(CloseEvent e) {
      forgotPassword.cancel();
    }
  });
  for (Button button : forgotPassword.getButtons()) {
    dialog.addButton(button);
  }
  r.addWindow(window);
  window.center();
  VerticalLayout vl = result;
  vl.addComponent(forgotPassword);
}

代码示例来源:origin: org.opencms/opencms-core

window.setContent(dialog);
window.setCaption(newCaption);
window.center();

代码示例来源:origin: org.ikasan/ikasan-dashboard-jar

super.setModal(true);
super.setResizable(false);
super.center();

代码示例来源:origin: com.haulmont.cuba/cuba-web

dialog.center();

相关文章

微信公众号

最新文章

更多