CSS - Background image not displaying - java

I am trying, unsuccessfully, to get a background image to display. The java code is:
absolutePanel = new AbsolutePanel();
absolutePanel.setSize("600px", "600px");
absolutePanel.getElement().setId("cwAbsolutePanel");
absolutePanel.addStyleName("absolutePanel");
final Image img = new Image(Resources.INSTANCE.baseballBall());
absolutePanel.add(img, 10, 10);
CSS:
.absolutePanel {
background-image: url(bbdiamond.png);
background-size: 100% 100%;
background-repeat: no-repeat;
}
The path of the image and CSS file are:
I have tried "url('bbdiamond.png');" and "url(..\bbdiamond.png);" and "url('..\bbdiamond.png');".
I have also tried giving .absolutePanel a height and width of 100% each; background-color: white and opacity: 1.
Your assistance would be greatly appreciated.
Regards,
Glyn

I do not know why, however when I started testing this morning the CSS background was displayed. I have not made any changes to the CSS or the AbsolutePanel. In future if I am having issues with CSS I will reboot first.
Regards,
Glyn

Related

Setting button icon on SWT CCombo using CSS

According to https://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.rap.doc%2Fguide%2Freference%2Ftheming%2FCCombo.html the CCombo widget from SWT is themable, and the icon can be set.
I have the following CSS:
CCombo{
background-color: rgb(00,255,00);
}
CCombo Text {
background-color: rgb(00,255,00);
}
CCombo Button{
background-color: rgb(00,255,00);
background-image: url(ABSOLUTE PATH TO ICON);
}
CCombo Button-Icon{
background-color: rgb(00,255,00);
background-image: url(ABSOLUTE PATH TO ICON);
}
List[style~='SWT.DROP_DOWN']{
background-color: rgb(00,255,00);
}
And the background color is working fine. However I can't seem to get the icons working. I am using Linux to develop, however the application is deployed to windows7/10 so a solution for this platform would be sufficient for me.
I don't think this is possible.
The down arrow in CCombo is created using the SWT.ARROW | SWT.DOWN style on Button.
This setImage method of Button specifically ignores any setImage call when the style is SWT.ARROW so the CSS styling will not work.
I am looking at the macOS SWT code, there may be differences on other platforms.

JavaFX how to remove the borders from button

https://i.stack.imgur.com/Y76Fl.png
On this picture on left side - running java program, and right side - Scene builder layout.
This is my github code: https://github.com/captsmile/calc
You can do the following code in .css file
.button
{
-fx-background-color: transparent;
}
This will make the color of button as the color of your application's background color(due to transparency).
Furthermore you may also apply some effects to make your button looks more cool. To add effects
.button:hover
{
-fx-background-color: yellow;
}
.button:pressed
{
-fx-background-color: brown;
}
At the end ,you may attach the case file with your file(suppose index.java file in which you want to apply css) by writing following code in your index.java
scene.getStylesheets().add(getClass().getClassLoader().getResource("application.css").toExternalForm());
Where application.css is the css file with whole css code given above . This application file must be present in your src folder.
I fixed this removing border at GridPane
.root{
-fx-padding: 5;
-fx-border-style: none;
-fx-border-width: 0;
-fx-border-insets: 0;
}
This is how you can do it in scenebuilder
Choose the button by clicking on it.
Then in properties->Style
Choose "-fx-background-color"
and put value as " transparent"
Like this
You can do it by JavaFX CSS selectors on the button.
The answer in this link check it out, and there are also many JavaFX related examples you may interested in:
http://tutorials.jenkov.com/javafx/button.html

How to make the border of a SimplePanel dashed?

I have a GWT application with some SimplePanel.
How can I make its border dashed?
I tried myPanel.addStyleName(Style.BorderStyle.DOTTED.getCssName());, but it didn't work.
This should work using Element#getStyle() method to update the element's Style object.
SimplePanel myPanel=new SimplePanel();
myPanel.getElement().getStyle().setBorderStyle(BorderStyle.DOTTED);
but I suggest you to keep the styling in the CSS file instead of directly applying it in Java file that is more difficult to manage and change in future mostly in case of themes.
CSS:
.dashedBorder{
border: 1px dotted black;
}
JAVA:
SimplePanel myPanel=new SimplePanel();
myPanel.setStyleName("dashedBorder");

css img:hover working, img:active is not

I have the following code, which displays the images in my table with no border, then an orange border when hovered over:
table.test {
}
.test img {
border: solid 4px transparent;
}
.test img:hover {
border-color: orange;
}
If it try the following, i expect the border to stay orange after click, but it does not
.test img:active {
border-color: orange;
}
The images being used are thumbnail size instead of checkboxes.
Any ideas how I can keep the border orange after click?
Images cannot use active. http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#selector-active.Wrap it within an anchor and prevent default on the anchor click and change the cursor maybe?
check this fiddle might help you using simple jquery let you give your output
$('.test img').on('click', function(){
//use jquery css function
$(this).css({"border-color":"orange"});
// or add class .active with your own style
$(this).addClass('active');
})
make your image as block element and add this jquery click event. solved
You can create a class called orangeborder (or anything, really). Give it the attributes of border-color:orange;.
Then you can use jQuery and use:
$('img').click(function(){
$(this).toggleClass('orangeborder');
});
jsFiddle

webkit-specific css selector not working

I'm styling my GWT CellTable cells by overriding getCellStyleNames in my column definition. Styles are working, on the most part. I'm trying to color the background of a 4-pixel wide column, with mixed display results depending on the browser engine. I'm expecting the following to work, but it doesn't. I need to set the height for firefox to 0, otherwise the first row appears to have a larger height than the rest of the rows. Any ideas?
.wt-tableRowGreen {
background-color: #8DAF00;
width: 0px;
padding-left: 4px !important;
padding-right: 0px !important;
display: compact;
height: 100%;
}
Setting height to 0 works fine for FF, but breaks the others. Using browser specific selectors isn't working:
-ms-height: 100%;
-webkit-height: 100%;
-moz-height: 0;
If you want to target spesific css for Firefox, this is the solution I use:
#-moz-document url-prefix()
{
/* Css for FF here */
}
Obviously, this is something one should generally avoid, but in some cases it's virtually impossible to get around it.

Categories

Resources