/** * 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 Station Names panel */ import javax.swing.*; // the Swing GUI system import java.awt.*; // abstract windiwing toolkit public class stationnamepanel extends JPanel { private Color bg; // background colour transparent white hfbrx_swing hf; // reference to the main applet class boolean StationNamesLoaded = false; int w, h, y, // panel's width and height font vertical baseline offset stn; // station name Font font; // font for panel lettering stationnamepanel(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 setStn(int x) { stn = x; repaint(); } // DISPLAY THE STATION NAME CONFIRMATION FIELD public void paint(Graphics g) { if(StationNamesLoaded) { // provided staion names download is complete // Select the new station and get its name hf.stations.setSelectedIndex(stn); String s = (String)hf.stations.getItemAt(stn); g.setColor(bg); // set to background colour to g.fillRect(0,0,w,h); // fill the field with it g.setFont(font); // Use the big bold font g.setColor(Color.black); // in black lettering g.drawString(s,4,y); // to display the confirmation field } } public void update(Graphics g) { paint(g); } void setStationNamesLoaded() {StationNamesLoaded = true;} }