Hi!

I would like to make transparent my two JScrollPane components. Could please someone explain me why the code scrollPane1.setOpaque(false); scrollPane2.setOpaque(false); imagePanel.setOpaque(false); beads.setOpaque(false); does not work?

Thanks!

public SelectablePanel() {
        beads = new BeadsCollection(NR_OF_BEADS);
        imagePanel = new ImageSelectionPanel(0, NR_OF_BEADS_SIZE);

        p = new Point();

        JInternalFrame jif = new JInternalFrame("Title", true, true, true, true);
        ImageIcon icon = new ImageIcon(SelectablePanel.class.getResource("/icons/bkg_palette.jpg"));
        Image backImage = icon.getImage();
        MyJPanel pan = new MyJPanel();
        pan.setBackgroundImage(backImage); pan.setLayout(new MigLayout());
        jif.getContentPane().setLayout(new BorderLayout());
        jif.getContentPane().add(pan,BorderLayout.CENTER);
        JScrollPane scrollPane1 = new JScrollPane(imagePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        JScrollPane scrollPane2 = new JScrollPane(beads, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scrollPane1.setOpaque(false); scrollPane2.setOpaque(false);
        imagePanel.setOpaque(false); beads.setOpaque(false);
        pan.add(scrollPane1); pan.add(scrollPane2);

        jif.setPreferredSize(new Dimension(screenDim.width-deltax, screenDim.height-deltay));
        jif.pack();
        pan.setPreferredSize(new Dimension(jif.getWidth(),jif.getHeight()));
        jif.setVisible(true);
        jif.setResizable(false);
        add(jif);
   }

I solved the problem by including scrollPane1.getViewport().setBackground( new Color(1.0f, 1.0f, 1.0f, 0.6f));

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.