List of usage examples for javax.swing.event ListSelectionEvent ListSelectionEvent
public ListSelectionEvent(Object source, int firstIndex, int lastIndex, boolean isAdjusting)
From source file:Main.java
public static void addDoubleClickEvent(JList list) { list.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { JList source = (JList) e.getSource(); if (e.getClickCount() == 2) { ListSelectionListener[] listeners = source.getListSelectionListeners(); for (int i = 0; i < listeners.length; i++) { listeners[i].valueChanged(new ListSelectionEvent(source, source.getSelectedIndex(), source.getSelectedIndex(), false)); }/* w w w .j a v a 2 s . co m*/ } } }); }
From source file:blue.automation.ParameterIdList.java
private void fireListSelectionEvent(int index) { if (listSelectionListeners != null && listSelectionListeners.size() > 0) { Iterator iter = new Vector(listSelectionListeners).iterator(); ListSelectionEvent lse = new ListSelectionEvent(this, index, index, false); while (iter.hasNext()) { ListSelectionListener listener = (ListSelectionListener) iter.next(); listener.valueChanged(lse);// w ww. j a v a 2s . c o m } } }
From source file:com.openbravo.pos.sales.JTicketLines.java
/** Creates new form JLinesTicket */ public JTicketLines(AppView app, String propertyRowHeight, String propertyFontsize, String ticketline) { this.m_App = app; initComponents();/*from w w w . ja va 2 s . com*/ m_jTicketTable.m_App = app; m_jTicketTable.propertyRowHeight = propertyRowHeight; ColumnTicket[] acolumns = new ColumnTicket[0]; if (ticketline != null) { try { if (m_sp == null) { SAXParserFactory spf = SAXParserFactory.newInstance(); m_sp = spf.newSAXParser(); } ColumnsHandler columnshandler = new ColumnsHandler(); m_sp.parse(new InputSource(new StringReader(ticketline)), columnshandler); acolumns = columnshandler.getColumns(); } catch (ParserConfigurationException ePC) { logger.log(Level.WARNING, LocalRes.getIntString("exception.parserconfig"), ePC); } catch (SAXException eSAX) { logger.log(Level.WARNING, LocalRes.getIntString("exception.xmlfile"), eSAX); } catch (IOException eIO) { logger.log(Level.WARNING, LocalRes.getIntString("exception.iofile"), eIO); } } Map<String, Integer> widths = PropertyUtil.getTicketLineWidths(m_App); for (ColumnTicket acolumn : acolumns) { Integer width = widths.get(acolumn.name); if (width == null) { continue; } acolumn.width = width; } m_jTableModel = new TicketTableModel(acolumns); m_jTicketTable.setModel(m_jTableModel); m_jTicketTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN); TableColumnModel jColumns = m_jTicketTable.getColumnModel(); for (int i = 0; i < acolumns.length; i++) { jColumns.getColumn(i).setPreferredWidth(acolumns[i].width); jColumns.getColumn(i).setResizable(true); } PropertyUtil.ScaleScrollbar(m_App, m_jScrollTableTicket); m_jTicketTable.getTableHeader().setReorderingAllowed(false); // m_jTicketTable.setDefaultRenderer(Object.class, new // TicketCellRenderer(app, acolumns, propertyFontsize)); m_jTicketTable.setDefaultRenderer(Object.class, new RowHeightCellRenderer(app, acolumns, propertyFontsize, propertyRowHeight)); PropertyUtil.ScaleTableColumnFontsize(m_App, m_jTicketTable, "sales-tablecolumn-fontsize", "14"); m_jTicketTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); m_jTicketTable.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { JTable table = (JTable) me.getSource(); Point p = me.getPoint(); int row = table.rowAtPoint(p); if (me.getClickCount() == 2) { // your valueChanged overridden method listDoubleClickListener.valueChanged(new ListSelectionEvent(m_jTicketTable, row, row, false)); } } }); // reseteo la tabla... m_jTableModel.clear(); }
From source file:edu.ku.brc.af.ui.db.TextFieldWithQuery.java
/** * @param source/*from w ww .jav a 2 s . com*/ */ private void notifyListenersOfChange(final Object source) { if (listSelectionListeners != null) { ListSelectionEvent lse = source == null ? null : new ListSelectionEvent(source, 0, 0, false); for (ListSelectionListener l : listSelectionListeners) { l.valueChanged(lse); } } }
From source file:org.wings.SList.java
/** * This method notifies all ListSelectionListeners that * the selection model has changed.// w w w .ja v a 2 s. co m * * @see #addListSelectionListener * @see #removeListSelectionListener * @see EventListenerList */ protected void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting) { Object[] listeners = getListenerList(); ListSelectionEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ListSelectionListener.class) { if (e == null) { e = new ListSelectionEvent(this, firstIndex, lastIndex, isAdjusting); } ((ListSelectionListener) listeners[i + 1]).valueChanged(e); } } }