Web27 apr. 2012 · JList with JButtons and JPanel with JButtons or for scrolling to the decision Point or Rectangle there exists the method scrollRectToVisible e.g. myPanel.scrollRectToVisible (myButton.getBounds ()); Share Improve this answer Follow edited May 23, 2024 at 11:53 Community Bot 1 1 answered Apr 27, 2012 at 7:47 … WebFor instance, if you create a JList in a JScrollPane (no horiz scrollbar) with a single String "Foo", you would expect the horizontal size of the list to be enough to exactly accommodate the String "Foo". If you now add the string "FooBar" to the model, you would expect the preferred size to immediately report a size that accommodates "FooBar".
java - java-SWING-在此之后保存數據。 - 堆棧內存溢出
Web29 nov. 2012 · The list is already contained inside the scrollpane, so you must not add the list to the main panel. Only the scroll pane. Another thing you're doing wrong is not using a layout manager, and setting the bounds and sizes of your components. Don't do that. Let the layout manager position and size the components for you. Web20 dec. 2012 · The JScrollPane must be added to the panel and the JList must be added to the ScrollPane for it to work. There's really no need to use setBounds or setPreferredSize - get rid of them. JList takes care of all that when you call the setVisibleRowCount method. Here's an example of your ScrollPane working. growing grass in the desert
JList and ListSelectionListener Java Swing Tutorial #22
Web简介. JList 类是一个显示对象列表并允许用户选择一个或多个项目的组件。 一个单独的模型 ListModel 维护列表的内容。 类声明. 以下是 javax.swing.JList 类的声明 −. public class JList extends JComponent implements Scrollable, Accessible Web25 feb. 2014 · IF you REALLY want more control, you should take a look at the Scrollable interface that JList implements, but even then, I'd be careful. Share. Improve this answer. Follow answered Feb 24, 2014 at 23:26. MadProgrammer MadProgrammer. 341k 22 22 gold badges 228 228 silver badges 360 360 bronze badges. WebJList doesn't implement scrolling directly. To create a list that scrolls, make it the viewport view of a JScrollPane. For example: JScrollPane scrollPane = new JScrollPane (myList); // Or in two steps: JScrollPane scrollPane = new JScrollPane (); scrollPane.getViewport ().setView (myList); growing grass in south carolina