Исходный текст аплета OptionsИсходный текст аплета Options представлен в листинге 1. Листинг 1. Файл Options.java import java.applet.*; import java.awt.*; public class Options extends Applet
{
FirstPanel pPanel1;
CardPanel pCard;
ControlPanel pControl;
public String getAppletInfo()
{
return "Name: Options";
}
public void init()
{
setLayout(new GridLayout(3, 1));
pPanel1 = new FirstPanel();
add(pPanel1);
pCard = new CardPanel(pPanel1);
add(pCard);
pControl = new ControlPanel(pCard);
add(pControl);
pPanel1.setBackground(Color.yellow);
pPanel1.setForeground(Color.black);
repaint(); } } class FirstPanel extends Panel
{
String szFontName = "TimesRoman";
public void paint(Graphics g)
{
Dimension dimAppWndDimension = getSize();
g.drawRect(0, 0,
dimAppWndDimension.width - 1,
dimAppWndDimension.height - 1);
g.setFont(new Font(szFontName,
Font.PLAIN, 24));
g.drawString("First panel", 10, 50);
super.paint(g); } } class CardPanel extends Panel
{
Panel pBgColor;
Panel pFgColor;
Panel pFont;
Panel pControlled; Choice chBgColor; Choice chFgColor; Choice chFont; Label lbBgColor; Label lbFgColor; Label lbFont; public CardPanel(Panel pControlledPanel)
{
pControlled = pControlledPanel;
setLayout(new CardLayout(5, 5)); pBgColor = new Panel();
pFgColor = new Panel();
pFont = new Panel();
add("BgColor", pBgColor);
add("FgColor", pFgColor);
add("Font", pFont);
chBgColor = new Choice();
chFgColor = new Choice();
chFont = new Choice();
chBgColor.add("Yellow");
chBgColor.add("Green");
chBgColor.add("White");
chFgColor.add("Black");
chFgColor.add("Red");
chFgColor.add("Green");
chFont.add("TimesRoman");
chFont.add("Helvetica");
chFont.add("Courier");
lbBgColor = new Label("Background color");
lbFgColor = new Label("Foreground color");
lbFont = new Label("Font");
pBgColor.add(lbBgColor);
pBgColor.add(chBgColor);
pFgColor.add(lbFgColor);
pFgColor.add(chFgColor);
pFont.add(lbFont);
pFont.add(chFont);
}
public void paint(Graphics g)
{
Dimension dimAppWndDimension = getSize();
g.dra |