set background color in scrollpane - javafx-2

I have set background color in scrollpane using setStyle() method. the below code is working fine in up to "jdk-8-ea-bin-b109" java version after that java versions, these commend is not working properly but while mouse over the color has been applying.
My code is:
scrlPane.setStyle("-fx-background-color:#434547;");

From a question I created in regards to ScrollPane background colors in JavaFX 8:
ScrollPanes in JavaFX 8 always have gray background
You may need to use this CSS so that ScrollPane styling can actually work:
.scroll-pane > .viewport {
-fx-background-color: transparent;
}

try this it change scroll pane color
.scroll-bar:horizontal .thumb {
-fx-background-color:
red,
linear-gradient(to bottom, derive(red,95%), derive(red,10%)),
linear-gradient(to bottom, derive(red,38%), derive(red,-16%));
-fx-background-insets: 0, 1, 2;
-fx-background-radius: 0.5em; /* makes sure this remains circular */
}
.scroll-bar:vertical .thumb {
-fx-background-color:
red,
linear-gradient(to right, derive(red,95%), derive(red,10%)),
linear-gradient(to right, derive(red,38%), derive(red,-16%));
-fx-background-insets: 0, 1, 2;
-fx-background-radius: 0.5em; /* makes sure this remains circular */
}
it shows like below
here the global css for scroll pane for further changes;
.scroll-bar:horizontal {
-fx-background-color:
red,
linear-gradient(to bottom, derive(red,30%) 5%, derive(red,-17%) 100%);
-fx-background-insets: 0, 1;
}
.scroll-bar:horizontal:focused {
-fx-background-color:
-fx-focus-color,
-fx-box-border,
linear-gradient(to bottom, derive(red,30%) 5%, derive(red,-17%) 100%);
-fx-background-insets: -1.4, 0, 1;
}
.scroll-bar:vertical {
-fx-background-color:
red,
linear-gradient(to top, derive(red,30%) 5%, derive(red,-17%) 100%);
-fx-background-insets: 0, 1;
}
.scroll-bar:vertical:focused {
-fx-background-color:
red,
red,
linear-gradient(to top, derive(red,30%) 5%, derive(red,-17%) 100%);
-fx-background-insets: -1.4, 0, 1;
}
.scroll-bar:horizontal .thumb {
-fx-background-color:
red,
linear-gradient(to bottom, derive(red,95%), derive(red,10%)),
linear-gradient(to bottom, derive(red,38%), derive(red,-16%));
-fx-background-insets: 0, 1, 2;
-fx-background-radius: 0.5em; /* makes sure this remains circular */
}
.scroll-bar:vertical .thumb {
-fx-background-color:
red,
linear-gradient(to right, derive(red,95%), derive(red,10%)),
linear-gradient(to right, derive(red,38%), derive(red,-16%));
-fx-background-insets: 0, 1, 2;
-fx-background-radius: 0.5em; /* makes sure this remains circular */
}
.scroll-bar:focused .thumb {
-fx-color: -fx-focused-base;
}
.scroll-bar .thumb:hover {
-fx-color: -fx-hover-base;
}
/* Uncomment when RT-10521 is fixed.
.scroll-bar .thumb:pressed {
-fx-color: -fx-pressed-base;
}
*/
.scroll-bar:horizontal .track {
-fx-background-color:
-fx-box-border,
linear-gradient(to bottom, derive(-fx-color,-15%), derive(-fx-color,2.2%) 20%, derive(-fx-color,60%));
-fx-background-insets: 0, 1;
-fx-background-radius: 0.5em; /* makes sure this remains circular */
}
.scroll-bar:horizontal .track-background {
-fx-background-color:
-fx-box-border,
linear-gradient(to bottom, derive(-fx-color,-15%), derive(-fx-color,2.2%) 20%, derive(-fx-color,60%));
-fx-background-insets: 0, 1;
}
.scroll-bar:vertical .track {
-fx-background-color:
-fx-box-border,
linear-gradient(to right, derive(-fx-color,-15%), derive(-fx-color,2.2%) 20%, derive(-fx-color,60%));
-fx-background-insets: 0, 1;
-fx-background-radius: 0.5em; /* makes sure this remains circular */
}
.scroll-bar:vertical .track-background {
-fx-background-color:
-fx-box-border,
linear-gradient(to right, derive(-fx-color,-15%), derive(-fx-color,2.2%) 20%, derive(-fx-color,60%));
-fx-background-insets: 0, 1;
}
.scroll-bar .increment-button {
-fx-background-color:
-fx-box-border,
linear-gradient(to bottom, derive(-fx-color,30%) 5%, derive(-fx-color,-17%));
-fx-background-insets: 0, 1;
-fx-padding: 0.25em; /* 3 */
}
.scroll-bar .decrement-button {
-fx-background-color:
-fx-box-border,
linear-gradient(to bottom, derive(-fx-color,30%) 5%, derive(-fx-color,-17%));
-fx-background-insets: 0, 1;
-fx-padding: 0.25em; /* 3 */
}
.scroll-bar:horizontal .increment-arrow {
-fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
-fx-background-insets: 1 0 -1 0, 0;
-fx-padding: 0.5em 0.333333em 0.0em 0.0em; /* 6 4 0 0 */
-fx-shape: "M 4 0 L 0 -3 L 0 3 z";
}
.scroll-bar:vertical .increment-arrow {
-fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
-fx-background-insets: 1 0 -1 0, 0;
-fx-padding: 0.333333em 0.5em 0.0em 0.0em; /* 4 6 0 0 */
-fx-shape: "M -3 0 L 0 4 L 3 0 z";
}
.scroll-bar:horizontal .decrement-arrow {
-fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
-fx-background-insets: 1 0 -1 0, 0;
-fx-padding: 0.5em 0.333333em 0.0em 0.0em; /* 6 4 0 0 */
-fx-shape: "M 0 0 L 4 -3 L 4 3 z";
}
.scroll-bar:vertical .decrement-arrow {
-fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
-fx-background-insets: 1 0 -1 0, 0;
-fx-padding: 0.333333em 0.5em 0.0em 0.0em; /* 4 6 0 0 */
-fx-shape: "M -3 0 L 0 -4 L 3 0 z";
}
.scroll-bar:disabled {
-fx-opacity: -fx-disabled-opacity;
}

