import java.awt.Graphics; import eu.webtoolkit.jwt.*; import eu.webtoolkit.jwt.utils.WebGraphics2D; import figtree.treeviewer.TreePane; public class TreeWidget extends WPaintedWidget { private TreePane treePane; public TreeWidget() { treePane = new TreePane() { @Override public void repaint() { // Signal that we need a repaint TreeWidget.this.update(); } }; } @Override public void resize(WLength width, WLength height) { super.resize(width, height); // Also resizes the tree pane treePane.setSize((int)width.toPixels(), (int)height.toPixels()); } @Override protected void layoutSizeChanged(int width, int height) { super.layoutSizeChanged(width, height); // Also resizes the tree pane treePane.setSize(width, height); } @Override protected void paintEvent(WPaintDevice paintDevice) { // Let the javax.swing.JComponent paint itself on the JWt paint-device WPainter painter = new WPainter(paintDevice); Graphics graphics = new WebGraphics2D(painter); treePane.paint(graphics); } }