ОПИСАНИЕJavaFX2: нельзя смешивать некоторые «SetStyle» на панели
На windows7 и JDK1.8.0_20, я просто пытаюсь показать некоторые стекла с черной каймой и с заданным цветом фона. Для этого я использую метод setStyle, со следующей документацией http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#region. Код проблемы находится в классе TestPane. Смотрите ниже полный ходовой код:
package pane;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class BorderPaneApp extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("BorderPane");
MainPane mainPane = new MainPane();
Scene scene = new Scene(mainPane, 400, 300, Color.ORANGE);
// do it for the layout
mainPane.prefHeightProperty().bind(scene.heightProperty());
mainPane.prefWidthProperty().bind(scene.widthProperty());
primaryStage.setScene(scene);
primaryStage.show();
}
public class MainPane extends BorderPane{
public TestPane topPane = new TestPane("top", Color.LIGHTSKYBLUE);
public TestPane leftPane = new TestPane("left", Color.AQUA);
public TestPane bottomPane = new TestPane("bottom", Color.AZURE);
public TestPane centerPane = new TestPane("center", Color.LIGHTBLUE);
public MainPane(){
this.setTop(this.topPane);
this.setLeft(this.leftPane);
this.setCenter(this.centerPane);
this.setBottom(this.bottomPane);
}
}
public class TestPane extends BorderPane {
public TestPane(String name, Color color){
// first style part - start
this.setStyle("-fx-border-color: #FFFFFF;");
this.setStyle("-fx-border-width: 1px;");
this.setStyle("-fx-border-style: solid;");
// first style part - end
// second style part - start
this.setStyle("-fx-background-color: " + color.toString().replace("0x", "#") + ";");
// second style part - end
this.setCenter(new Text(name));
}
}
}
После некоторых попыток, я не могу смешивать этот код:
// first style part - start
this.setStyle("-fx-border-color: #FFFFFF;");
this.setStyle("-fx-border-width: 1px;");
this.setStyle("-fx-border-style: solid;");
// first style part - end
с этим:
// second style part - start
this.setStyle("-fx-background-color: " + color.toString().replace("0x", "#") + ";");
// second style part - end
Последняя, кажется, принимает над первым и не отображать его. На первом снимке отображаются граничные линии перед фоном, а второй показывает набор фона перед пограничной линией.
ВОПРОС
Как отображать оба стиля вместе? Приветствие,
Jakez
Спасибо, я было неправильно истолковано, что стиль был ключевым меканизмом. Спасибо за ваш быстрый и ясный ответ. – Jakez