Related

how to store pieces in gomoku

am currently learning MFC and decided to make the game Gomoku. this is the code I have so far.
**mainframe.h**
class CMainFrame : public CFrameWnd
{
public:
CMainFrame();
protected:
DECLARE_DYNAMIC(CMainFrame)
public:
public:
public:
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
DECLARE_MESSAGE_MAP()
void DrawBoard(CDC* pDC);
int m_nNextChar;
int board[15][15];
static const int EMPTY = 0, WHITE = 1, BLACK = 2;
public:
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnPaint();
};
**mainframe.cpp**
#include "stdafx.h"
#include "01.win32tomfc.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
ON_WM_PAINT()
END_MESSAGE_MAP()
int diameter = 23;
int size = 40;
int xCod;
int yCod;
int xCodx;
int yCody;
// CMainFrame ¹¹Ôì/Îö¹¹
CMainFrame::CMainFrame()
{
m_nNextChar = BLACK;
Create(NULL, _T("Generic Sample Application"));
CRect rect(0, 0, 700, 700);
CalcWindowRect(&rect);
SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(),
SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW);
}
CMainFrame::~CMainFrame()
{
}
// CMainFrame Õï¶Ï
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
// CMainFrame ÏûÏ¢´¦Àí³ÌÐò
void CMainFrame::DrawBoard(CDC * pDC)
{
CPen pen(PS_SOLID, 1, RGB(0, 0, 0));
CPen* pOldPen = pDC->SelectObject(&pen);
for (int i = 1; i <= 16; i++) {
pDC->MoveTo(40 * i, 40);
pDC->LineTo(40 * i, 640);
pDC->MoveTo(40, 40 * i);
pDC->LineTo(640, 40 * i);
}
pDC->SelectObject(pOldPen);
}
void CMainFrame::OnLButtonDown(UINT nFlags, CPoint point)
{
CClientDC dc(this);
CPen pen(PS_SOLID, 1, RGB(0, 0, 0));
CPen* pOldPen = dc.SelectObject(&pen);
dc.SelectStockObject(BLACK_BRUSH);
xCod = (point.x + (size / 2)) / size;
xCod = (xCod * size) - diameter / 2;
yCod = (point.y + (size / 2)) / size;
yCod = (yCod * size) - diameter / 2;
xCodx = xCod + diameter;
yCody = yCod + diameter;
if (m_nNextChar != BLACK )
return;
else {
if (xCod > 20 && yCod <= 640 && xCodx < 655 && yCody > 40) {
dc.Ellipse(xCod, yCod, xCodx, yCody);
}
}
m_nNextChar = WHITE;
CFrameWnd::OnLButtonDown(nFlags, point);
}
void CMainFrame::OnRButtonDown(UINT nFlags, CPoint point)
{
CClientDC dc(this);
CPen pen(PS_SOLID, 1, RGB(0, 0, 0));
CPen* pOldPen = dc.SelectObject(&pen);
dc.SelectStockObject(WHITE_BRUSH);
xCod = (point.x + (size / 2)) / size;
xCod = (xCod * size) - diameter / 2;
yCod = (point.y + (size / 2)) / size;
yCod = (yCod * size) - diameter / 2;
xCodx = xCod + diameter;
yCody = yCod + diameter;
if (m_nNextChar != WHITE)
return;
else {
if (xCod > 20 && yCod <= 640 && xCodx < 655 && yCody > 40) {
dc.Ellipse(xCod, yCod, xCodx, yCody);
}
}
m_nNextChar = BLACK;
CFrameWnd::OnRButtonDown(nFlags, point);
}
void CMainFrame::OnPaint()
{
CPaintDC dc(this);
DrawBoard(&dc);
}
the code I have draws a 15 X 15 grid in the function DrawBoard() and draws the black and white pieces in the OnLButtonDown and OnRButtonDown respectively. thing is when I run the program and click to draw the black piece and then the white piece, the white piece can be drawn over the black piece and vice versa. so I thought to create a two-dimensional array board[15][15] to store a piece when its drawn so that a different piece cannot be drawn over a current piece would be best(am I on the right track here). I tried but I can't seem to figure out how to do it. am not very good at programming and realize this might be easy but some help would really be appreciated. please explain how I would go about it the right way.
this is what I tried.
void CMainFrame::OnLButtonDown(UINT nFlags, CPoint point)
{
CClientDC dc(this);
CPen pen(PS_SOLID, 1, RGB(0, 0, 0));
CPen* pOldPen = dc.SelectObject(&pen);
dc.SelectStockObject(BLACK_BRUSH);
xCod = (point.x + (size / 2)) / size;
xCod = (xCod * size) - diameter / 2;
yCod = (point.y + (size / 2)) / size;
yCod = (yCod * size) - diameter / 2;
xCodx = xCod + diameter;
yCody = yCod + diameter;
if ((m_nNextChar != BLACK) && (board[xCod][yCod] = WHITE) )
return;
else {
if (xCod > 20 && yCod <= 640 && xCodx < 655 && yCody > 40) {
dc.Ellipse(xCod, yCod, xCodx, yCody);
board[xCod][yCod] = BLACK;
}
}
void CMainFrame::OnRButtonDown(UINT nFlags, CPoint point)
{
CClientDC dc(this);
CPen pen(PS_SOLID, 1, RGB(0, 0, 0));
CPen* pOldPen = dc.SelectObject(&pen);
dc.SelectStockObject(WHITE_BRUSH);
xCod = (point.x + (size / 2)) / size;
xCod = (xCod * size) - diameter / 2;
yCod = (point.y + (size / 2)) / size;
yCod = (yCod * size) - diameter / 2;
xCodx = xCod + diameter;
yCody = yCod + diameter;
if (m_nNextChar != WHITE && (board[xCod][yCod] = BLACK))
return;
else {
if (xCod > 20 && yCod <= 640 && xCodx < 655 && yCody > 40) {
dc.Ellipse(xCod, yCod, xCodx, yCody);
board[xCod][yCod] = WHITE;
}
}
m_nNextChar = BLACK;
CFrameWnd::OnRButtonDown(nFlags, point);
}
You should do all the drawings in OnPaint. Don't draw in other functions such as OnLButtonDown. Instead, get the necessary information from OnLButtonDown and call Invalidate, this will repaint the window.
Here is an example. For simplicity, I created a structure info and a 2-dimensional array data. data stores all the information for each cell, that is the rectangle and color. You have to initialize data once, and paint based on the information in data
#include <vector>
class CMainFrame : public CFrameWnd
{
...
struct info
{
CRect rect;
int color;
};
std::vector<std::vector<info>> data;
};
CMainFrame::CMainFrame()
{
...
data.resize(15);
for(int i = 0; i < data.size(); i++)
data[i].resize(15);
int xoffset = 20;
int yoffset = 20;
for(int row = 0; row < 15; row++)
{
for(int col = 0; col < 15; col++)
{
data[row][col].rect.SetRect(0, 0, size + 1, size + 1);
data[row][col].rect.MoveToXY(xoffset + row * size, yoffset + col * size);
}
}
}
void CMainFrame::OnLButtonDown(UINT nFlags, CPoint point)
{
CFrameWnd::OnLButtonDown(nFlags, point);
for(int row = 0; row < 15; row++)
{
for(int col = 0; col < 15; col++)
{
if(data[row][col].color)
break;
if(data[row][col].rect.PtInRect(point))
{
data[row][col].color = WHITE;
break;
}
}
}
Invalidate(FALSE);
}
void CMainFrame::OnRButtonDown(UINT nFlags, CPoint point)
{
CFrameWnd::OnRButtonDown(nFlags, point);
for(int row = 0; row < 15; row++)
{
for(int col = 0; col < 15; col++)
{
if(data[row][col].color)
break;
if(data[row][col].rect.PtInRect(point))
{
data[row][col].color = BLACK;
break;
}
}
}
Invalidate(FALSE);
}
void CMainFrame::OnPaint()
{
CPaintDC dc(this);
CPen pen(PS_SOLID, 1, RGB(0, 0, 0));
dc.SelectObject(&pen);
CBrush white, black;
white.CreateSolidBrush(RGB(255, 255, 255));
black.CreateSolidBrush(RGB(0, 0, 0));
for(int row = 0; row < 15; row++)
{
for(int col = 0; col < 15; col++)
{
dc.Rectangle(data[row][col].rect);
if(data[row][col].color)
{
CBrush *oldbrush;
if(data[row][col].color == WHITE)
oldbrush = dc.SelectObject(&white);
else
oldbrush = dc.SelectObject(&black);
dc.Ellipse(data[row][col].rect);
dc.SelectObject(oldbrush);
}
}
}
}

Javafx combobox styling

I need a combobox in javaFX whose popup behavior can be controlled, like upon clicking the combobox, instead of default behavior where it shows a drop down, i want the drop down to be shown above the combobox (insetad of display below the combobox) .
Is it possible ?
Can we do this with css ?
Thanks for any help.
I hope this will work for you. Make some changes according your need
.combo-box .list-cell
{
-fx-background: white;
-fx-background-color: transparent;
-fx-text-fill: -fx-text-base-color;
-fx-padding: 3 0 2 7;
-fx-cell-size: 1.66667em;
}
.combo-box-popup .list-view
{
-fx-background-color: white, white;
-fx-background-insets: 0, 1;
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 8, 0.0 , 0 , 0 );
}
.combo-box-popup .list-view .list-cell
{
-fx-padding: 4 0 4 5;
/* No alternate highlighting */
-fx-background-color: white;
}
.combo-box-popup .list-view .list-cell:filled:selected, .combo-box-popup .list-view .list-cell:filled:selected:hover
{
-fx-background: -fx-accent;
-fx-background-color: -fx-selection-bar;
-fx-text-fill: -fx-selection-bar-text;
}
.combo-box-popup .list-view .list-cell:filled:hover
{
-fx-background-color: white;
-fx-text-fill: -fx-text-inner-color;
}
.combo-box-base
{
-fx-skin: "com.sun.javafx.scene.control.skin.ComboBoxBaseSkin";
-fx-background-color: white, white, white, white;
-fx-background-radius: 5, 5, 4, 3;
-fx-background-insets: 0 0 -1 0, 0, 1, 2;
-fx-padding: 0;
}
.combo-box-base:hover
{
-fx-color: -fx-hover-base;
}
.combo-box-base:showing
{
-fx-color: -fx-pressed-base;
}
.combo-box-base:focused {
-fx-background-color: -fx-focus-color, -fx-outer-border, -fx-inner-border, -fx-body-color;
-fx-background-radius: 6.4, 4, 5, 3;
-fx-background-insets: -1.4, 0, 1, 2;
}
.combo-box-base:disabled {
-fx-opacity: .4;
}

