/** * HF Receiver Controller Applet 1.0.0 * @author Robert J Morton YE572246C * @version 25 November 2001, revanped 16 November 2007, * Swing Version 31 January 2012 * @copyright Robert J Morton (all rights reserved) */ /* This is the Applet's Confirmation Messages panel */ import javax.swing.*; // the Swing GUI system import java.awt.*; // abstract windiwing toolkit public class messagespanel extends JPanel { private hfbrx_swing hf; private Color bg; // background colour transparent white private boolean FrequenciesLoaded = false, Error = false; // true when message is an error message int w, h, y; // panel's width, height, font vertical baseline offset String msg; // string to hold messages Font font; // font for panel lettering messagespanel(int w, int h, int y, Font font, hfbrx_swing hf, Color bg) { this.w = w; this.h = h; this.font = font; this.y = y; this.hf = hf; this.bg = bg; } void showMsg(String m, boolean b) { msg = m; Error = b; repaint(); } public void paint(Graphics g) { // clear the field by filling it with background colour g.setColor(bg); g.fillRect(0, 0, w, h); g.setFont(font); // use the big bold font g.setColor(Color.black); // show progress message in black lettering /* If loading has finished completely, kill label on retry button; else, if this is an ERROR message, change label on retry button to "Retry" and display error message in red lettering. */ if(msg.equals("")) hf.RtryBut.setText(""); else if(Error) { hf.RtryBut.setText("Retry"); g.setColor(Color.red); } g.drawString(msg,4,y); // display the message } public void update(Graphics g) { paint(g); } }