Editor component added to OnePixelSplitter or JBTabbedPane are not scrollable

I'm creating custom editors to show decompiled/dissassembled code.  I got highlighting and  annotations working using


class Panel(private val definitionsTree: Tree, project: Project): JPanel(GridLayout(1, 1)), TreeSelectionListener {
private val psiFile = PsiFileFactory.getInstance(project).createFileFromText(ElixirLanguage.INSTANCE, DEFAULT_TEXT)
private val document = PsiDocumentManager.getInstance(project).getDocument(psiFile)!!
private val editor = EditorFactory.getInstance().createEditor(document, project, ElixirFileType.INSTANCE, true)

init {
definitionsTree.addTreeSelectionListener(this)
add(editor.component)
}

and

fun component(code: Code?, project: Project): JComponent {
val text = code?.assembly() ?: DEFAULT_TEXT
val psiFile = PsiFileFactory.getInstance(project).createFileFromText(Language, text)
val document = PsiDocumentManager.getInstance(project).getDocument(psiFile)!!
val editor = EditorFactory.getInstance().createEditor(document, project, Type, true)

return editor.component
}


but when I put the first `Panel` in a `OnePixelSplitter`


class Splitter(debugInfo: V1, project: Project): OnePixelSplitter(false) {
init {
val tree = Tree(Model(debugInfo))

firstComponent = JBScrollPane(tree)
secondComponent = Panel(tree, project)
}


or the `component` one as a tab in a `JBTabbedPane` they don't show scrollbars and are not scrollable.  Do I need a special parent container to make `editor.component` be scrollable or do I need to call something to make them scrollable?  The line numbers do show up, so I'm not just using the content component as far as I can tell.

5 comments

At least, the first case works for me. But I created a form in Java.

Could you please provide more details? For example, a full form code, which I can compile and debug.

0

It might have something to do with the nesting: for the Code edtitor, which shows bytecode, it it is added to a tab and that JBTabbedPane is returned from `FileEditor.getComponent`.  If I move the mouse pointer to the very edge of the tab and scroll, I can get the scrollbar to appear and it responds to scrolling, but if I'm in the content of the Code editor, no scrolling happens.

For the docs code viewer in in ExDc tab, the editor is a child of the OnePixelSplitter, which is a child of a JPanel, which is the added the JBTabbedPane.  The ExDc editor also responds to scrolling, but it's scrolling the entire splitter, not just the editor.  The other side of the split is a JTree that I'd want to be scrolled separately, similar to the Structure View vs the normal Editors.

Is there some logic in Swing or the JB* Components that is putting the scroll bar on the outer components and that then suppresses the scrollbar on the inner components where I actually want the scrolling?

0

Ok, so I went through my code and it turned out that I had been wrapping the components in JBScrollPane before adding them to the outer most tabbed pane. I changed my code to only add JBScrollPane when the component is only a Table and now the editor's generate their own scrollbars, so I seems there is something that suppresses scrollbars in the editor if there is an outer scrollbar detected, but it was totally a problem with my code that I was able to fix.

0

It is a bad idea to put one scroll pane into another one, because of usability and event processing.

0

Yes, I know it's a bad idea. I didn't mean to do it.  It was left over as an optimization from a earlier version of the UI when I was adding a scrollpane on the outside of all tab components.  It stopped being true once I had non-table components, but I forgot to got back and remove it and then forgot it was there when I opened this thread.

0

Please sign in to leave a comment.