How can we set a particular color for selected item on ListView in java fx? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How can we set a particular color for selected item on ListView in java fx?
Thanks in advance!!!
Add appropriate rules to your css file to override the following rules (copied from caspian.css):
.list-cell {
-fx-skin: "com.sun.javafx.scene.control.skin.ListCellSkin";
-fx-background-color: -fx-control-inner-background;
-fx-padding: 0.25em; /* 3 */
-fx-text-fill: -fx-text-inner-color;
-fx-opacity: 1;
}
.list-cell:odd {
-fx-background-color: derive(-fx-control-inner-background,-5%);
}
.list-view:focused .list-cell:focused {
-fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-control-inner-background;
-fx-background-insets: 0, 1, 2;
}
.list-view:focused .list-cell:focused:odd {
-fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, derive(-fx-control-inner-background,-5%);
-fx-background-insets: 0, 1, 2;
}
/* When the list-cell is selected and focused */
.list-view:focused .list-cell:filled:focused:selected {
-fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
-fx-background-insets: 0, 1, 2;
-fx-background: -fx-accent;
-fx-text-fill: -fx-selection-bar-text;
}
.list-view:focused .list-cell:filled:selected, .list-view:focused .list-cell:filled:selected:hover {
-fx-background: -fx-accent;
-fx-background-color: -fx-selection-bar;
-fx-text-fill: -fx-selection-bar-text;
}
.list-view:focused .list-cell:filled:focused:selected:hover {
-fx-background: -fx-accent;
-fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
-fx-background-insets: 0, 1, 2;
-fx-text-fill: -fx-selection-bar-text;
}
/* When the ListView is _not_ focused, we show alternate selection colors */
.list-cell:filled:selected:focused, .list-cell:filled:selected, .list-view:horizontal .list-cell:filled:selected {
-fx-background-color: lightgray;
-fx-text-fill: -fx-selection-bar-text;
}
.list-cell:filled:selected:focused:disabled, .list-cell:filled:selected:disabled {
-fx-opacity: -fx-disabled-opacity;
}
.list-cell:filled:hover {
-fx-background-color: -fx-cell-hover-color;
-fx-text-fill: -fx-text-inner-color;
}
.list-view:focused .list-cell:filled:focused:hover {
-fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-cell-hover-color;
-fx-background-insets: 0, 1, 2;
-fx-text-fill: -fx-text-inner-color;
}
.list-view:horizontal .list-cell:filled:selected, .list-view:horizontal .list-cell:filled:selected:hover {
-fx-background-color: linear-gradient(to right, derive(-fx-accent,-7%), derive(-fx-accent,-25%));
}
Especially, look for :selected pseudo classes and modify them as you need.

