@@ -43,6 +43,7 @@ import com.intellij.ui.MutableCollectionComboBoxModel
43
43
import com.intellij.ui.SimpleListCellRenderer
44
44
import com.intellij.ui.components.JBLabel
45
45
import com.intellij.ui.components.JBList
46
+ import com.intellij.ui.components.JBScrollPane
46
47
import com.intellij.util.EventDispatcher
47
48
import com.intellij.util.ui.JBEmptyBorder
48
49
import com.intellij.util.ui.JBUI
@@ -166,7 +167,12 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
166
167
inputPanel.add(input, BorderLayout .CENTER )
167
168
inputPanel.addToBottom(layoutPanel)
168
169
169
- this .add(elementsList, BorderLayout .NORTH )
170
+ // 将 elementsList 放入 JScrollPane 中
171
+ val scrollPane = JBScrollPane (elementsList)
172
+ scrollPane.verticalScrollBarPolicy = JScrollPane .VERTICAL_SCROLLBAR_AS_NEEDED
173
+ scrollPane.horizontalScrollBarPolicy = JScrollPane .HORIZONTAL_SCROLLBAR_AS_NEEDED
174
+ this .add(scrollPane, BorderLayout .NORTH )
175
+
170
176
this .add(inputPanel, BorderLayout .CENTER )
171
177
172
178
ComponentValidator (disposable!! ).withValidator(Supplier <ValidationInfo ?> {
@@ -222,6 +228,9 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
222
228
elementsList.cellRenderer = RelatedFileListCellRenderer ()
223
229
elementsList.setEmptyText(" " )
224
230
231
+ // 假设 elementsList 是某个容器的子组件,你需要将 scrollPane 添加到该容器中
232
+ // 例如:parentContainer.add(scrollPane)
233
+
225
234
elementsList.addMouseListener(object : MouseAdapter () {
226
235
override fun mouseClicked (e : MouseEvent ) {
227
236
val list = e.source as JBList <* >
0 commit comments