[英]JScrollPane not working with JPanel and JFrame
對於我的代碼,我做了類似的事情:
Jframe frame = new JFrame();
JPanel panel = new JPanel();
JButton button = new JButton();
// after locating and resizing buttons...
panel.add(button);
// and after many codes about buttons and labels...
frame.add(panel);
JScrollPane scroll = new JScrollPane(panel);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
frame.add(scroll);
據我所知,這應該是正確的,但我無法滾動。 滾動條內的灰色條丟失。
感謝您的關注和時間! <3
如果您在https://docs.oracle.com/javase/tutorial/uiswing/components/scrollpane.html上閱讀有關滾動窗格的官方教程,他們會注意到這些政策:
VERTICAL_SCROLLBAR_ALWAYS
HORIZONTAL_SCROLLBAR_ALWAYS
始終顯示滾動條。 如果視口足夠大以顯示整個客戶端,則該旋鈕將消失。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.