How to change the tab pane style

I use the default JavaFX tab pane layout
I want to display new tabs below the old ones. I don't want to display the default context menu to select which tab to display. Are there any options to change this?
try this....change it according your need.this is default css for tab pane and their layout... i used it and work sucessfully
.tab-pane
{
-fx-skin: "com.sun.javafx.scene.control.skin.TabPaneSkin";
/* -fx-tab-min-width: 4.583em; 55 */
/* -fx-tab-max-width: 4.583em; 55 */
-fx-tab-min-height: 2em; /* 24 */
-fx-tab-max-height: 2em; /* 24 */
}
.tab .tab-label
{
-fx-skin: "com.sun.javafx.scene.control.skin.LabelSkin";
-fx-background-color: transparent;
-fx-alignment: CENTER;
-fx-text-fill: -fx-text-base-color;
}
/*
.tab *.tab-label Text {
-fx-effect: dropshadow(two-pass-box , rgba(255, 255, 255, 0.4), 1, 0.0 , 0, 1);
}*/
.tab-content-area
{
-fx-background-color: -fx-control-inner-background;
-fx-padding: 0.0em; /* 0 */
/* -fx-opacity: -fx-disabled-opacity;*/
}
.tab
{
/* This is how it is done in Button, but the -1 inset caused a white line */
/* to appear beneath the tab, which looks bad, so it's taken out below. */
/* -fx-background-color: -fx-shadow-highlight-color, -fx-tab-border-color, -fx-inner-border, -fx-body-color;
-fx-background-radius: 5 5 0 0, 5 5 0 0, 4 4 0 0, 3 3 0 0;
-fx-background-insets: 0 0 -1 0, 0, 1, 2;*/
-fx-background-insets: 0, 1, 2;
-fx-background-radius: 5 5 0 0, 4 4 0 0, 3 3 0 0;
-fx-padding: 0.083333em 0.5em 0.083333em 0.5em; /* 1 6 1 6 */
/* -fx-text-fill: -fx-text-base-color;*/
}
.tab:top
{
-fx-background-color: -fx-tab-border-color, -fx-inner-border, -fx-body-color;
}
.tab:right
{
-fx-background-color: -fx-tab-border-color, -fx-inner-border-bottomup, -fx-body-color-bottomup;
}
.tab:bottom
{
-fx-background-color: -fx-tab-border-color, -fx-inner-border-bottomup, -fx-body-color-bottomup;
}
.tab:left
{
-fx-background-color: -fx-tab-border-color, -fx-inner-border, -fx-body-color;
}
.tab:hover
{
-fx-color: -fx-hover-base;
}
.tab:selected
{
/* -fx-background-color: white;*/
/* -fx-background-color: -fx-tab-border-color, -fx-inner-border, -fx-body-color;
-fx-background-radius: 5 5 0 0, 4 4 0 0, 3 3 0 0;
-fx-background-insets: 0, 1 1 0 1, 2 2 0 2;*/
-fx-background-color: -fx-tab-border-color, -fx-control-inner-background;
-fx-background-insets: 0, 1 1 0 1;
-fx-background-radius: 5 5 0 0, 4 4 0 0;
}
.tab:disabled
{
-fx-opacity: -fx-disabled-opacity;
}
.tab:disabled:hover
{
-fx-color: -fx-base;
-fx-opacity: -fx-disabled-opacity;
}
.tab-pane *.tab-header-background
{
-fx-background-color: -fx-outer-border, -fx-inner-border, derive(-fx-color, -20%);
-fx-effect: innershadow(two-pass-box , rgba(0,0,0,0.6) , 4, 0.0 , 0 , 0);
}
/*.tab-pane *.tab-header-area {*/
/* I would like to use -fx-tab-border-color here, but for some reason it */
/* just isn't the correct color, even though it works in :top above */
/* -fx-background-color: -fx-tab-border-color, lightgray;*/
/*}*/
.tab-pane:top *.tab-header-area
{
-fx-background-insets: 0, 0 0 1 0;
-fx-padding: 0.416667em 0.166667em 0.0em 0.833em; /* 5 2 0 10 */
}
.tab-pane:bottom *.tab-header-area
{
-fx-background-insets: 0, 1 0 0 0;
-fx-padding: 0 0.166667em 0.416667em 0.833em; /* 0 2 5 0 */
}
.tab-pane:left *.tab-header-area
{
-fx-background-insets: 0, 0 1 0 0;
-fx-padding: 0.833em 0.0em 0.166667em 0.416667em; /* 10 0 2 5 */
}
.tab-pane:right *.tab-header-area
{
-fx-background-insets: 0, 0 0 0 1;
-fx-padding: 0.833em 0.416667em 0.166667em 0.0em; /* 10 5 2 0 */
}
.tab-pane .headers-region
{
-fx-effect: dropshadow(two-pass-box , rgba(0,0,0,0.6) , 4, 0.0 , 0, 0);
}
/* TODO: scaling the shape seems to make it way too large */
.tab-close-button
{
-fx-background-color: -fx-mark-color;
-fx-shape: "M 0,0 H1 L 4,3 7,0 H8 V1 L 5,4 8,7 V8 H7 L 4,5 1,8 H0 V7 L 3,4 0,1 Z";
-fx-scale-shape: false;
-fx-effect: dropshadow(two-pass-box , rgba(255, 255, 255, 0.4), 1, 0.0 , 0, 1);
}
.tab-close-button:hover
{
-fx-background-color: derive(-fx-mark-color, -30%);
}
/* CONTROL BUTTONS */
.control-buttons-tab
{
-fx-background-color: -fx-tab-border-color, -fx-inner-border, -fx-body-color;
-fx-background-insets: 0, 1, 2;
-fx-background-radius: 5 5 0 0, 4 4 0 0, 3 3 0 0;
-fx-padding: 0.083333em 0.25em 0.083333em 0.25em; /* 1 3 1 3 */
}
.tab-down-button
{
-fx-background-color: transparent;
-fx-padding: 0.0em 0.416667em 0.0em 0.416667em; /* 0 5 0 5 */
}
.tab-down-button:hover
{
-fx-background-color: -fx-body-color;
-fx-color: -fx-hover-base;
}
.tab-down-button .arrow
{
-fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
-fx-background-insets: 1 0 -1 0, 0;
-fx-padding: 0.238083em 0.416667em 0.238083em 0.416667em; /* 2.857 5 2.857 5 */
-fx-shape: "M 0 0 H 7 L 3.5 4 z";
}
/* FLOATING TABS CUSTOMISATION */
.tab-pane.floating *.tab-header-background {
-fx-background-color: null;
}
.tab-pane.floating *.tab-header-area
{
-fx-background-color: null;
}
.tab-pane.floating *.tab-content-area
{
-fx-background-color: -fx-tab-border-color, -fx-control-inner-background;
-fx-background-insets: 0, 1;
-fx-background-radius: 5, 4;
}
.tab-pane.floating *.tab
{
-fx-background-color: -fx-tab-border-color, -fx-inner-border, -fx-body-color;
-fx-background-insets: 0, 1, 2;
-fx-background-radius: 5 5 0 0, 4 4 0 0, 3 3 0 0;
}
.tab-pane.floating *.tab:selected
{
-fx-background-color: -fx-tab-border-color, -fx-control-inner-background;
-fx-background-insets: 0 0 -1 0, 1 1 -1 1;
-fx-background-radius: 5 5 0 0, 4 4 0 0;
}
/*.tab-pane:floating *.control-buttons-tab
{
-fx-padding: 0.083333em 0.25em 0.083333em 0.25em;
-fx-background-color: -fx-tab-border-color, -fx-inner-border, -fx-body-color;
-fx-background-radius: 5 5 0 0, 4 4 0 0, 3 3 0 0;
-fx-background-insets: 0, 1 1 0 1, 2 2 0 2;
}*/

