/** * Search Engine Applet 1.0.1 * @author Robert John Morton * @version 22 October 1999 modified 10 July 2009, 10 April 2012 JFramed Sat 04 Mar 2017 11:57:36 BRT * @copyright Robert John Morton (all rights reserved) */ import javax.swing.*; // Swing GUI import java.awt.*; // for graphics operations (GUI) public class img3panel extends JPanel{ // SUMMARY NUMBER DISPLAY PANEL private static final Font // font for url and summary number font = new Font("Serif",Font.PLAIN,18); private Color bg; // background colour for the message panel private String msg = ""; // string to hold the displayed message text private search hf; // instance reference of the search applet private boolean redMsg = false; // true = display message in red lettering private int W, H, // width and height of message panel h; // height of the text base-line img3panel(int W, int H, Color bg, search hf) { this.W = W; // set width of message panel to local variable this.H = H; // set height of message panel to local variable this.bg = bg; // set panel's background colour to local variable this.hf = hf; // copy app's instance reference to local variable // compute baseline 'h' for the lettering within a panel of height 'H' FontMetrics fm = getFontMetrics(font); h = fm.getAscent() + (H - fm.getHeight()) /2; } void showNumber(String s){ // UPDATE SUMMARY'S NUMBER msg = s; // copy message to local variables repaint(); // schedule a repaint via event despatching thread } public void paint(Graphics g){ // DISPLAY SUMMARY'S NUMBER // draw the background image onto the applet canvas g.drawImage(hf.IMG3,0,0,this); g.setFont(font); // set font for summary number g.setColor(Color.black); // set text foreground colour g.drawString(msg,5,h); // draw the summary number } }