云大JAVA实验12Lab #12(陆歌浩)

上传人:积*** 文档编号:205350355 上传时间:2023-04-28 格式:DOC 页数:15 大小:141KB
返回 下载 相关 举报
云大JAVA实验12Lab #12(陆歌浩)_第1页
第1页 / 共15页
云大JAVA实验12Lab #12(陆歌浩)_第2页
第2页 / 共15页
云大JAVA实验12Lab #12(陆歌浩)_第3页
第3页 / 共15页
点击查看更多>>
资源描述
云南大学软件学院 实验报告课程: Ja程序设计实验 学期: 第一学期任课教师: 专业: 学号: 序号: 姓名: 成绩: 实验12 部署pet和应用程序一、实验目的练习aa中部署apple和应用程序的应用。二、实验内容Pogam Pupse:Faliarize yef it smeo avs GI caabilites ndvnt hanlig d wite prormcntaites thingPror:Crte a progam o dodslay something cle to the fllowi: - Iut Numrs | | - | | | is i tex fied - | | - | | |otlwtohih | Tis is a btto | - | | - | | rhigh oo| Th is auto | - | | | Output bers | - | | | | | Th satext il - | | | - | | xitProgrm | Thi i abto | - | - Yo will b rovided it amtd tha take in Sng ad returnst you an arra nteers. (Iil write his ad ke aiable tou.) Teing hat ou passin the e theser etr i te nput uberset field.oillee to avea edt sor thearay tisreture (yu can use bubblert ust iknthe la ouple o labs.) This wilor romoto ih. yu docpy t out of t oo, give prorarbuoWhen eSrtlow to hh bt is ciced,ousuoutpt th sote itees ithe utputnumbertext fied.Whn th Sort high tlbutn i clkd, you shoud ouutte srted inegeih Ot nubes tex fie.The srshould be ab to cange te mbes in h Inpt numbe fil nd whe he buttns areped,thys tecurnt brand tput hmrted.实验代码:pacae e.ynu.lb12;mportavawt.*;impr javaxwing.*;ulc clss rTest pbli stai vi ain(Sting ar) Evntuuevokear(neRunab()pubic oid run()SotFamefrm =newSre();fra.etLcaton(350,1);/re.stSize(35,3);framesefaultloseOatn(JFram.EITON_OE); fame.etVisibl(tre);); packe eduynul1;iport java.wng.*;iport jva.a.nt;io jaa.awt.vent;impor jaa.til.Matcr;mprt jvautlregexPatten;bi clasotameextendJFrme private JuttoupButo;privt JttonownButtn;prive JBtn xtBut;riveJabel inpuLabel;private Jbl ottLabel;pieJTtFe inpuied;private JTexFiel oututield;piateJPanePne;pui SortFrame() / 设立indo风格ry MaagersetLoAndee(cmsun.va.wng.pwindonowsLookFel); cth (ClasNtouEcepton cnfe)cn.intSaTace(); cath (nstntiationxeptii) iepntStacka(); cath(IlaAcesEceti a)ieprtStckTe(); cath (UnuprtLoondFlxeptule) ulaprintSakTrce();etTitle(孙金文17);nutLabelnew JLabl(Inut Numbes);ouputLbl=ne JLel(Outpu Nubs);pton = nBun(ort lwt igh);ownBtn w Jtton(Sot hgh tow);eitBtto= ew Juon(Exitrgra);intFiel ew JTextFd();oupute =nw JTexFil();anel =ew Janel();inutLabl.setFont(newn(Sef, Font.OD,));oupuabl.setont(ne nt(rif, FtBOD, 12);puttn.seFn(ew Font(Se,Fnt.BOLD,1);ownutnseo(newFo(ri, Font.BOD, 12);iutst(n Fon(eif, nB, 12);outpied.etot(new Fo(Serif, FntBOLD, ));intFeldeFont(ne Fo(ei,Fon.BOD, 12);/ 升序排列按钮事件解决ttdActoistenr(newctoLsr() blcoid atonPrfod(AconEvent evt)tr ascnNumrs= scnsort();ouputFd.stx(acendus););/ 降序排列按钮事件解决donuto.adctListen(wcionLitene() pubi void tiPefrmed(Aconent t) Stri dendubers Decendsort();ututFld.t(descdNumbrs););/ 退出按钮事件解决exiutoddAtionLstener(new Actinitee() plc void tinPerformed(AtioEvent e) Ssexit(););oupaout jPaelayot = n GroupLayut(Pne);jae.Layot(jPael1Layu);nel1LayoutseorzntlGo(janelLyout.rearlGoup(Goyot.Alnmet.LADING)addGu(Grupaot.Aligent.TAILI,jPaneayout.creatSequentialGrup().addontinra(, hortMX_VAUE)addup(Pe1Layout.cratParallelGro(GrLyo.Alnmen.LEI)addCompon(dwuon)addCompone(ton)).ad(99,99, 9).addGrop(GropLayou.Alnt.TAILIG,jPanelLyout.reateeqeaGop().dCotainerG(101, So.MAX_VALUE)dComponent(itButo).aGa(, 12,12)aroup(jane1Layout.ratuntialru().adda(11, 1, 13).addmnen(utputLal).adCotainerGap(121,ot.MXVU).addGrou(Panel1Lyot.createquntiGrop().addGap(2,112, 112)ddCopoent(iptLabl)onainrG(1,Shot.X_LUE)).adGop(jPane1ayou.createSequntialGup().addGap(2,2,22)addroup(jPane1LayutreatParelGrp(Gropayou.AlinnTRAILN,fls)addmpn(outputFid,GropLayoutlignm.LEAING).adComoent(inputFild,upLayoutignme.LEANG,Gropayout.DEAULT_SIE,272,hor.AXVALUE))ddntaneGap(24, Sho.AX_V));janl1Layou.setVertiarou(jPel1Layout.createParalllGro(rouut.Alignmen.LADIN)dGrop(jael1Layut.cteeuentalGroup().aConaierGa().ddCompoen(ntLabel)dPrferdGap(aa.swng.ayutStleComonnPlacemen.REATED).dCmpont(inputFeld,Gropayut.PRFERED_SIZE,Grupayt.EFAUT_E,GouLaout.PREERR_IE).addGa(22, 22, 2)aCompoent(pBtton).ddG(,18, 18).addCpoet(dwnButn).adGap(18, 18,1).adomont(outLabel).dGp(, 10, 0).aCponnt(utpul,GoupayoutRFRED_SIZE,Grouayou.DFALT_SIZE,GropayoutPEERRED_IZE).addreeeGap(aax.swing.ayouttyleCponntPleentELATED,18,Shrt.M_ALUE).addmpont(exiButton).adGap(25, 25,25));Gopaot laou =nw Gouout(geCtntan();eCtentane()setLyut(layut);layt.setHorzoaGroup(layout.reateallelGop(ouLou.mn.EG).adroup(Gruayot.gnmentTRILING,ayout.creteSeqentialGroup().dContaineGp().ddCopnt(l, Groupaout.DAULTIZE,GupLayot.DEALZE, ho.MA_VAE).adConainerap());layout.eVrtclGoup(lyot.ceatPlelGroup(Groat.Aignent.LEADIG).dGou(ayotaequnlGroup().adCotnea().addComnent(jPanel,GrupLayout.DEAUL_SIZE,rupLout.DEAULT_SIZE, So.MAXALE).addContanerp();ack();/数据升序排序pubiString scndot()Srt sot ne ort();rngt= puie.get();rn Pate.cpie(.,/?!:;_+=*&%$!|?();增长相应的标点Macerma =atchr(str);Strigfirs=maeplell( );/ 把英文标点符号替代成空,即去掉英文标点符号frs firt.repaeAll(+, ); / 去掉输入时多余的空格Sring ewsr = frstsit( );nt newst.legth;i ubers nwntm ;tasndSot;Strig aceNumbr = ;r(inti = ; i ();/ 增长相应的标点Matcr m=pa.machr(tr);ting frs =.aceAll( ); / 把英文标点符号替代成空,即去掉英文标点符号frs= fis.rplceAl( +,);/去掉输入时多余的空格in ewstr= irs.plt( );intm =nst.lengt;itnmbrs neintm 1;intscedSor;ting dsedNubers= ;or (t i =; i m;+)numsi = Inteer.preInt(wstri);descndSorsort.ecenr(umers);for(nt= 0;k (scnSortlengh-);k+)deendmbers = eendNmers + dscedortk, ;retun ecendNmber + dsenortesceot.ngt ;pckage eduyu.lab1;pblic clss ortpblcn AcendSt(i arr) /升序排序 or(in ss = 1;ss rra.lengh; ss+) or (int elemet =0;eemen aaeeme+ ) sap(ara,eleen,men + 1); euraray; ubicin Descenor(nara) /降序排序 fr (in pas = 1; pa arra.lt; pass+) or(int elemnt = ;ent (array.eth- 1); elmet+) if (arayemenarayeement +) swap(array,elemet,een+ 1); rtu ay; pulic oid sa(nt arr, nt frt,it secod)/元素移位 thl; hd = arayirst; rrayfis = arraseon; aryson ld; 运营截图:图1 将顾客输入的标点符号和多余的空格转换为一种空格(此为自己所加功能,教师未规定,参照时请清除)图 升序排列图3 降序排列
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 幼儿教育


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!