JavaFX CSS checkbox styling - checkbox

I have some JavaFX checkboxes and want to style labels that I've assigned to them. I've put this in my .css file, but it doesn't change anything:
.check-box .label {
-fx-font-size: 18;
-fx-font-weight: bold;
}
What am I doing wrong?

Assuming that when you say you've "assigned labels to the check boxes" you mean that you've set text on them (either CheckBox cbox = new CheckBox("Check this"); or cbox.setText("Check this");, then you just need to omit the .label from the css:
.check-box {
-fx-font-size: 18;
-fx-font-weight: bold;
}

Related

Add border-spacing to ANTD Table Component ,and the checkbox is misaligned when checked?

I added border-spacing in index.css
body .ant-table table {
border-spacing: 0 16px;
}
There is indeed a gap, but it causes the check box to be misaligned after checking
example:
https://codesandbox.io/s/musing-snow-f7nui?file=/index.js
If you check the class of the cell that has the checkbox, its ant-table-selection-column.
The solution I used for this was style this class directly and remove border spacing from those td's like;
.ant-table-cell.ant-table-selection-column {
border-spacing: initial;
}

Change font size of chart (n3-charts/line-chart)

I am using https://github.com/n3-charts/line-chart library to generate charts. Is it possible to change font size of axis labels? I could not find such option in official documentation.
Something like this on the CSS would work
.tick text {
font-size: 120%;
}
Edit: The appearance of many SVG elements can be configured using CSS, just inspect them in the browser and try modifying them.
When the chart is generated it has it's own classes that you can take advantage of overwriting... Here are all the axis for example:
// X-Axis Font
.x-axis {
font-size: 120%;
}
// Left Y-Axis
.y-axis {
font-size: 130%;
}
// Right Y-Axis
.y2-axis {
font-size: 140%;
}
Hope that helps.

JavaFx combobox dropdown list design issue

I am trying to change the background color and text color for combbox and is using following style
.root
{
//-back:#152635;
-darker:#272B30;
-dark:#3A3F44;
-normal:#52575C; // #555
-light:#7A8288; // #999
-lighter:#999; // #eee
-primary:-light;
-success:#62c462;
-info:#5bc0de;
-warning:#f89406;
-danger:#ee5f5b;
-fore-color:#C8C8C8;
-fx-background-color:-darker ;
-focused-color:#64c8c8;
-border-color:derive(-darker,50%);
-fx-text-fill:-fore-color;
-fx-font-size: 14px;
-fx-font-weight:100;
-fx-font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.combo-box-base {
-fx-background-color:-dark;
-fx-text-fill:-fore-color;
-fx-min-width:150px; }
.combo-box-base *.arrow-button {
-fx-background-color:derive(-dark,-10%); }
.combo-box-base *.arrow {
-fx-background-color:-normal; }
.combo-box *.list-view {
-fx-background-color:-normal;
-fx-text-fill:-fore-color; }
Design looks good in Scene builder but in my application, font and background color of drop down list is not changed which is little bit surprised to me. Please help me to find out what is wrong in my css.
While #James_D solution works, if you override the background color you won't see hover, filled or selected pseudo classes.
This will give you the chance to define your styling for them too:
.combo-box-popup > .list-view {
-fx-background-color: -normal; // or define other color to highlight the border
}
.combo-box-popup *.list-cell {
-fx-background: -normal;
-fx-selection-bar: -light; // filled:hover
-fx-cell-focus-inner-border: -dark; // filled:selected:hover
-fx-text-fill: -fore-color;
}
You need to apply the style to the list cells, not the list view:
.combo-box *.list-view .list-cell {
-fx-background-color:-normal;
-fx-text-fill:-fore-color; }

Renderer having image and hyperlink together in extjs

I have a form which has a displayfield.The value of the form is set as a hyperlink.Now I also need an image to appear along with the hyperlink.How can this be done?Below is my code to add hyperlink:
xtype:'displayField',
fieldLabel: 'Name',
value: 'abc',
renderer:function(value){
return ''+value+'' //need to add an image with this
}
I usually go for one of these approaches, mostly equivalent:
Add a css class to my a element, with background-image and some padding-left.
Enclose the anchor element in a div with a similar css class.
Add a span before the anchor. Additionally use display: inline-block and give it a width and a height since it has no text content.
You could just precede it with an img, but for some reason I never do that. It's ugly if the image doesn't get loaded.
Examples:
CSS
.myimgclass: {
background-image: url(...);
background-position: 0;
background-repeat: no-repeat;
}
span.myimgclass {
width: 16px;
height: 16px;
display: inline-block;
}
So in your renderer you can the following:
Inline the anchor:
renderer:function(value){
return '<a class="myimgclass" href="#">'+value+'</a>';
}
Enclosed in a div
renderer:function(value){
return '<div class="myimgclass">'+value+'</div>';
}
Prepended as a span:
renderer:function(value){
return '<span class="myimgclass"></span>'+value+'';
}
Prepended as an img:
renderer:function(value){
return '<img src="../your/img/path/here.png." />'+value+'';
}
I would also like to add that all these approaches are based on you wanting to add the image as html, through your renderer. Another approach is to set your component's html: configuration. Then use ctrl.update('...'); if you ever want to update it. The html content should be identical to the examples above, but value won't be available. So renderer is more for dynamic content or generic during initialization, while html is controlled mostly from code (e.g. events).

extjs - column headers and row data are not aligned

I have a gridpanel and 5 columns in that. Problem is that column headers and row data are not aligned. I believe its just the problem in my project only as when i create an example with the same code then everything works fine. Check the following image:
Can anyone suggest what could be the problem?
Please apply below css as per the requirements.
1) For Customizing specific ExtJS GridPanel, apply below css:
#testgrid_id table caption,table th,table td {
padding : 0px !important;
margin : 0px !important;
}
Note: Here, above "#testgrid_id" is the id of specific Grid Panel.
2) For applying to all ExtJS GridPanels, apply below css :
table caption,table th,table td {
padding : 0px !important;
margin : 0px !important;
}
Thanks!
Actually I found out that most times, the grid is under some panel.
Hence the actual problem is with this class
.x-grid-cell-inner
{
overflow: hidden;
padding: 2px 6px 3px;
**text-overflow: ellipsis;
white-space:nowrap;**
}
This is because the width of the or
<td class=" x-grid-cell x-grid-cell-gridcolumn-1099 "><div class="x-grid-cell-inner "></div></td>
Does not get set. Making the Div overflowing the columns and screwing up the whole grid alignment.
Probably because i nested the GridPanel into another panel OR a Row expander in my case or under some modal dialogue or whatever it may be causing the settings not to take place.
A Quick Fix.
**white-space:normal;**
Will do the trick and squeeze the contents into the column. However it does not apply the ellipses so it is a bit annoying if the content is long, its not hidden with "..."
I will try to find another solution that does the trick, but guess what, time to deploy this to the server!
I hope this helps someone
I have this bug using GXT 2.2.5 (Chrome Version 26.0.1410.43m).
Solution:
#media screen and (-webkit-min-device-pixel-ratio:0) {
.x-grid3-row td.x-grid3-cell
{
box-sizing: border-box;
}
}
Note, if your CSS contains something like:
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
remote it.
I had exactly the same problem.
For me the problem was, was that I was setting HTML ids on my column headers. ExtJS then appends funny things to the ID, like titleEl, textEl, triggerEL.
Eg:
<div id="myPackageGridId1-titleEl" class="x-column-header-inner">
This must somehow screw up the column listener.
Solution : use class instead.
In my case (GXT 2.2.1) I fixed the problem by subclassing GridView, overriding getColumnStyle, and setting adj to 0:
import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.Style;
import com.extjs.gxt.ui.client.widget.grid.GridView;
public class GridViewBugFix extends GridView {
private boolean fixHeaderDisplacement = true;
public GridViewBugFix() {
super();
}
#Override
protected String getColumnStyle(int colIndex, boolean isHeader) {
String style = !isHeader ? cm.getColumnStyle(colIndex) : "";
if (style == null) {
style = "";
}
int adj = GXT.isWebKit ? 2 : 0;
if (fixHeaderDisplacement) adj = 0;
style += "width:" + (getColumnWidth(colIndex) + adj) + "px;";
if (cm.isHidden(colIndex)) {
style += "display:none;";
}
Style.HorizontalAlignment align = cm.getColumnAlignment(colIndex);
if (align != null) {
style += "text-align:" + align.name() + ";";
}
return style;
}
}

Resources