Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Normally, if you want to do some custom drawing with a field ie. draw into the field's graphics context, you'd subclass Field and override the <em>paint</em> method. However, when it comes to BrowserField, you can't do that because it's declared <em>final</em>. </p> <p>There is a workaround for this, though. You can subclass a Manager and add your BrowserField to an instance of that manager. So, for example, if you want to add your BrowserField instance to a VerticalFieldManager, you can use the following code to get access to the Graphics object the browser will be drawn into. In this sample code, you'll see that I use the graphics object and manager's superclass implementation to draw into a bitmap. Then, that bitmap is drawn to the screen.</p> <pre><code>VerticalFieldManager vfm = new VerticalFieldManager() { // Override to gain access to Field's drawing surface // protected void paint(Graphics graphics) { // Create a bitmap to draw into // Bitmap b = new Bitmap(vfm.getVirtualWidth(), vfm.getVirtualHeight()); // Create a graphics context to draw into the bitmap // Graphics g = Graphics.create(b); // Give this graphics context to the superclass implementation // so it will draw into the bitmap instead of the screen // super.paint(g); // Now, draw the bitmap // graphics.drawBitmap(0, 0, vfm.getVirtualWidth(), vfm.getVirtualHeight(), b, 0, 0); } }; </code></pre> <p>And, there you have a Bitmap containing the contents of the manager. Should note, though, that this has the potential to consume a lot of memory.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload