Java Code Examples for javax.swing.JScrollPane#getComponent()

The following examples show how to use javax.swing.JScrollPane#getComponent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogTopComponent.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void tabPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tabPaneStateChanged

        JScrollPane sPane = (JScrollPane) tabPane.getSelectedComponent();
        if (sPane != null) {

            JViewport view = (JViewport) sPane.getComponent(0);
            selectedTable = (JTable) view.getView();

            // re-apply the filter to the current tab
            if (selectedTable.getRowSorter() != null) {
                ((TableRowSorter) selectedTable.getRowSorter()).sort();
            }

            if (tabManagers != null) {

                // Remove all toggle button listeners
                for (ChangeListener l : autoScrollToggleButton.getChangeListeners()) {

                    autoScrollToggleButton.removeChangeListener(l);
                }

                LogTableManager manager = tabManagers.get(tabPane.getSelectedIndex());

                // Add current listener
                autoScrollToggleButton.addChangeListener(manager);

                // Refresh buttons
                autoScrollToggleButton.setSelected(manager.isAutoFollowScroll());
            }
        }
    }
 
Example 2
Source File: MainView.java    From HiJson with Apache License 2.0 5 votes vote down vote up
private JTextArea getTextArea(){
    int selIndex = getTabIndex();
    if(selIndex >= 0){
        TabData selTabData = tabDataModel.getTab(selIndex);
        JSplitPane selSplitPane = (JSplitPane)selTabData.getComponent();
        JScrollPane sp = (JScrollPane)selSplitPane.getLeftComponent();
        JViewport vp = (JViewport)sp.getComponent(0);
        JTextArea ta = (JTextArea)vp.getComponent(0);
        return ta;
    }
    return null;
}
 
Example 3
Source File: MainView.java    From HiJson with Apache License 2.0 5 votes vote down vote up
private JTree getTree(TabData tabData){
    if(tabData==null){
        return null;
    }
    JSplitPane selSplitPane = (JSplitPane)tabData.getComponent();
    JSplitPane rightSplitPane = (JSplitPane)selSplitPane.getRightComponent();
    JScrollPane sp = (JScrollPane)rightSplitPane.getLeftComponent();
    JViewport vp = (JViewport)sp.getComponent(0);
    JTree t = (JTree)vp.getComponent(0);
    return t;
}
 
Example 4
Source File: MainView.java    From HiJson with Apache License 2.0 5 votes vote down vote up
private JTable getTable(int tabIndex){
    if(tabIndex >= 0){
        TabData selTabData = tabDataModel.getTab(tabIndex);
        JSplitPane selSplitPane = (JSplitPane)selTabData.getComponent();
        JSplitPane rightSplitPane = (JSplitPane)selSplitPane.getRightComponent();
        JScrollPane sp = (JScrollPane)rightSplitPane.getRightComponent();
        JViewport vp = (JViewport)sp.getComponent(0);
        JTable t = (JTable)vp.getComponent(0);
        return t;
    }
    return null;
}