问题描述
我想将 Jscroll 窗格添加到面板,但是当我将 Jscroll 窗格添加到我的面板时,我的面板的背景会发生变化并变成白色。为什么会这样?
JPanel followingsName=new JPanel();
JScrollPane scrollPane2=new JScrollPane();
scrollPane2.add(followingsName);
scrollPane2.setBounds(430,190,370,250);
scrollPane2.setOpaque(false);
scrollPane2.setViewportView(followingsName);
scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane2.setHorizontalScrollBar(null);
JPanel pp= new JPanel();
pp.setLayout(null);
pp.setBackground(Color.pink);
pp.add(scrollPane2);
JFrame frame=new JFrame();
frame.setLayout(null);
frame.setPreferredSize(new Dimension(900,590));
frame.setSize(frame.getPreferredSize());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setContentPane(pp);
frame.setVisible(true);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)