Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

unable to set text color in TextArea

815317Oct 24 2011 — edited Nov 1 2011
I'm trying to skin the TextArea control, but it seems to be ignoring the -fx-text-fill style option. I've tried setting the style in code, FXML and css (preferred solution). Here is what I currently have for code:

App.java:
package spike;

import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.*;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.stage.*;

public class App extends Application {

    @FXML
    private TextInputControl console;
    
    public static void main(String[] args) { Application.launch(args); }
    
    @Override
    public void start(Stage stage) throws IOException {
        Parent root = FXMLLoader.load(getClass().getResource("App.fxml"));
        Scene scene = new Scene(root);        
        scene.getStylesheets().add(getClass().getResource("default.css").toString());
        stage.setScene(scene);
        stage.show();        
    }
}
App.fxml:
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<BorderPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml" fx:controller="spike.App">
    <center>
        <TextArea fx:id="console" />
    </center>
</BorderPane>
default.css:
#console { 
    -fx-background-color: black;
    -fx-font: 18pt "Serif";
    -fx-text-fill: white;
}
Changing the TextArea tag in the fxml file to TextField causes the font color to be correct, however does not provide the interface I am trying to achieve. I can't find any open bugs for this, but I'm fairly certain I would not be the first to notice this. Any ideas?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 29 2011
Added on Oct 24 2011
5 comments
2,847 views