home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Samples / Samples / afc11 / Buttons / Src / SDKCtrlPnl.java < prev    next >
Encoding:
Java Source  |  2000-05-04  |  16.1 KB  |  577 lines

  1. //
  2. // (C) Copyright 1995 - 1999 Microsoft Corporation.  All rights reserved.
  3. //
  4. import java.awt.Event;
  5. import java.awt.Insets;
  6. import java.awt.Image;
  7. import com.ms.ui.*;
  8. import com.ms.fx.*;
  9. import com.ms.util.*;
  10.  
  11. public class SDKCtrlPnl extends UIPanel implements SDKConsts, SDKCallbacks
  12. {
  13.     private UIPanel panel;
  14.     private UIGroup main, stsgrp, btntst;
  15.     private BtnPanel btns;
  16.     private BtnTstPanel btntstpnl;
  17.     private SDKInsetPanelBL ipanel;
  18.     private UIText btntype, btnstyle, btnstate;
  19.  
  20.     public SDKCtrlPnl(UIApplet applet, UIFrame frame)
  21.     {
  22.         SDKImages.init(applet, frame);
  23.  
  24.         setLayout(new UIBorderLayout(0,0));
  25.  
  26.         // Create button UIPanel
  27.         btns = new BtnPanel(this);
  28.  
  29.         // Create Button Test Panel
  30.         btntst = new UIGroup("Button Test Area");
  31.         btntst.setLayout(new UIBorderLayout(0,0));
  32.         btntstpnl = new BtnTstPanel(this);
  33.         btntst.add(btntstpnl, "Center");
  34.  
  35.         // Create UIPanel for btns and btntst
  36.         panel = new UIPanel();
  37.         panel.setLayout(new UISplitLayout(0, 135));
  38.         panel.add(btns,"nw"); panel.add(btntst,"se");
  39.  
  40.         // Create UIGroup for displaying button status information
  41.         stsgrp = new UIGroup("Button Status");
  42.         stsgrp.setLayout(new UISplitLayout(0, 90));
  43.  
  44.         SDKInsetPanelGL ipnlgl;
  45.         ipnlgl = new SDKInsetPanelGL(0,0,0,0);
  46.         ipnlgl.add(new UIText( "Button TYPE:", UIStatic.RIGHT));
  47.         ipnlgl.add(new UIText("Button STYLE:", UIStatic.RIGHT));
  48.         ipnlgl.add(new UIText("Button STATE:", UIStatic.RIGHT));
  49.         stsgrp.add(ipnlgl, "nw");
  50.  
  51.         ipnlgl = new SDKInsetPanelGL(0,5,0,0);
  52.         btntype = new UIText("", UIStatic.LEFT);
  53.         btnstyle = new UIText("", UIStatic.LEFT);
  54.         btnstate = new UIText("", UIStatic.LEFT);
  55.         btnstate.setFont(new FxFont("Dialog", FxFont.BOLD, 12));
  56.         ipnlgl.add(btntype); ipnlgl.add(btnstyle); ipnlgl.add(btnstate);
  57.         stsgrp.add(ipnlgl, "se");
  58.  
  59.         // Initialize Status panel w/ UIPushButton status (one button at a time
  60.         //  is enabled, we start w/ UIPushButton
  61.         displayTestBtn(B_PUSH); setStatusPush();
  62.  
  63.         // Create main UIGroup, add to this UIPanel
  64.         main = new UIGroup("You don't wear these BUTTONS on your lapel");
  65.         add(main, "Center");
  66.         main.setLayout(new UISplitLayout(UISplitLayout.HORIZONTAL, 264));
  67.         // Add button and button test panels on top and status panel on bottom.
  68.         main.add(panel, "nw"); 
  69.         ipanel = new SDKInsetPanelBL(3,0,0,0); ipanel.add(stsgrp, "Center");
  70.         main.add(ipanel, "se");
  71.     }
  72.  
  73.     public void setStatusPush()
  74.     {
  75.         int style = 0;
  76.         String str = new String("");
  77.  
  78.         btntype.setName("UIPushButton");
  79.         if ( btns.raised.isChecked() ) {
  80.             str += "UIPushButton.RAISED";
  81.             style |= UIPushButton.RAISED;
  82.         }
  83.  
  84.         if ( btns.thick.isChecked() ) {
  85.             if ( str.length() != 0 ) str += " | ";
  86.             str += "UIPushButton.THICK";
  87.             style |= UIPushButton.THICK;
  88.         }
  89.         if ( btns.ptgl.isChecked() ) {
  90.             if ( str.length() != 0 ) str += " | ";
  91.             str += "UIButton.TOGGLE";
  92.             style |= UIButton.TOGGLE;
  93.         }
  94.         else { // If TOGGLE is turned off PushButton can't be checked
  95.             if ( btntstpnl.pbtn.isChecked() )
  96.                 btntstpnl.pbtn.setChecked(false);
  97.         }
  98.         btntstpnl.pbtn.setStyle(style);
  99.         btnstyle.setName(str);
  100.         if ( btntstpnl.pbtn.isChecked() ) {
  101.             btnstate.setName("Checked");
  102.             btnstate.setForeground(new FxColor(255,0,0));
  103.         }
  104.         else {
  105.             btnstate.setName("UNChecked");
  106.             btnstate.setForeground(new FxColor(0,191,0));
  107.         }
  108.         // This will ensure pbtn repaints properly
  109.         btntstpnl.pbtn.setVisible(false);
  110.         btntstpnl.pbtn.setVisible(true);
  111.         btnstate.setValid(true);
  112.     }
  113.  
  114.     public void setStatusCheck()
  115.     {
  116.         int style = 0;
  117.         String str = new String("");
  118.  
  119.         btntype.setName("UICheckButton");
  120.  
  121.         if ( btns.ctgl.isChecked() ) {
  122.             str += "UIButton.TRITOGGLE";
  123.             style = UIButton.TRITOGGLE;
  124.         }
  125.         else {
  126.             str += "UIButton.TOGGLE";
  127.             // if not TRITOGGLE can't be indeterminate
  128.             if ( btntstpnl.cbtn.isIndeterminate() )
  129.                 btntstpnl.cbtn.setIndeterminate(false);
  130.             style = UIButton.TOGGLE;
  131.         }
  132.  
  133.         btntstpnl.cbtn.setStyle(style);
  134.         btnstyle.setName(str);
  135.  
  136.         if ( btntstpnl.cbtn.isChecked() ) {
  137.             btnstate.setName("Checked");
  138.             btnstate.setForeground(new FxColor(255,0,0));
  139.         }
  140.         else {
  141.             if ( btntstpnl.cbtn.isIndeterminate() ) {
  142.                 btnstate.setName("Indeterminate");
  143.                 btnstate.setForeground(new FxColor(255,255,0));
  144.             }
  145.             else {
  146.                 btnstate.setName("UNChecked");
  147.                 btnstate.setForeground(new FxColor(0,191,0));
  148.             }
  149.         }
  150.         btnstate.setValid(true);
  151.     }
  152.  
  153.     private void repaintAll(IUIComponent comp)
  154.     {
  155.         FxGraphics g = comp.getGraphics();
  156.         if (g != null)
  157.         {
  158.             comp.paintAll(g);
  159.             g.dispose();
  160.         }
  161.     }
  162.  
  163.     public void repaintCheck() { repaintAll(btntstpnl.cbtn); }
  164.  
  165.     public void setStatusRadio()
  166.     {
  167.         btntype.setName("UIRadioButton");
  168.         btnstyle.setName("UIButton.TOGGLE");
  169.         if ( btntstpnl.rbtn.isChecked() ) {
  170.             btnstate.setName("Checked");
  171.             btnstate.setForeground(new FxColor(255,0,0));
  172.         }
  173.         else {
  174.             btnstate.setName("UNChecked");
  175.             btnstate.setForeground(new FxColor(0,191,0));
  176.         }
  177.         btnstate.setValid(true);
  178.     }
  179.  
  180.     public void setEnabledRadio() { btntstpnl.rbtn.setEnabled(!btns.rdis.isChecked()); }
  181.  
  182.     public void repaintRadio()
  183.     { 
  184.         btntstpnl.rbtn.setValid(true);
  185.         repaintAll(btntstpnl.rbtn);
  186.     }
  187.  
  188.     public void setStatusRepeat()
  189.     {
  190.         btntype.setName("UIRepeatButton");
  191.         btnstyle.setName("");
  192.         btnstate.setName("UNChecked");
  193.         btnstate.setForeground(new FxColor(0,191,0));
  194.         btnstate.setValid(true);
  195.     }
  196.  
  197.     public void setEnabledRepeat()
  198.     {
  199.         boolean enabled = !btns.rptdis.isChecked();
  200.         btntstpnl.rptitem.setImage(enabled ? SDKImages.get(HOLDME) : 
  201.                                              SDKImages.get(HOLDME_DIS));
  202.         btntstpnl.rptitem.setValid(true);
  203.         btntstpnl.rptbtn.setEnabled(enabled);
  204.     }
  205.  
  206.     public void displayTestBtn(int btn)
  207.     {
  208.         btntstpnl.removeAll();
  209.  
  210.         switch ( btn ) {
  211.         case B_PUSH: btntstpnl.add(btntstpnl.ppanel,"nw"); break;
  212.         case B_CHECK: btntstpnl.add(btntstpnl.cpanel,"nw"); break;
  213.         case B_RADIO: btntstpnl.add(btntstpnl.rpanel,"nw"); break;
  214.         case B_REPEAT: btntstpnl.add(btntstpnl.rptpnl,"nw"); break;
  215.         }
  216.         btntstpnl.add(btntstpnl.display, "se");
  217.     }
  218.  
  219.     public boolean isCustomCheck() { return btns.ccstm.isChecked(); }
  220.  
  221.     public boolean isCustomRadio() { return btns.rcstm.isChecked(); }
  222.  
  223.     public Insets getInsets() { return new Insets(0,5,5,5); }
  224. }
  225.  
  226. class BtnPanel extends UIPanel implements SDKConsts
  227. {
  228.     public UIRadioButton push, rpt, chk, rad;
  229.     public UICheckButton raised, thick, ptgl, rcstm, ccstm, ctgl, bgnd;
  230.     public UICheckButton rdis, rptdis;
  231.  
  232.     private SDKCallbacks ctrl;
  233.     private UIGroup types; //, contnt;
  234.     private SDKInsetPanelVFL ipnl1, ipnl2;
  235.  
  236.     public BtnPanel(SDKCallbacks ctrl)
  237.     {
  238.         this.ctrl = ctrl;
  239.  
  240.         setLayout(new UIBorderLayout(0,0));
  241.         types = new UIGroup("Button Types");
  242.         types.setLayout(new UIVerticalFlowLayout(UIVerticalFlowLayout.FILL, 0));
  243.  
  244.         add(types, "Center");
  245.  
  246.         push = new UIRadioButton("UIPushButton"); push.setChecked(true);
  247.         raised = new UICheckButton("RAISED"); raised.setChecked(true);
  248.         thick = new UICheckButton("THICK"); thick.setChecked(true);
  249.         ptgl = new UICheckButton("TOGGLE"); ptgl.setChecked(true);
  250.         
  251.         chk = new UIRadioButton("UICheckButton"); 
  252.         ctgl = new UICheckButton("TRITOGGLE"); ctgl.setChecked(true); ctgl.setEnabled(false);
  253.         ccstm = new UICheckButton("Custom"); ccstm.setChecked(true); ccstm.setEnabled(false);
  254.  
  255.         rad = new UIRadioButton("UIRadioButton"); 
  256.         rcstm = new UICheckButton("Custom"); rcstm.setChecked(true); rcstm.setEnabled(false);
  257.         rdis = new UICheckButton("Disabled"); rdis.setEnabled(false);
  258.  
  259.         rpt = new UIRadioButton("UIRepeatButton"); 
  260.         rptdis = new UICheckButton("Disabled");
  261.  
  262.         // Add UIPushButton option and sub-options
  263.         ipnl1 = new SDKInsetPanelVFL(0,0,5,0); ipnl2 = new SDKInsetPanelVFL(0,20,0,0);
  264.         ipnl1.add(push);
  265.         ipnl2.add(raised); ipnl2.add(thick); ipnl2.add(ptgl);
  266.         ipnl1.add(ipnl2); types.add(ipnl1);
  267.  
  268.         // Add UICheckButton option and sub-options
  269.         ipnl1 = new SDKInsetPanelVFL(0,0,5,0);
  270.         ipnl2 = new SDKInsetPanelVFL(0,20,0,0);
  271.         ipnl1.add(chk);
  272.         ipnl2.add(ctgl); ipnl2.add(ccstm);
  273.         ipnl1.add(ipnl2); types.add(ipnl1);
  274.  
  275.         // Add UIRadioButton option and sub-options
  276.         ipnl1 = new SDKInsetPanelVFL(0,0,5,0); ipnl2 = new SDKInsetPanelVFL(0,20,0,0);
  277.         ipnl1.add(rad);
  278.         ipnl2.add(rcstm); ipnl2.add(rdis);
  279.         ipnl1.add(ipnl2); types.add(ipnl1);
  280.  
  281.         // Add UIRepeatButton option
  282.         ipnl2 = new SDKInsetPanelVFL(0,20,0,0);
  283.         ipnl2.add(rptdis);
  284.         types.add(rpt); types.add(ipnl2);
  285.     }
  286.  
  287.     public boolean action(Event e, Object arg)
  288.     {
  289.         if ( arg instanceof UIButton ) {
  290.             if ( arg == push ) {
  291.                 push.setChecked(true); rpt.setChecked(false);
  292.                 chk.setChecked(false); rad.setChecked(false);
  293.                 raised.setEnabled(true); thick.setEnabled(true);
  294.                 ptgl.setEnabled(true);
  295.                 ctgl.setEnabled(false); ccstm.setEnabled(false);
  296.                 rcstm.setEnabled(false); rdis.setEnabled(false);
  297.                 rptdis.setEnabled(false);
  298.                 ctrl.displayTestBtn(B_PUSH); ctrl.setStatusPush();
  299.             }
  300.             else if ( (arg == raised) || (arg == thick) || (arg == ptgl) )
  301.                 ctrl.setStatusPush();
  302.             else if ( arg == chk ) {
  303.                 push.setChecked(false); rpt.setChecked(false);
  304.                 chk.setChecked(true); rad.setChecked(false);
  305.                 raised.setEnabled(false); thick.setEnabled(false);
  306.                 ptgl.setEnabled(false);
  307.                 ctgl.setEnabled(true); ccstm.setEnabled(true);
  308.                 rcstm.setEnabled(false); rdis.setEnabled(false);
  309.                 rptdis.setEnabled(false);
  310.                 ctrl.displayTestBtn(B_CHECK); ctrl.setStatusCheck();
  311.             }
  312.             else if ( arg == ctgl )
  313.                 ctrl.setStatusCheck();
  314.             else if ( arg == ccstm )
  315.                 ctrl.repaintCheck();
  316.             else if ( arg == rad ) {
  317.                 push.setChecked(false); rpt.setChecked(false);
  318.                 chk.setChecked(false); rad.setChecked(true);
  319.                 raised.setEnabled(false); thick.setEnabled(false);
  320.                 ptgl.setEnabled(false);
  321.                 ctgl.setEnabled(false);    ccstm.setEnabled(false);
  322.                 if ( !rdis.isChecked() )
  323.                     rcstm.setEnabled(true); 
  324.                 if ( !rcstm.isChecked() )
  325.                     rdis.setEnabled(true);
  326.                 rptdis.setEnabled(false);
  327.                 ctrl.displayTestBtn(B_RADIO); ctrl.setStatusRadio();
  328.             }
  329.             else if ( arg == rcstm ) {
  330.                 ctrl.repaintRadio();
  331.                 if ( rcstm.isChecked() )
  332.                     rdis.setEnabled(false);
  333.                 else
  334.                     rdis.setEnabled(true);
  335.             }
  336.             else if ( arg == rdis ) {
  337.                 ctrl.setEnabledRadio();
  338.                 if ( rdis.isChecked() )
  339.                     rcstm.setEnabled(false);
  340.                 else
  341.                     rcstm.setEnabled(true);
  342.             }
  343.             else if ( arg == rpt ) {
  344.                 push.setChecked(false); rpt.setChecked(true);
  345.                 chk.setChecked(false); rad.setChecked(false);
  346.                 raised.setEnabled(false); thick.setEnabled(false);
  347.                 ptgl.setEnabled(false); 
  348.                 ctgl.setEnabled(false); ccstm.setEnabled(false);
  349.                 rcstm.setEnabled(false); rdis.setEnabled(false);
  350.                 rptdis.setEnabled(true);
  351.                 ctrl.displayTestBtn(B_REPEAT); ctrl.setStatusRepeat();
  352.             }
  353.             else if ( arg == rptdis )
  354.                 ctrl.setEnabledRepeat();
  355.         }
  356.     return super.action(e, arg);
  357.     }    
  358. }
  359.  
  360. class BtnTstPanel extends UIPanel implements SDKConsts, TimerListener
  361. {
  362.     public UIPushButton pbtn;
  363.     public CustomCheckButton cbtn;
  364.     public CustomRadioButton rbtn;
  365.     public UIRepeatButton rptbtn;
  366.     public DisplayPanel display; 
  367.     public SDKInsetPanelBL ppanel, cpanel, rpanel, rptpnl;
  368.     public UIGraphic anigrfc;
  369.     public UIItem rptitem;
  370.  
  371.     private SDKCallbacks ctrl;
  372.     private int imgindex, times;
  373.     private Timer timer;
  374.  
  375.     public BtnTstPanel(SDKCallbacks ctrl)
  376.     {
  377.         super();
  378.         this.ctrl = ctrl;
  379.  
  380.         imgindex = 0;
  381.         timer = null;
  382.  
  383.         setLayout(new UISplitLayout(0, 135));
  384.  
  385.         // Make test UIPushButton
  386.         UIItem item = new UIItem(SDKImages.get(PUSHME), "Press Me!", UIStatic.LEFT);
  387.         item.setFont(new FxFont("Dialog", FxFont.PLAIN, 14));
  388.         pbtn = new TTUIPushButton(item, 
  389.                                 UIPushButton.TOGGLE | UIPushButton.RAISED | 
  390.                                 UIPushButton.THICK);
  391.         pbtn.setBackground(new FxTexture(SDKImages.get(TEXTURE), FxTexture.STRETCH_NONE, 
  392.                                         0, 0, -1, -1, false, 185, 179, 202));
  393.         ppanel = new SDKInsetPanelBL(0,5,175,10); ppanel.add(pbtn, "Center");
  394.  
  395.         UIText text;
  396.  
  397.         // Make test UICheckButton
  398.         text = new UIText("Check Me!", UIStatic.LEFT);
  399.         cbtn = new CustomCheckButton(text, UIButton.TRITOGGLE, ctrl);
  400.         cpanel = new SDKInsetPanelBL(64,0,131,10); cpanel.add(cbtn, "Center");
  401.  
  402.         // Make test UIRadioButton
  403.         text = new UIText("Turn Me On!", UIStatic.LEFT);
  404.         rbtn = new CustomRadioButton(text, ctrl);
  405.         rpanel = new SDKInsetPanelBL(123,0,72,10); rpanel.add(rbtn, "Center");
  406.  
  407.         // Make test UIRepeatButton
  408.         rptitem = new UIItem(SDKImages.get(HOLDME), "Hold Me Down!", 0, UIItem.ABOVE);
  409.         rptbtn = new TTUIRepeatButton(rptitem, UIPushButton.RAISED);
  410.         rptpnl = new SDKInsetPanelBL(167,5,0,10); rptpnl.add(rptbtn, "Center");
  411.  
  412.         // Create Animation panel
  413.         display = new DisplayPanel();
  414.         anigrfc = new UIGraphic(SDKImages.get(ANIMATION));
  415.         display.add(anigrfc, "Center");
  416.     }
  417.  
  418.     public boolean action (Event evt, Object arg)
  419.     {
  420.         if ( arg instanceof UIButton ) {
  421.             if ( arg == pbtn ) {
  422.                 animate();
  423.                 ctrl.setStatusPush(); 
  424.             }
  425.             else if ( arg == rptbtn ) {
  426.                 // Show next frame in animation
  427.                 imgindex = (imgindex + 1) % NUM_ANIMATE;
  428.                 anigrfc.setImage(SDKImages.get(ANIMATION+imgindex));
  429.                 anigrfc.setValid(true);
  430.                 ctrl.setStatusRepeat();
  431.             }
  432.             else if ( arg == cbtn ) {
  433.                 animate();
  434.                 ctrl.setStatusCheck();
  435.             }
  436.             else if ( arg == rbtn ) {
  437.                 animate();
  438.                 ctrl.setStatusRadio();
  439.             }
  440.         }
  441.         return super.action(evt, arg);
  442.     }
  443.  
  444.     public void animate()
  445.     {
  446.         if ( timer != null )
  447.             timer.stop();
  448.  
  449.         times = 0;
  450.         timer = new Timer(this, 65, true);
  451.         timer.start();
  452.     }
  453.  
  454.     public void timeTriggered(TimerEvent te)
  455.     {
  456.         if ( te.getSource() == timer ) {
  457.             times++;
  458.             imgindex++;
  459.             if ( times == 4 )
  460.                 timer.stop();
  461.             anigrfc.setImage(SDKImages.get(ANIMATION + (imgindex % NUM_ANIMATE)));
  462.             anigrfc.setValid(true);
  463.         }
  464.     }
  465. }
  466.  
  467. class DisplayPanel extends UIPanel implements SDKConsts
  468. {
  469.     public DisplayPanel()
  470.     {
  471.         setLayout(new UIBorderLayout(0,0));
  472.         setBackground(new FxTexture(SDKImages.get(STARS), FxTexture.STRETCH_NONE, 
  473.                                         0, 0, -1, -1, false, 210, 184, 155));
  474.     }
  475.  
  476.     public Insets getInsets() { return new Insets(82,71,95,71); }
  477. }
  478.  
  479. class TTUIPushButton extends UIPushButton
  480. {
  481.     public TTUIPushButton(IUIComponent comp, int style) { super(comp, style); }
  482.  
  483.     // This will implement ToolTips
  484.     public String getHelp() {
  485.         return "Pressing button will\nmake globe rotate\none quarter revolution.";
  486.     }
  487. }
  488.  
  489. class TTUIRepeatButton extends UIRepeatButton
  490. {
  491.     public TTUIRepeatButton(IUIComponent comp, int style) { super(comp, style); }
  492.  
  493.     // This will implement ToolTips
  494.     public String getHelp() {
  495.         return "Holding down button\nwill cause globe to\nrotate continuously.";
  496.     }
  497. }
  498.  
  499. class CustomCheckButton extends UICheckButton implements SDKConsts
  500. {
  501.     private SDKCallbacks ctrl;
  502.     private Image on, off, ind;
  503.  
  504.     public CustomCheckButton(IUIComponent comp, int style, SDKCallbacks ctrl)
  505.     {
  506.         super(comp, style);
  507.         this.ctrl = ctrl;
  508.         on = SDKImages.get(CHECKBTN_ON); 
  509.         off = SDKImages.get(CHECKBTN); 
  510.         ind = SDKImages.get(CHECKBTN_IND);
  511.     }
  512.  
  513.     public void paintCheck(FxGraphics g)
  514.     {
  515.         if ( ctrl.isCustomCheck() ) {
  516.             if (g != null) {
  517.                 Image image;
  518.                 if ( isChecked() )
  519.                     image = on;
  520.                 else if ( isIndeterminate() )
  521.                     image = ind;
  522.                 else 
  523.                     image = off;
  524.                 g.drawImage(image, 0, (getSize().height - 32) / 2, this);
  525.             }            
  526.         }
  527.         else
  528.             super.paintCheck(g);
  529.     }
  530.  
  531.     public Insets getInsets()
  532.     {
  533.         Insets insets = super.getInsets();
  534.         if ( ctrl.isCustomCheck() )
  535.             insets.left += 14;
  536.         return(insets);
  537.     }
  538. }
  539.  
  540. class CustomRadioButton extends UIRadioButton implements SDKConsts
  541. {
  542.     private SDKCallbacks ctrl;
  543.     private Image off, on;
  544.  
  545.     public CustomRadioButton(IUIComponent comp, SDKCallbacks ctrl)
  546.     {
  547.         super(comp);
  548.         this.ctrl = ctrl;
  549.         off = SDKImages.get(RADIOBTN); on = SDKImages.get(RADIOBTN_ON);
  550.     }
  551.  
  552.     public void paintCheck(FxGraphics g)
  553.     {
  554.         if ( ctrl.isCustomRadio() ) {
  555.             if (g != null) {
  556.                 Image image;
  557.                 if ( isChecked() )
  558.                     image = on;
  559.                 else 
  560.                     image = off;
  561.                 g.clearRect(0,0, 30,40);
  562.                 g.drawImage(image, 0, (getSize().height - 32) / 2, this);
  563.             }            
  564.         }
  565.         else
  566.             super.paintCheck(g);
  567.     }
  568.  
  569.     public Insets getInsets()
  570.     {
  571.         Insets insets = super.getInsets();
  572.         if ( ctrl.isCustomRadio() )
  573.             insets.left += 16;
  574.         return(insets);
  575.     }
  576. }
  577.