Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Scroll Panes contain another component, known as the ViewPort. This is actually where the components been assigned to the scroll pane get added.</p> <p>If you want to maintain the JTable as transparent (<code>table1.setOpaque(false);</code>), then you need to change the view ports background</p> <pre><code>scroll1.getViewport().setBackground(ivory); </code></pre> <p>Otherwise, set the table to opaque and <code>table1.setFillsViewportHeight(true);</code> to force the table to fill the entire viewport</p> <p><strong>UPDATED</strong></p> <p>Works fine for me</p> <pre><code>model1 = new DefaultTableModel(); model1.addColumn("Purpose"); model1.addColumn("Name"); model1.addColumn("Composition"); model1.addColumn("Expiry"); model1.addColumn("Stock"); model1.addColumn("Cost"); model1.addColumn("Type"); model1.addColumn("Supplier"); model1.addColumn("Supplier Number"); model1.addColumn("Rack"); for (int index = 0; index &lt; 10; index++) { Vector vector = new Vector(); vector.add("p" + index); vector.add("n" + index); vector.add("c" + index); vector.add("e" + index); vector.add("s" + index); vector.add("c" + index); vector.add("t" + index); vector.add("s" + index); vector.add("s" + index); vector.add("r" + index); model1.addRow(vector); } table1 = new JTable(model1); Color ivory = new Color(255, 255, 208); table1.setOpaque(true); table1.setFillsViewportHeight(true); table1.setBackground(ivory); JScrollPane scroll1 = new JScrollPane(table1); table1.getTableHeader().setBackground(ivory); add(scroll1, BorderLayout.CENTER); </code></pre> <p>You can comment out the row creation section and it will still paint in ivory.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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