I want to add a JScrollPane
to a panel but when I add the scroll pane to a panel, the background of the panel changes and becomes white. Why does this happen?
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);