tab与list配合使用
生活随笔
收集整理的這篇文章主要介紹了
tab与list配合使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
tab與list配合使用會使效果增添不少,可是在之前沒有接觸過此框架的要做到很好卻是有點小難度,以下就按我在開發過程中遇到的問題,一一羅列出來,并附上解決的方法。
如圖:
?? ? ? ? ??
?
問題一:首先我從登陸窗體進入時,我不希望每個Tab選項卡中的List中都去服務器取數據,這樣會導致加載時間過長導致用戶等待過久,因為Tab是在窗體初始化的時候就要把List中的數據添加進去,如果要分別加載數據則在tab事件中必須重新加載之前的數據。
解決方法:此問題的關鍵是Container的使用,我們可以為每個選項卡添加一個Container,然后觸發tab事件時我們改變的只是Container中的數據及控件,所以這樣最完美了解決了存在的問題,創建list的代碼就不重復了,需要請看這里。
?
?? ? ? ?//?個人郵件
?? ? ? ?String[][]?mailPersonal?=?GetMailPersonal();
?? ? ? ?MailInfo[]?mailInfoPersonal?=?GetMainInfoArrary(mailPersonal,?true);
?? ? ? ?containerPersonal?=?new?Container();
?? ? ? ?containerPersonal.setLayout(new?BoxLayout(BoxLayout.Y_AXIS));
?? ? ? ?if?(mailInfoPersonal?!=?null)
?? ? ? ? ? ?containerPersonal.addComponent(createList(mailInfoPersonal,
?? ? ? ? ? ? ? ? ? ?List.VERTICAL,?new?ContactsRenderer()));
?? ? ? ?else?{
?? ? ? ? ? ?Label?label?=?new?Label("您的個人郵件沒有數據!");
?? ? ? ? ? ?containerPersonal.getStyle().setMargin(Component.TOP,?60);
?? ? ? ? ? ?containerPersonal.setLayout(new?FlowLayout(Component.CENTER));
?? ? ? ? ? ?containerPersonal.addComponent(label);
?? ? ? ?}
?? ? ? ?tab.addTab("個人郵件",?getRes().getImage("SJX.gif"),?containerPersonal);
?? ? ? ?//?群發郵件,未加載數據賦空數值
?? ? ? ?String[][]?mailGroup?=?{?{?"正在加載",?"",?"",?"",?"",?"",?""?}?};
?? ? ? ?MailInfo[]?mailInfoGroup?=?GetMainInfoArrary(mailGroup,?false);
?? ? ? ?final?Container?ContainerGroup?=?new?Container();
?? ? ? ?ContainerGroup.setLayout(new?BoxLayout(BoxLayout.Y_AXIS));
?? ? ? ?ContainerGroup.addComponent(createList(mailInfoGroup,?List.VERTICAL,
?? ? ? ? ? ? ? ?new?ContactsRenderer()));
?? ? ? ?tab.addTab("群發郵件",?getRes().getImage("SJX.gif"),?ContainerGroup);
?? ? ? ?//?保留郵件,未加載數據賦空數值
?? ? ? ?String[][]?mailSave?=?{?{?"正在加載",?"",?"",?"",?"",?"",?""?}?};
?? ? ? ?MailInfo[]?mailInfoSave?=?GetMainInfoArrary(mailSave,?true);
?? ? ? ?final?Container?ContainerSave?=?new?Container();
?? ? ? ?ContainerSave.setLayout(new?BoxLayout(BoxLayout.Y_AXIS));
?? ? ? ?ContainerSave.addComponent(createList(mailInfoSave,?List.VERTICAL,
?? ? ? ? ? ? ? ?new?ContactsRenderer()));
?? ? ? ?tab.addTab("保留郵件",?getRes().getImage("SJX.gif"),?ContainerSave);
?? ? ? ?//?發件箱,未加載數據賦空數值
?? ? ? ?String[][]?mailSend?=?{?{?"正在加載",?"",?"",?"",?"",?"",?""?}?};
?? ? ? ?MailInfo[]?mailInfoSend?=?GetMainInfoArrary(mailSend,?true);
?? ? ? ?final?Container?ContainerSend?=?new?Container();
?? ? ? ?ContainerSend.setLayout(new?BoxLayout(BoxLayout.Y_AXIS));
?? ? ? ?ContainerSend.addComponent(createList(mailInfoSend,?List.VERTICAL,
?? ? ? ? ? ? ? ?new?ContactsRenderer()));
?? ? ? ?tab.addTab("發件箱",?getRes().getImage("SJX.gif"),?ContainerSend);
?? ? ? ?tab.setTabPlacement(TabbedPane.TOP);
?? ? ? ?addComponent(BorderLayout.CENTER,?tab);
?? ? ? ?//?tab事件,觸發時請求數據并向Container添加已經填充好數據的list
?? ? ? ?tab.addTabsListener(new?SelectionListener()?{
?? ? ? ? ? ?public?void?selectionChanged(int?oldSelected,?int?newSelected)?{
?? ? ? ? ? ? ? ?int?indexvalue?=?tab.getSelectedIndex();
?? ? ? ? ? ? ? ?if?(indexvalue?==?1?&&?flagGroup?==?0)?{
?? ? ? ? ? ? ? ? ? ?Global.GetWaitCursor("正在轉到群發郵件,請稍候",?FormFactory
?? ? ? ? ? ? ? ? ? ? ? ? ? ?.getInstance().getMailForm());
?? ? ? ? ? ? ? ? ? ?new?Thread()?{
?? ? ? ? ? ? ? ? ? ? ? ?public?void?run()?{
?? ? ? ? ? ? ? ? ? ? ? ? ? ?String[][]?mailGroup?=?GetMailGroup();
?? ? ? ? ? ? ? ? ? ? ? ? ? ?flagGroup?=?1;
?? ? ? ? ? ? ? ? ? ? ? ? ? ?LoadDataAgain(ContainerGroup,?"您的群發郵件沒有數據!",
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailGroup,?false);
?? ? ? ? ? ? ? ? ? ? ? ? ? ?FormFactory.getInstance().getMailForm().show();
?? ? ? ? ? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ? ? ?}.start();
?? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ?if?(indexvalue?==?2?&&?flagSave?==?0)?{
?? ? ? ? ? ? ? ? ? ?Global.GetWaitCursor("正在轉到保留郵件,請稍候",?FormFactory
?? ? ? ? ? ? ? ? ? ? ? ? ? ?.getInstance().getMailForm());
?? ? ? ? ? ? ? ? ? ?new?Thread()?{
?? ? ? ? ? ? ? ? ? ? ? ?public?void?run()?{
?? ? ? ? ? ? ? ? ? ? ? ? ? ?String[][]?mailSave?=?GetMailSave();
?? ? ? ? ? ? ? ? ? ? ? ? ? ?flagSave?=?1;
?? ? ? ? ? ? ? ? ? ? ? ? ? ?LoadDataAgain(ContainerSave,?"您的保留郵件沒有任何數據!",
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailSave,?true);
?? ? ? ? ? ? ? ? ? ? ? ? ? ?FormFactory.getInstance().getMailForm().show();
?? ? ? ? ? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ? ? ?}.start();
?? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ?if?(indexvalue?==?3?&&?flagSend?==?0)?{
?? ? ? ? ? ? ? ? ? ?Global.GetWaitCursor("正在轉到發件箱,請稍候",?FormFactory
?? ? ? ? ? ? ? ? ? ? ? ? ? ?.getInstance().getMailForm());
?? ? ? ? ? ? ? ? ? ?new?Thread()?{
?? ? ? ? ? ? ? ? ? ? ? ?public?void?run()?{
?? ? ? ? ? ? ? ? ? ? ? ? ? ?String[][]?mailSend?=?GetMailSend();
?? ? ? ? ? ? ? ? ? ? ? ? ? ?flagSend?=?1;
?? ? ? ? ? ? ? ? ? ? ? ? ? ?LoadDataAgain(ContainerSend,?"您的發件箱沒有任何數據!",
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailSend,?true);
?? ? ? ? ? ? ? ? ? ? ? ? ? ?FormFactory.getInstance().getMailForm().show();
?? ? ? ? ? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ? ? ?}.start();
?? ? ? ? ? ? ? ?}
?? ? ? ? ? ?}
?? ? ? ?});
?? ? ? ?//將指定的Container添加上List
?? ?private?void?LoadDataAgain(Container?containner,?String?Labelstring,
?? ? ? ? ? ?String[][]?mail,?boolean?bolvalue)?{
?? ? ? ?MailInfo[]?mailInfo?=?GetMainInfoArrary(mail,?bolvalue);
?? ? ? ?containner.removeAll();
?? ? ? ?if?(mailInfo?!=?null)
?? ? ? ? ? ?containner.addComponent(createList(mailInfo,?List.VERTICAL,
?? ? ? ? ? ? ? ? ? ?new?ContactsRenderer()));
?? ? ? ?else?{
?? ? ? ? ? ?Label?label?=?new?Label(Labelstring);
?? ? ? ? ? ?containner.getStyle().setMargin(Component.TOP,?60);
?? ? ? ? ? ?containner.setLayout(new?FlowLayout(Component.CENTER));
?? ? ? ? ? ?containner.addComponent(label);
?? ? ? ?}
?? ?}
問題二:獲取選中的List列中的數據,這是普遍會遇到的難題,如果你單單是用手機中間鍵觸發的話,或許比較簡單,但是如果在菜單按鈕上也要增加此獲取list列表的數據,就會比較麻煩,不過麻煩都過去了。
解決辦法:通過list的獲取焦點失去焦點還有選擇焦點,設置全局變量來獲取list中綁定的屬性值。
?
?
?? ? ? ?//?list列表選擇焦點監聽事件
?? ? ? ? ? ? ? ?list.addSelectionListener(new?SelectionListener()?{
?? ? ? ? ? ?public?void?selectionChanged(int?oldSelected,?int?newSelected)?{
?? ? ? ? ? ? ? ?globalStrMailGuid?=?MainInfos[newSelected].fid;
?? ? ? ? ? ?}
?? ? ? ?});
?? ? ? ?list.addFocusListener(new?FocusListener()?{
?? ? ? ? ? ?//?list獲得焦點
?? ? ? ? ? ?public?void?focusGained(Component?cmp)?{
?? ? ? ? ? ? ? ?globalStrMailGuid?=?MainInfos[list.getSelectedIndex()].fid;
?? ? ? ? ? ?}
?? ? ? ? ? ?//?list失去焦點
?? ? ? ? ? ?public?void?focusLost(Component?cmp)?{
?? ? ? ? ? ? ? ?globalStrMailGuid?=?"";
?? ? ? ? ? ?}
?? ? ? ?});
list.addActionListener(new?ActionListener()?{
?? ? ? ? ? ?public?void?actionPerformed(final?ActionEvent?evt)?{
?? ? ? ? ? ? ? ?//觸發列表中的列的時候你所要做的事情。。。
?? ? ? ? ? ?}
?? ? ? ?});
問題三:選中狀態的調整,如果沒有調整的話,你會發現list放到Tab后,選中狀態跟綁定的數據會慢了一拍,也就是你選在第二條而數據卻是第一條的。
解決辦法:設置一全局變量,getListFocusComponent做下更改即可,代碼如下。
?
?? ? ? ? ? ?//創建list中的getListFocusComponent中添加此if語句。 ? ?
?? ? ? ? ? ? ? ?public?Component?getListFocusComponent(final?List?list)?{
?? ? ? ? ? ?if?(globalselect?==?1)
?? ? ? ? ? ? ? ?return?focus;
?? ? ? ? ? ?else
?? ? ? ? ? ? ? ?return?null;
?? ? ? ?}
?? ? ? ? ? ? ? ?//也就是list獲得焦點的時候才返回focus選中狀態,否則返回null
?? ? ? ?list.addFocusListener(new?FocusListener()?{
?? ? ? ? ? ?//?list獲得焦點
?? ? ? ? ? ?public?void?focusGained(Component?cmp)?{
?? ? ? ? ? ? ? ?globalselect?=?1;
?? ? ? ? ? ?}
?? ? ? ? ? ?//?list失去焦點
?? ? ? ? ? ?public?void?focusLost(Component?cmp)?{
?? ? ? ? ? ? ? ?globalselect?=?0;
?? ? ? ? ? ?}
?? ? ? ?});
這三點是比較大的問題所在,其他的還有一些可能會比較好解決就不列出來了。
如圖:
?? ? ? ? ??
?
問題一:首先我從登陸窗體進入時,我不希望每個Tab選項卡中的List中都去服務器取數據,這樣會導致加載時間過長導致用戶等待過久,因為Tab是在窗體初始化的時候就要把List中的數據添加進去,如果要分別加載數據則在tab事件中必須重新加載之前的數據。
解決方法:此問題的關鍵是Container的使用,我們可以為每個選項卡添加一個Container,然后觸發tab事件時我們改變的只是Container中的數據及控件,所以這樣最完美了解決了存在的問題,創建list的代碼就不重復了,需要請看這里。
?
?? ? ? ?//?個人郵件
?? ? ? ?String[][]?mailPersonal?=?GetMailPersonal();
?? ? ? ?MailInfo[]?mailInfoPersonal?=?GetMainInfoArrary(mailPersonal,?true);
?? ? ? ?containerPersonal?=?new?Container();
?? ? ? ?containerPersonal.setLayout(new?BoxLayout(BoxLayout.Y_AXIS));
?? ? ? ?if?(mailInfoPersonal?!=?null)
?? ? ? ? ? ?containerPersonal.addComponent(createList(mailInfoPersonal,
?? ? ? ? ? ? ? ? ? ?List.VERTICAL,?new?ContactsRenderer()));
?? ? ? ?else?{
?? ? ? ? ? ?Label?label?=?new?Label("您的個人郵件沒有數據!");
?? ? ? ? ? ?containerPersonal.getStyle().setMargin(Component.TOP,?60);
?? ? ? ? ? ?containerPersonal.setLayout(new?FlowLayout(Component.CENTER));
?? ? ? ? ? ?containerPersonal.addComponent(label);
?? ? ? ?}
?? ? ? ?tab.addTab("個人郵件",?getRes().getImage("SJX.gif"),?containerPersonal);
?? ? ? ?//?群發郵件,未加載數據賦空數值
?? ? ? ?String[][]?mailGroup?=?{?{?"正在加載",?"",?"",?"",?"",?"",?""?}?};
?? ? ? ?MailInfo[]?mailInfoGroup?=?GetMainInfoArrary(mailGroup,?false);
?? ? ? ?final?Container?ContainerGroup?=?new?Container();
?? ? ? ?ContainerGroup.setLayout(new?BoxLayout(BoxLayout.Y_AXIS));
?? ? ? ?ContainerGroup.addComponent(createList(mailInfoGroup,?List.VERTICAL,
?? ? ? ? ? ? ? ?new?ContactsRenderer()));
?? ? ? ?tab.addTab("群發郵件",?getRes().getImage("SJX.gif"),?ContainerGroup);
?? ? ? ?//?保留郵件,未加載數據賦空數值
?? ? ? ?String[][]?mailSave?=?{?{?"正在加載",?"",?"",?"",?"",?"",?""?}?};
?? ? ? ?MailInfo[]?mailInfoSave?=?GetMainInfoArrary(mailSave,?true);
?? ? ? ?final?Container?ContainerSave?=?new?Container();
?? ? ? ?ContainerSave.setLayout(new?BoxLayout(BoxLayout.Y_AXIS));
?? ? ? ?ContainerSave.addComponent(createList(mailInfoSave,?List.VERTICAL,
?? ? ? ? ? ? ? ?new?ContactsRenderer()));
?? ? ? ?tab.addTab("保留郵件",?getRes().getImage("SJX.gif"),?ContainerSave);
?? ? ? ?//?發件箱,未加載數據賦空數值
?? ? ? ?String[][]?mailSend?=?{?{?"正在加載",?"",?"",?"",?"",?"",?""?}?};
?? ? ? ?MailInfo[]?mailInfoSend?=?GetMainInfoArrary(mailSend,?true);
?? ? ? ?final?Container?ContainerSend?=?new?Container();
?? ? ? ?ContainerSend.setLayout(new?BoxLayout(BoxLayout.Y_AXIS));
?? ? ? ?ContainerSend.addComponent(createList(mailInfoSend,?List.VERTICAL,
?? ? ? ? ? ? ? ?new?ContactsRenderer()));
?? ? ? ?tab.addTab("發件箱",?getRes().getImage("SJX.gif"),?ContainerSend);
?? ? ? ?tab.setTabPlacement(TabbedPane.TOP);
?? ? ? ?addComponent(BorderLayout.CENTER,?tab);
?? ? ? ?//?tab事件,觸發時請求數據并向Container添加已經填充好數據的list
?? ? ? ?tab.addTabsListener(new?SelectionListener()?{
?? ? ? ? ? ?public?void?selectionChanged(int?oldSelected,?int?newSelected)?{
?? ? ? ? ? ? ? ?int?indexvalue?=?tab.getSelectedIndex();
?? ? ? ? ? ? ? ?if?(indexvalue?==?1?&&?flagGroup?==?0)?{
?? ? ? ? ? ? ? ? ? ?Global.GetWaitCursor("正在轉到群發郵件,請稍候",?FormFactory
?? ? ? ? ? ? ? ? ? ? ? ? ? ?.getInstance().getMailForm());
?? ? ? ? ? ? ? ? ? ?new?Thread()?{
?? ? ? ? ? ? ? ? ? ? ? ?public?void?run()?{
?? ? ? ? ? ? ? ? ? ? ? ? ? ?String[][]?mailGroup?=?GetMailGroup();
?? ? ? ? ? ? ? ? ? ? ? ? ? ?flagGroup?=?1;
?? ? ? ? ? ? ? ? ? ? ? ? ? ?LoadDataAgain(ContainerGroup,?"您的群發郵件沒有數據!",
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailGroup,?false);
?? ? ? ? ? ? ? ? ? ? ? ? ? ?FormFactory.getInstance().getMailForm().show();
?? ? ? ? ? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ? ? ?}.start();
?? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ?if?(indexvalue?==?2?&&?flagSave?==?0)?{
?? ? ? ? ? ? ? ? ? ?Global.GetWaitCursor("正在轉到保留郵件,請稍候",?FormFactory
?? ? ? ? ? ? ? ? ? ? ? ? ? ?.getInstance().getMailForm());
?? ? ? ? ? ? ? ? ? ?new?Thread()?{
?? ? ? ? ? ? ? ? ? ? ? ?public?void?run()?{
?? ? ? ? ? ? ? ? ? ? ? ? ? ?String[][]?mailSave?=?GetMailSave();
?? ? ? ? ? ? ? ? ? ? ? ? ? ?flagSave?=?1;
?? ? ? ? ? ? ? ? ? ? ? ? ? ?LoadDataAgain(ContainerSave,?"您的保留郵件沒有任何數據!",
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailSave,?true);
?? ? ? ? ? ? ? ? ? ? ? ? ? ?FormFactory.getInstance().getMailForm().show();
?? ? ? ? ? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ? ? ?}.start();
?? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ?if?(indexvalue?==?3?&&?flagSend?==?0)?{
?? ? ? ? ? ? ? ? ? ?Global.GetWaitCursor("正在轉到發件箱,請稍候",?FormFactory
?? ? ? ? ? ? ? ? ? ? ? ? ? ?.getInstance().getMailForm());
?? ? ? ? ? ? ? ? ? ?new?Thread()?{
?? ? ? ? ? ? ? ? ? ? ? ?public?void?run()?{
?? ? ? ? ? ? ? ? ? ? ? ? ? ?String[][]?mailSend?=?GetMailSend();
?? ? ? ? ? ? ? ? ? ? ? ? ? ?flagSend?=?1;
?? ? ? ? ? ? ? ? ? ? ? ? ? ?LoadDataAgain(ContainerSend,?"您的發件箱沒有任何數據!",
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailSend,?true);
?? ? ? ? ? ? ? ? ? ? ? ? ? ?FormFactory.getInstance().getMailForm().show();
?? ? ? ? ? ? ? ? ? ? ? ?}
?? ? ? ? ? ? ? ? ? ?}.start();
?? ? ? ? ? ? ? ?}
?? ? ? ? ? ?}
?? ? ? ?});
?? ? ? ?//將指定的Container添加上List
?? ?private?void?LoadDataAgain(Container?containner,?String?Labelstring,
?? ? ? ? ? ?String[][]?mail,?boolean?bolvalue)?{
?? ? ? ?MailInfo[]?mailInfo?=?GetMainInfoArrary(mail,?bolvalue);
?? ? ? ?containner.removeAll();
?? ? ? ?if?(mailInfo?!=?null)
?? ? ? ? ? ?containner.addComponent(createList(mailInfo,?List.VERTICAL,
?? ? ? ? ? ? ? ? ? ?new?ContactsRenderer()));
?? ? ? ?else?{
?? ? ? ? ? ?Label?label?=?new?Label(Labelstring);
?? ? ? ? ? ?containner.getStyle().setMargin(Component.TOP,?60);
?? ? ? ? ? ?containner.setLayout(new?FlowLayout(Component.CENTER));
?? ? ? ? ? ?containner.addComponent(label);
?? ? ? ?}
?? ?}
問題二:獲取選中的List列中的數據,這是普遍會遇到的難題,如果你單單是用手機中間鍵觸發的話,或許比較簡單,但是如果在菜單按鈕上也要增加此獲取list列表的數據,就會比較麻煩,不過麻煩都過去了。
解決辦法:通過list的獲取焦點失去焦點還有選擇焦點,設置全局變量來獲取list中綁定的屬性值。
?
?
?? ? ? ?//?list列表選擇焦點監聽事件
?? ? ? ? ? ? ? ?list.addSelectionListener(new?SelectionListener()?{
?? ? ? ? ? ?public?void?selectionChanged(int?oldSelected,?int?newSelected)?{
?? ? ? ? ? ? ? ?globalStrMailGuid?=?MainInfos[newSelected].fid;
?? ? ? ? ? ?}
?? ? ? ?});
?? ? ? ?list.addFocusListener(new?FocusListener()?{
?? ? ? ? ? ?//?list獲得焦點
?? ? ? ? ? ?public?void?focusGained(Component?cmp)?{
?? ? ? ? ? ? ? ?globalStrMailGuid?=?MainInfos[list.getSelectedIndex()].fid;
?? ? ? ? ? ?}
?? ? ? ? ? ?//?list失去焦點
?? ? ? ? ? ?public?void?focusLost(Component?cmp)?{
?? ? ? ? ? ? ? ?globalStrMailGuid?=?"";
?? ? ? ? ? ?}
?? ? ? ?});
list.addActionListener(new?ActionListener()?{
?? ? ? ? ? ?public?void?actionPerformed(final?ActionEvent?evt)?{
?? ? ? ? ? ? ? ?//觸發列表中的列的時候你所要做的事情。。。
?? ? ? ? ? ?}
?? ? ? ?});
問題三:選中狀態的調整,如果沒有調整的話,你會發現list放到Tab后,選中狀態跟綁定的數據會慢了一拍,也就是你選在第二條而數據卻是第一條的。
解決辦法:設置一全局變量,getListFocusComponent做下更改即可,代碼如下。
?
?? ? ? ? ? ?//創建list中的getListFocusComponent中添加此if語句。 ? ?
?? ? ? ? ? ? ? ?public?Component?getListFocusComponent(final?List?list)?{
?? ? ? ? ? ?if?(globalselect?==?1)
?? ? ? ? ? ? ? ?return?focus;
?? ? ? ? ? ?else
?? ? ? ? ? ? ? ?return?null;
?? ? ? ?}
?? ? ? ? ? ? ? ?//也就是list獲得焦點的時候才返回focus選中狀態,否則返回null
?? ? ? ?list.addFocusListener(new?FocusListener()?{
?? ? ? ? ? ?//?list獲得焦點
?? ? ? ? ? ?public?void?focusGained(Component?cmp)?{
?? ? ? ? ? ? ? ?globalselect?=?1;
?? ? ? ? ? ?}
?? ? ? ? ? ?//?list失去焦點
?? ? ? ? ? ?public?void?focusLost(Component?cmp)?{
?? ? ? ? ? ? ? ?globalselect?=?0;
?? ? ? ? ? ?}
?? ? ? ?});
這三點是比較大的問題所在,其他的還有一些可能會比較好解決就不列出來了。
轉載于:https://blog.51cto.com/zhaohaiyang/435619
總結
以上是生活随笔為你收集整理的tab与list配合使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网站性能优化之应用程序缓存-初篇
- 下一篇: Events are a bad ide