/*-----------------------------------------------------*/ /* Panel3 Options Java Program */ /*-----------------------------------------------------*/ import java.awt.*; import java.applet.*; import java.util.*; /*--------------------------------------------------------------*/ /* The class is an extension of Frame */ /* It provides options display/selection for panel3 */ /* Several sets of options are handled using a cardlayout */ /* panel */ /*--------------------------------------------------------------*/ public class P3opt extends Frame { private Panel3 parentApp; private String myTitle; private Panel3 qParent; private Panel mainPanel = new Panel(); private Panel fontPanel = new Panel(); private Panel colorPanel = new Panel(); private CardLayout cl = new CardLayout(); private Panel bPanel = new Panel(); private Button bApply = new Button("Apply"); private Button bDone = new Button("Done"); private Button bRefresh = new Button("Refresh"); private MenuBar mb = new MenuBar(); private Menu mPage = new Menu("View..."); private CheckboxMenuItem mFont = new CheckboxMenuItem("Font"); private CheckboxMenuItem mColor = new CheckboxMenuItem("Color"); Checkbox cbPlain = new Checkbox("Plain"); Checkbox cbBold = new Checkbox("Bold"); Checkbox cbItalic= new Checkbox("Italicized"); CheckboxGroup cbgStyle = new CheckboxGroup(); Label lFont = new Label("Font: ", Label.RIGHT); Choice cSize = new Choice(); Choice cFont = new Choice(); Label lRed = new Label("Red ", Label.RIGHT); Label lGreen = new Label("Green", Label.RIGHT); Label lBlue = new Label("Blue", Label.RIGHT); Label lRedval = new Label("0", Label.CENTER); Label lGreenval = new Label("0", Label.CENTER); Label lBlueval = new Label("0", Label.CENTER); Scrollbar sbRed = new Scrollbar(Scrollbar.HORIZONTAL, 0, 64, 0, 255); Scrollbar sbGreen = new Scrollbar(Scrollbar.HORIZONTAL, 0, 64, 0, 255); Scrollbar sbBlue = new Scrollbar(Scrollbar.HORIZONTAL, 0, 64, 0, 255); TextField tfTest = new TextField("", 16); int iFontsize; int iSizes[] = {8, 10, 12, 14, 16, 18, 20, 22, 24}; String sFonts[] = {"Courier", "Helv", "TimesNewRoman"}; int ix=0, iy=0; /*---------------------------------------------------------------*/ /* Constructor for option frame */ /* args are: frame title, parent applet, parent panel object */ /*---------------------------------------------------------------*/ public P3opt(String sTitle, Panel3 app) { super(sTitle); parentApp = app; myTitle = sTitle; // Construct menubar, menus and menuitems mPage.add(mFont); mPage.add(mColor); mb.add(mPage); setMenuBar(mb); mFont.setState(true); // Identify card layout for central options panel(s) mainPanel.setLayout(cl); //use card layout for master panel // Create center panel with option info (font options) GridBagConstraints gbc = new GridBagConstraints(); GridBagLayout gbl = new GridBagLayout(); gbc.anchor = GridBagConstraints.WEST; fontPanel.setLayout(gbl); // Add the fontsize choicelist and its label to the panel // Add the fontsizes from the static array to the choice and // set the default size to the fourth entry gbc.gridx=0; gbc.gridy=0; gbc.gridwidth=1; addElement(fontPanel, lFont, gbl, gbc); gbc.gridx=GridBagConstraints.RELATIVE; addElement(fontPanel, cFont, gbl, gbc); for (int i=0; i