Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't see the contetnts when jscrollpane's opaque set to false
    primarykey
    data
    text
    <p>Hi, I am making a program that has a <code>JSplitPane</code> and its background is transparent so I add two panels with a <code>JScrollPane</code> on the <code>JSplitPane</code>.. when I add the contents in the panel it doesn't appear.</p> <p>This is the code that I was using:</p> <pre><code>import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JViewport; import javax.swing.UIManager; public class sample { JFrame mainFrame; JPanel mainPanel; JPanel splitPaneLeftPanel; JPanel splitPaneRightPanel; JSplitPane splitPane; JScrollPane rightPanelScroll; JScrollPane leftPanelScroll; JViewport viewport; sample(){ Frame(); SplitPaneAndContent(); mainFrame.setVisible(true); } public void Frame(){ mainFrame = new JFrame(); mainFrame.setTitle("Sample"); mainFrame.setLayout(new BorderLayout()); mainFrame.setSize(1024,720); mainFrame.setMaximumSize(new Dimension(1366,768)); mainFrame.setMinimumSize(new Dimension(800,600)); mainFrame.setResizable(true); mainFrame.setLocationRelativeTo(null); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void SplitPaneAndContent(){ mainPanel = new JPanel(new BorderLayout()); splitPaneLeftPanel = new JPanel(new BorderLayout()); splitPaneRightPanel = new JPanel(new BorderLayout()); mainPanel.setBackground(Color.blue); JScrollPane rightPanelScroll = new JScrollPane(splitPaneRightPanel); JScrollPane LeftPanelScroll = new JScrollPane(splitPaneLeftPanel); viewport = new JViewport(); rightPanelScroll.setViewport(viewport); rightPanelScroll.getViewport().setOpaque(false); JLabel Text = new JLabel("SAMPLE"); Text.setBackground(Color.red); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,LeftPanelScroll,rightPanelScroll); splitPane.setDividerLocation(300); splitPaneLeftPanel.setOpaque(false); splitPaneRightPanel.setOpaque(false); rightPanelScroll.setOpaque(false); splitPane.setOpaque(false); splitPaneRightPanel.add(Text, BorderLayout.CENTER); mainPanel.add(splitPane, BorderLayout.CENTER); mainFrame.add(mainPanel, BorderLayout.CENTER); } public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); new sample(); } catch (Exception e) { System.out.println(e); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload