Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't change background properties of an InlineCssTextArea #29

Closed
Flashfyre opened this issue Apr 1, 2014 · 10 comments
Closed

Can't change background properties of an InlineCssTextArea #29

Flashfyre opened this issue Apr 1, 2014 · 10 comments

Comments

@Flashfyre
Copy link

Is it possible to set the background colour and/or opacity of an InlineCssTextArea? I can't seem to find a way to do this anywhere. I originally had a TextArea in my project and switched it for an InlineCssTextArea for rich text support, but the CSS I used before no longer works. If this is not supported, is there a chance of it being added any time soon?

I'm using the newest JAR, 1.0.0-20140327. Thanks in advance.

@TomasMikula
Copy link
Member

Thanks for reporting. You can now use

area.setStyle("-fx-background-color: yellow;");

in your Java code, or

.styled-text-area {
    -fx-background-color: yellow;
}

in your stylesheet.

@Flashfyre
Copy link
Author

Thank you for answering so quickly. Unfortunately, I downloaded the newest fat JAR and tried both of those but to no avail. It's still the same white background. Are there any other lines of code that I need to be sure to put in before this will work properly? Thanks again.

@TomasMikula
Copy link
Member

This example works for me with this fat jar:

import org.fxmisc.richtext.InlineCssTextArea;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.layout.StackPane;

public class BackgroundColor extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        InlineCssTextArea area = new InlineCssTextArea();
        area.setStyle("-fx-background-color: yellow;");

        Scene scene = new Scene(new StackPane(area), 600, 400);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

@Flashfyre
Copy link
Author

Thanks a lot! It works now. I must have downloaded the wrong version or something.

@ghost
Copy link

ghost commented Apr 1, 2014

Thanks!

@ghost
Copy link

ghost commented Apr 2, 2014

Hi Tomas, did you change jar version in the link above? because i downloaded it and have two issues:
1- it seems to come with "whitesmoke" as background color.
2-I tried the same exact code, "-fx-background-color: white;" (or any other color), but it still is whitesmoke.
can you confirm?

@TomasMikula
Copy link
Member

Text area contains a ListView, whose background color is white by default. What I did here was to set this ListView's background color to transparent, so that any background color you set on the area can shine through.

My guess for your whitesmoke background would be that something of a whitesmoke color is shining through from underneath the text area, but then setting the background color of the area to white would have fixed it. So I'm not sure what exactly is going on in your case.

Anyway, I now set the default background color of text area to white, so please redownload and report back.

@ghost
Copy link

ghost commented Apr 2, 2014

Ok I will try that now.

On Wed, Apr 2, 2014 at 7:25 AM, TomasMikula notifications@github.comwrote:

Text area contains a ListView, whose background color is white by default.
What I did here was to set this ListView's background color to transparent,
so that any background color you set on the area can shine through.

My guess for your whitesmoke background would be that something of a
whitesmoke color is shining through from underneath the text area, but then
setting the background color of the area to white would have fixed it. So
I'm not sure what exactly is going on in your case.

Anyway, I now set the default background color of text area to white, so
please redownload and report back.

Reply to this email directly or view it on GitHubhttps://github.com//issues/29#issuecomment-39319070
.

@ghost
Copy link

ghost commented Apr 2, 2014

Ok Now it is white.

I found the issue. the "-fx-highlight-fill" causes the background color to reset to its default (now white). And it is affected by the order in which they are called.

This order gives a red background for the text area, with blue highlighting
richText.setStyle("-fx-highlight-fill: blue;");
richText.setStyle("-fx-background-color: red;");

This order gives a white background with blue highlighting.
richText.setStyle("-fx-background-color: red;");
richText.setStyle("-fx-highlight-fill: blue;");

@TomasMikula
Copy link
Member

Maher,

it is not the "-fx-highlight-fill". It's simply that richText.setStyle(style) overwrites whatever style was set before using richText.setStyle(previousStyle).

In

richText.setStyle("-fx-highlight-fill: blue;");
richText.setStyle("-fx-background-color: red;");

"-fx-highlight-fill: blue;" has no effect.

In

richText.setStyle("-fx-background-color: red;"); 
richText.setStyle("-fx-highlight-fill: blue;");

"-fx-background-color: red;" has no effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants