/** * 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 Selected Station Name panel */ import javax.swing.*; // the Swing GUI system import java.awt.*; // abstract windiwing toolkit public class frequencypanel extends JPanel { private Color bg; // background colour transparent white hfbrx_swing hf; boolean FrequenciesLoaded = false; int w, h, y; //panel's width and height font vertical baseline offset int FreqNum; //selected frequency Font font; //font for panel lettering frequencypanel(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 setFreq(int f) { FreqNum = f; repaint(); } public void paint(Graphics g) { // DISPLAY FREQUENCY CONFIRMATION FIELD if(FrequenciesLoaded) { // provided frequencies download is complete // select the new listening frequency hf.frequencies.setSelectedIndex(FreqNum); String s = (String)hf.frequencies.getItemAt(FreqNum); g.setColor(bg); // clear the field by g.fillRect(0, 0, w, h); // filling it with background colour g.setFont(font); // use the big bold font g.setColor(Color.black); /* display confirmation field in white lettering */ g.drawString(s, 4, y); // display the lettering } } public void update(Graphics g) { paint(g); } void setState(boolean b) {FrequenciesLoaded = b;} }