/* * @(#)QueueView.java * * This file is part of webCDwriter - Network CD Writing. * * Copyright (C) 2003 Jörg P. M. Haeger * * webCDwriter is free software. See CDcreator.java for details. */ import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; /** * A component displaying a queue. * * @version 20031015 * @author Jörg P. M. Haeger */ class QueueView extends JComponent { private int rank; QueueView(int rank) { this.rank = rank; setBackground(Color.gray); setFont(new Font("Dialog", Font.BOLD, 12)); setPreferredSize(new Dimension(100, 30)); } public void paint(Graphics g) { g.clearRect(0, 0, getWidth(), getHeight()); for (int i = 0; i <= rank; i++) { if (i == 0 && i == rank) g.setColor(Color.green); else if (i == rank) g.setColor(Color.yellow); else g.setColor(Color.gray); g.fillArc(10 + i * getHeight(), 1, getHeight() - 4, getHeight() - 4, 0, 360); g.setColor(Color.black); g.drawString("" + i, 20 + i * getHeight(), 2 * getHeight() / 3); } } }