How to change the colors of the TableView's rows?

I have a tableview and want to change the default colors of the rows if I...
1. ... hover above a row.
2. ... selected a row.
Is there a easy way to do all of it in the css-file?
All I found out is that for case 1, I can set
.table-cell:hover {
-fx-background-color: green; }
in the css-file. With that the color of the cell changes but not the color of the whole row.
.table-view .row-selection:hover{
-fx-background-color: lightgreen; }
and a lot of other combinations I tried are not working.
/* Selected row */
.table-view:focused .table-row-cell:filled:focused:selected {
-fx-background-color: brown;
-fx-background-insets: 0, 1, 2;
-fx-background: -fx-accent;
-fx-text-fill: -fx-selection-bar-text;
}
/* Selected row when table not focused */
.table-row-cell:filled:focused:selected {
-fx-background-color: red;
-fx-background-insets: 0, 1, 2;
-fx-background: -fx-accent;
-fx-text-fill: -fx-selection-bar-text;
}
/* Row hovered */
.table-view:row-selection .table-row-cell:filled:hover {
-fx-background-color: green;
-fx-background-insets: 0, 0 0 1 0;
-fx-text-fill: -fx-text-inner-color;
}
/* Selected row hovered */
.table-view:focused .table-row-cell:filled:focused:selected:hover {
-fx-background: -fx-accent;
-fx-background-color: yellow;
-fx-background-insets: 0, 1, 2;
-fx-text-fill: -fx-selection-bar-text;
}
/* Selected row hovered when table not focused */
.table-view:row-selection .table-row-cell:filled:focused:hover {
-fx-background-color: blue;
-fx-background-insets: 0, 0 0 1 0, 1 1 2 1, 2 2 3 2, 3 3 4 3;
-fx-text-fill: -fx-text-inner-color;
}

Resources