Start New Discussion within our Software Development Community

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));

This question has already been answered. Start a new discussion instead.