Any help appreciated,
--
--------------------------------------------
Krzysztof Sterna
krzys_...@poczta.onet.pl
--------------------------------------------
Klaus
Krzysztof Sterna escribió:
Hi !
> I have a problem with changing a JScrollPane background colour. I tried
> these:
[...]
> How to change the background???
Are you using 1.3 or an older JDK - version ?
I read something about a bug in prior versions than 1.3 concerning
JScrollPane's background I simply call setBackground() on the
JViewport and so the the following codelines changes the color :
myscroll.getViewport().setBackground(new Color(80,90,155));
Linda
--
"So tell me, my good man, why is a raven like
a writing desk ?" A British accent, precise,
aristocratic. George stumbled free of the
congested clothing like a jungle explorer
breaking into a clearing. "What ?"
James Morrow, This Is The Way The World Ends ,
Krzysztof Sterna escribió:
> I have a problem with changing a JScrollPane background colour. I tried
> these:
[...]
> How to change the background???
Are you using 1.3 or an older JDK - version ?
I read something about a bug in prior versions than 1.3 concerning
JScrollPane's background. I simply call setBackground() on the
JViewport and so the following codelines changes the color :
To Klaus:
I add a JTable component to the JScrollPane... the background colour of the
JTable is set to white by default...
The size of JScrollPane is constant, but the size of JTable changes... e.g.
it may contain only two rows and then not the whole JScrollPane is covered
with the table. In this case JScrollPane content is half white and half
gray, which doesn't look good :(
To Linda:
setting background for a JViewport doesn't work in my case... I checked it
again...
Do you remember where you've read about the bug with JScrollPane?
KS
Krzysztof Sterna escribió:
Hi!
> To Linda:
> setting background for a JViewport doesn't work in my case... I checked it
> again...
> Do you remember where you've read about the bug with JScrollPane?
I found the article again containing a possible solution for prior versions,
too :
http://forum.java.sun.com/read/16799962/q_XDXfzdGkL8AAZQE#LR
Linda
--
E wieß Blatt Papier, ne Bleisteff, Jedanke bei dir,
setz ich ahm Finster un hühr, wat sich avvspillt vüür
der Düür, bess ich avvrötsch en die Zigg, en der et
dich für mich nit joov un mir ming Levve vürm Daach
X op einmohl vüürkütt wie en Stroof.
Do kanns zaubere, BAP
Thanks a lot!!!
The solution given by JoeScheer works very well in JDK1.2.2:
Work-around:
By putting the scroll pane within a panel which is the same size as the
scrollpane AND setting the background color of the panel, the viewport ends
up
picking up the background of the panel.
Example code:
/*
* Workaround for bug 4119459
*/
// Set background color of panel which contains the JTable
m_hTableBackgroundPanel.setBackground(SystemColor.window);
m_hTableBackgroundPanel.setLayout( new BorderLayout() );
// Create a scroll pane for the JTable
m_hStatusTableScrollPane =
JTable.createScrollPaneForTable(m_hStatusTable);
// Add the scroll pane to the panel - The viewport w/in the scroll pane
will pick up the
// background color of the panel.
m_hTableBackgroundPanel.add(m_hStatusTableScrollPane,
BorderLayout.CENTER);