package free; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import javax.swing.ListSelectionModel; import javax.swing.event.MouseInputAdapter; import javax.swing.event.MouseInputListener; import twaver.Element; import twaver.Group; import twaver.list.TList; public class FreeList extends TList { public FreeList() { init(); } private void init() { this.setFont(FreeUtil.FONT_12_BOLD); this.setForeground(FreeUtil.DEFAULT_TEXT_COLOR); this.setBackground(FreeUtil.LIST_BACKGROUND); this.setCellRenderer(new FreeListRenderer(this)); this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //move mouse, select over item. MouseInputListener mouseListener = new MouseInputAdapter() { @Override public void mouseMoved(MouseEvent e) { Element element = getElementByPoint(e.getPoint()); getDataBox().getSelectionModel().clearSelection(); if (element != null) { //ignore group. if (!(element instanceof Group)) { element.setSelected(true); } } } @Override public void mouseExited(MouseEvent e) { getDataBox().getSelectionModel().clearSelection(); } @Override public void mouseClicked(MouseEvent e) { Element element = getDataBox().getSelectionModel().lastElement(); if (element != null) { if (!(element instanceof Group)) { ActionListener action = (ActionListener) element.getUserObject(); String command = (String) element.getBusinessObject(); if (action != null) { ActionEvent event = new ActionEvent(element, 0, command); action.actionPerformed(event); } } } } }; this.addMouseMotionListener(mouseListener); this.addMouseListener(mouseListener); } }

励志12345 LV3
2024年5月8日
329512801 LV28
2022年1月18日
cd201481 LV1
2020年2月5日
yongzheng132 LV17
2019年6月24日
通天晓 LV10
2019年4月15日
mixiansheng LV6
2018年12月27日
mengfanyun LV9
2018年11月16日
QueenLuxuMissRy LV1
2018年7月31日
applepaihs1 LV1
2018年7月20日
蓝色鸢尾 LV2
2018年7月20日