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.

PanelChangeContents.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package com.vaadin.tests.components.panel;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractReindeerTestUI;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.Button.ClickEvent;
  6. import com.vaadin.ui.Button.ClickListener;
  7. import com.vaadin.ui.HorizontalLayout;
  8. import com.vaadin.ui.Label;
  9. import com.vaadin.ui.Panel;
  10. import com.vaadin.ui.VerticalLayout;
  11. public class PanelChangeContents extends AbstractReindeerTestUI
  12. implements ClickListener {
  13. VerticalLayout stats = new VerticalLayout();
  14. VerticalLayout companies = new VerticalLayout();
  15. VerticalLayout settings = new VerticalLayout();
  16. Button statsButton = new Button("Stats", this);
  17. Button companiesButton = new Button("Companies", this);
  18. Button settingsButton = new Button("Settings", this);
  19. private Panel panel;
  20. @Override
  21. protected void setup(VaadinRequest request) {
  22. VerticalLayout content = new VerticalLayout();
  23. setSizeFull();
  24. HorizontalLayout buttons = new HorizontalLayout();
  25. stats.addComponent(new Label("stats"));
  26. companies.addComponent(new Label("companies"));
  27. settings.addComponent(new Label("settings"));
  28. buttons.addComponent(statsButton);
  29. buttons.addComponent(companiesButton);
  30. buttons.addComponent(settingsButton);
  31. panel = new Panel();
  32. panel.setCaption("<div class=\"caption-with-html\">Caption</div>");
  33. panel.setSizeFull();
  34. panel.setContent(stats);
  35. content.addComponent(buttons);
  36. content.addComponent(panel);
  37. content.setMargin(true);
  38. content.setSpacing(true);
  39. content.setExpandRatio(panel, 1);
  40. setContent(content);
  41. }
  42. @Override
  43. public void buttonClick(ClickEvent event) {
  44. if (event.getButton() == statsButton) {
  45. panel.setContent(stats);
  46. } else if (event.getButton() == companiesButton) {
  47. panel.setContent(companies);
  48. } else if (event.getButton() == settingsButton) {
  49. panel.setContent(settings);
  50. }
  51. }
  52. @Override
  53. protected String getTestDescription() {
  54. // TODO Auto-generated method stub
  55. return null;
  56. }
  57. @Override
  58. protected Integer getTicketNumber() {
  59. return 8735;
  60. }
  61. }