Example usage for javax.swing JTable getMouseListeners

List of usage examples for javax.swing JTable getMouseListeners

Introduction

In this page you can find the example usage for javax.swing JTable getMouseListeners.

Prototype

public synchronized MouseListener[] getMouseListeners() 

Source Link

Document

Returns an array of all the mouse listeners registered on this component.

Usage

From source file:nl.xs4all.home.freekdb.b52reader.gui.MainGuiTest.java

private void testClickInTable(boolean firstStarred, boolean firstRead, boolean spanTable, boolean selectRow,
        int xMouseEvent) throws InterruptedException, InvocationTargetException {
    List<Article> testArticles = TestUtilities.getSixTestArticles();
    testArticles.get(0).setStarred(firstStarred);
    testArticles.get(0).setRead(firstRead);

    MainGui mainGui = new MainGui(mockManyBrowsersPanel);
    mainGui.setMainCallbacks(mockMainCallbacks);

    Mockito.when(mockConfiguration.useSpanTable()).thenReturn(spanTable);

    mainGui.initializeBackgroundBrowsersPanel(mockFrame, mockConfiguration);
    mainGui.initializeGui(testArticles);

    waitForGuiTasks();//from   w w  w  .  ja va 2s  . c o  m

    JTable table = (JTable) findComponent(mockContentPane, JTable.class);
    assertNotNull(table);

    if (selectRow) {
        table.getSelectionModel().setValueIsAdjusting(true);
        table.getSelectionModel().setSelectionInterval(1, 1);
        table.getSelectionModel().setValueIsAdjusting(true);
        table.getSelectionModel().setSelectionInterval(0, 0);
    } else {
        table.getSelectionModel().setValueIsAdjusting(true);
        table.clearSelection();
    }

    MouseEvent mouseEvent = new MouseEvent(table, 123456, new Date().getTime(), 0, xMouseEvent, 10, 1, false);

    for (MouseListener mouseListener : table.getMouseListeners()) {
        mouseListener.mouseClicked(mouseEvent);
    }
}