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

The following examples show how to use javax.swing.JScrollPane#setRowHeader() . 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: InternalSourceViewerComponent.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public InternalSourceViewerComponent(String text, int offset, int endOffset, InternalSourceAppearance appearance) {
    super(new BorderLayout());
    
    sourceArea = new SourceArea();
    
    this.appearance = appearance;
    appearance.addListener(this);
    propertyChange(null);
    
    sourceArea.setText(text);
    setOffset(offset, endOffset);
    
    lineNumbersPanel = new JPanel(new BorderLayout());
    lineNumbersPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 10));
    lineNumbers = new LineNumbers(sourceArea);
    lineNumbersPanel.add(lineNumbers, BorderLayout.EAST);
    
    lineNumbersViewport = new JViewport();
    lineNumbersViewport.setView(lineNumbersPanel);
    lineNumbersViewport.setPreferredSize(lineNumbersPanel.getPreferredSize());
    
    JScrollPane scrollPane = new JScrollPane(sourceArea);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    scrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    scrollPane.setRowHeader(lineNumbersViewport);
    
    add(scrollPane, BorderLayout.CENTER);
}
 
Example 2
Source File: TableUtil.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
/**
 * Creates row header for table with row number (starting with 1) displayed.
 */
public static void removeRowHeader(JTable table) {
    Container p = table.getParent();
    if (p instanceof JViewport) {
        Container gp = p.getParent();
        if (gp instanceof JScrollPane) {
            JScrollPane scrollPane = (JScrollPane) gp;
            scrollPane.setRowHeader(null);
        }
    }
}
 
Example 3
Source File: NbEditorUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void processSideBars(Map sideBars, JComponent ec, JScrollPane scroller) {
        // Remove all existing sidebars
        ec.removeAll();

        // Add the scroller and the new sidebars
        ec.add(scroller);
        scroller.setRowHeader(null);
        scroller.setColumnHeaderView(null);
//        final MouseDispatcher mouse = new MouseDispatcher((JTextComponent) ec.getClientProperty(JTextComponent.class));
        for (Iterator entries = sideBars.entrySet().iterator(); entries.hasNext(); ) {
            Map.Entry entry = (Map.Entry) entries.next();
            SideBarPosition position = (SideBarPosition) entry.getKey();
            JComponent sideBar = (JComponent) entry.getValue();
            
//            if (position.getPosition() == SideBarPosition.WEST) {
//                JPanel p = new JPanel(new BorderLayout()) {
//
//                    @Override
//                    public void addNotify() {
//                        super.addNotify();
//                        infiltrateContainer(this, mouse, true);
//                    }
//
//                    @Override
//                    public void removeNotify() {
//                        infiltrateContainer(this, mouse, false);
//                        super.removeNotify();
//                    }
//
//                };
//                p.add(sideBar, BorderLayout.CENTER);
//                sideBar = p;
//            }
            
            if (position.isScrollable()) {
                if (position.getPosition() == SideBarPosition.WEST) {
                    scroller.setRowHeaderView(sideBar);
                } else {
                    if (position.getPosition() == SideBarPosition.NORTH) {
                        scroller.setColumnHeaderView(sideBar);
                    } else {
                        throw new IllegalArgumentException("Unsupported side bar position, scrollable = true, position=" + position.getBorderLayoutPosition()); // NOI18N
                    }
                }
            } else {
                ec.add(sideBar, position.getBorderLayoutPosition());
            }
        }
    }