關燈 巨大 直達底部
親,雙擊螢幕即可自動滾動
第4部分

nelp3=newPanel();

//addasimplemenuMenum=newMenu(”Application”);m。add(new

CheckboxMenuItem(”Base36Active”);m。add(newMenuItem(”Exit”));

//addmenutomenubarmb。add(m);setMenuBar(mb);//installthismenubar

intheframe

//Addbuttonstotheirownpanelp3。setLayout(newFlowLayout());

p3。add(d2Binary);p3。add(d2Octal);p3。add(d2Hex);p3。add(d2Base36);

//AddtextfieldsLabeldLabel=newLabel(”EnterDeecimal:”);Label

xLabel=newLabel(”ConvertedValue:”);dDisplay=new

TextField(integer。toString(decimalValue);7);xDisplay=new

TextField(baseXValue;32);xDisplay。setEditable(false);

p1。setLayout(newFlowLayout(FlowLayout。LEFT));p2。setLayout(new

FlowLayout(FlowLayout。LEFT));p1。add(dLabel);p1。add(dDisplay);

p2。add(xLabel);p2。add(xDisplay);

//Addthepanelsadd(”North”;p1);add(”Center”;p2);

add(”South”;p3);}//endd2xconstructor

publicvoidstart(){resize(400;150);show();}

publicvoidupdateXDisplay(){xDisplay。setText(baseXValue);}

publicbooleanhandleEvent(Eventevt){if(evt。targtintanceofMenuItem)

{if(”Exit”。equals(((MenuItem)evt。target)。getLabel())){hide();

dispose();System。exit(0);returnfalse;}retruntrue;}elseif

(evt。targetinstanceofButton){Stringwhick=

((Button)evt。target)。getLabel();if(whick。equals(”Binary”))

{decimalValue=Integer。parseInt(dDisplay。getText());baseXValue=

Interger。toString(decimalValue;2);}if(whick。equals(”Octal”))

{decimalValue=Integer。parseInt(dDisplay。getText());baseXValue=

Interger。toString(decimalValue;8);}if(whick。equals(”Hex”))

{decimalValue=Integer。parseInt(dDisplay。getText());baseXValue=

Interger。toString(decimalValue;16);}if(whick。equa