import java.awt.*; public class RandomPanels extends RandomApplet { Color leftColor, rightColor; float lh, ls, lb, rh, rs, rb; // left/right HSB // draw a rectangle of colour on the left // avoids drawing on top of the font box, reduces flashing public void drawLeft() { int fontTop, fontBottom, fontWidth; fontTop = fontY; fontBottom = fontY + font.getHeight(); fontWidth = font.getWidth(); Graphics g = imageBuffer.getGraphics(); g.setColor(leftColor); g.fillRect(0, 0, imageBufferSize.width / 2, fontTop); g.fillRect(0, fontBottom, imageBufferSize.width / 2, imageBufferSize.height - fontBottom); g.fillRect(fontWidth, fontTop, imageBufferSize.width / 2 - fontWidth, fontBottom - fontTop); super.drawLeft(); } // draw a rectangle of colour on the right // avoids drawing on top of the font box, reduces flashing public void drawRight() { int fontTop, fontBottom, fontWidth; fontTop = fontY; fontBottom = fontY + font.getHeight(); fontWidth = font.getWidth(); Graphics g = imageBuffer.getGraphics(); g.setColor(rightColor); g.fillRect(imageBufferSize.width / 2, 0, imageBufferSize.width / 2, fontTop); g.fillRect(imageBufferSize.width / 2, fontBottom, imageBufferSize.width / 2, imageBufferSize.height - fontBottom); g.fillRect(imageBufferSize.width / 2, fontTop, imageBufferSize.width - fontWidth, fontBottom - fontTop); super.drawRight(); } // set colour to random values public void updateLeft() { super.updateLeft(); lh = leftNumber / (float)255.0; ls = (leftGen.next() & 0xff) / (float)255.0; lb = (leftGen.next() & 0xff) / (float)255.0; leftColor = Color.getHSBColor(lh, ls, lb); } public void updateRight() { super.updateRight(); rh = rightNumber / (float)255.0; rs = (rightGen.next() & 0xff) / (float)255.0; rb = (rightGen.next() & 0xff) / (float)255.0; rightColor = Color.getHSBColor(rh, rs, rb); } }