#List

e792. 建立一个包括所有数据的SpinnerListModel

Bydefault,iftheuserisbrowsingthevaluesinaSpinnerListModel,theiterationstopswheneitherendisreached.Thisexampledemonstratesasubclassthatallowstheusertocontinuousl...

e776. 设置JList组件项的提示语

//Createalist,overridingthegetToolTipText()methodString[]items={"A","B","C","D"};JListlist=newJList(items){//Thismethodiscalledasthecursormoveswithinthelist.pub...

e775. 设置JList组件项的维数

Bydefault,thewidthofthelistisdeterminedbythelongestitemandtheheightisdeterminedbythenumberofvisiblelinesmultipliedbythetallestitem.Thisexampledemonstrateshowtoo...

e781. 设置JList中的选择模式

//ThedefaultmodeisMULTIPLE_INTERVAL_SELECTIONString[]items={"A","B","C","D"};JListlist=newJList(items);//Getthecurrentselectionmodelmodeintmode=list.getSelectio...

e784. 监听对JList选择变动

Whenthesetofselecteditemsischanged,eitherbytheuserorprogrammatically,alistselectioneventisfired.//CreatealistString[]items={"A","B","C","D"};JListlist=newJList(...

e780. 设置JList中的已选项

Listselectioneventsarefiredwhenthefollowingmethodsareusedtochangethesetofselecteditems(seee774创建JList组件).//CreatealistandgetthemodelString[]items={"A","B","C","...

e782. 排列JList中的项

Bydefault,theitemsinalistarearrangedvertically,inasinglecolumn,asin:item1item2...Itispossibletoarrangetheitemsleft-to-rightandtop-to-bottom,asin:item1item2item3...
代码星球 ·2021-02-12

e779. 获得JList中的已选项

Thefollowingmethodsreturntheindicesoftheselecteditems://Tocreatealist,seee774创建JList组件//Gettheindexofalltheselecteditemsint[]selectedIx=list.getSelectedIndices(...

e777. 获得JList组件的所有项

//CreatealistString[]items={"A","B","C","D"};JListlist=newJList(items);//Getnumberofitemsinthelistintsize=list.getModel().getSize();//4//Getallitemobjectsfor(in...

e783. 监听对JList中项双击和三击

//CreatealistString[]items={"A","B","C","D"};JListlist=newJList(items);//Addalistenerformouseclickslist.addMouseListener(newMouseAdapter(){publicvoidmouseClicke...

e785. 监听JList中项的变动

Whenthesetofitemsinalistcomponentischanged,alistdataeventisfired.//Createalistthatallowsaddsandremoves;//seee778在JList中加入和删除项//RegisteralistdatalistenerDefaultL...

e778. 在JList中加入和删除项

Thedefaultmodelforalistdoesnotallowtheadditionandremovalofitems.ThelistmustbecreatedwithaDefaultListModel.//CreatealistthatallowsaddsandremovesDefaultListModelm...
代码星球 ·2021-02-12

e774. 创建JList组件

Bydefault,alistallowsmorethanoneitemtobeselected.Also,theselecteditemsneednotbecontiguous.Tochangethisdefault,seee781设置JList中的选择模式.Alistselectioneventisfiredwhe...
代码星球 ·2021-02-12

e609. Listening to All Focus Changes Between Components in an Application

Tolistentofocuschangeeventsbetweencomponents,installalistenerwiththekeyboardfocusmanager.Ifyouneedtheabilitytoveto(reject)afocuschange,installavetoablelistenerw...

e636. Listening to All Key Events Before Delivery to Focused Component

Registeringakeyeventdispatcherwiththekeyboardfocusmanagerallowsyoutoseeallkeyeventsbeforetheyaresenttothefocusedcomponent.Itispossibletomodifytheeventorevenprev...
代码星球 ·2021-02-12
首页上一页...2223242526...下一页尾页