@SuppressWarnings(“serial”)
public class NotificationCustomExample extends VerticalLayout implements ClickListener {
public Button b;
//private Button b;
private Label richText;
private final RichTextArea editor = new RichTextArea();
public NotificationCustomExample() {
setSpacing(true);
richText = new Label(
"<h1>Rich text example</h1>"
+ "<p>The <b>quick</b> brown fox jumps <sup>over</sup> the <b>lazy</b> dog.</p>"
+ "<p>This text can be edited with the <i>Edit</i> -button</p>");
richText.setContentMode(Label.CONTENT_XHTML);
addComponent(richText);
b = new Button("Edit");
b.addListener(this);
addComponent(b);
editor.setWidth("100%");
}
public void buttonClick(ClickEvent event) {
if (getComponentIterator().next() == richText) {
editor.setValue(richText.getValue());
replaceComponent(richText, editor);
b.setCaption("Apply");
} else {
richText.setValue(editor.getValue());
replaceComponent(editor, richText);
b.setCaption("Edit");
}
}
}
@SuppressWarnings(“serial”)
public class NotificationCustomExample extends VerticalLayout {
public Label richText;
public RichTextArea editor = new RichTextArea();
public Label n ;
public NotificationCustomExample() {
setSpacing(true);
final RichTextArea editor = new RichTextArea();
editor.setWidth("100%");
editor.setValue("<p>to <i>john.doe@example.com</i></p>");
editor.setCaption("Description");
editor.setDescription("Additional information; try to keep it short.");
addComponent(editor);
n = new Label("ccccccc");
addComponent(n);
Button show = new Button("Show",
new Button.ClickListener() {
// "Inline" click listener; this is where the
// notification is actually created and shown.
public void buttonClick(ClickEvent event) {
// create Notification instance and customize
n.setValue(editor.getValue());
n.setContentMode(Label.CONTENT_XHTML);
//replaceComponent(n, editor);
System.out.println( "richTextArea.getValue(): " + editor.getValue() );
}
});
addComponent(show);
setComponentAlignment(show, Alignment.MIDDLE_RIGHT);
}