• 如何在 j夫的表层中打一栏。 我的表格有3栏,希望为每个栏目设定不同的字体。 此外,还有可能改变常年。 请提供一些样本代码。
I recently started a JavaFX project, and I d like to use Maven as my compiler/deployment tool. Is there a good tutorial or plugin to integrate JavaFX and Maven?
• 如何在 j夫的表层中打一栏。 我的表格有3栏,希望为每个栏目设定不同的字体。 此外,还有可能改变常年。 请提供一些样本代码。
You should to use TableColumn#setCellFactory() to customize cell item rendering.
For example, datamodel with like this Person class:
// init code vs..
TableColumn firstNameCol = new TableColumn("First Name");
firstNameCol.setMinWidth(100);
firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));
firstNameCol.setCellFactory(getCustomCellFactory("green"));
TableColumn lastNameCol = new TableColumn("Last Name");
lastNameCol.setMinWidth(100);
lastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName"));
lastNameCol.setCellFactory(getCustomCellFactory("red"));
table.setItems(data);
table.getColumns().addAll(firstNameCol, lastNameCol);
// scene create code vs..
和共同的<条码>植被规范/编码方法:
private Callback<TableColumn<Person, String>, TableCell<Person, String>> getCustomCellFactory(final String color) {
return new Callback<TableColumn<Person, String>, TableCell<Person, String>>() {
@Override
public TableCell<Person, String> call(TableColumn<Person, String> param) {
TableCell<Person, String> cell = new TableCell<Person, String>() {
@Override
public void updateItem(final String item, boolean empty) {
if (item != null) {
setText(item);
setStyle("-fx-text-fill: " + color + ";");
}
}
};
return cell;
}
};
}
TableView
like other controls of JavaFX uses a built-in style sheet named caspian.css
which is bundled with jfxrt.jar. See the answer of "JavaFX 2 and CSS classes".
To change the column font style you can either override the default style or customize it:
Overriding:
.table-view .column-header{
-fx-text-fill: -fx-selection-bar-text;
-fx-font-size: 16;
-fx-font-family: "Arial";
}
习俗:
#my-custom .table-view .column-header {
-fx-text-fill: red;
-fx-font-size: 26;
-fx-font-family: "Arial";
}
http://www.ohchr.org。 因此,如果你在界定多种风格时更愿意定制,那么你可以将习惯风格适用于任何在操作时间的表象,即:
myTableView.setId("my-custom");
...
// Apply another style at runtime
myTableView.setId("my-custom2");
了解如何界定和装货单档案,以备查 如何塑造景象”。
However, applying different styles to different columns requires more effort I think.
您可使用fxml或cs文档确定字体。
# .mainFxmlClass {
-fx-font-family:nyala,Tahoma,Arial,Helvetica,sans-serif;
-fx-font-size:1.13em;
}
.label{
-fx-font-size:1.3em;
}
f file
1. 第1栏使用这种精干的1,2栏使用风格2
供应一个习惯电池工厂,提供cells, 您在剪辑中界定了这些风格。 相关文件载有一些实例,这些实例应当为你提供足够信息以实现这一目标。
I recently started a JavaFX project, and I d like to use Maven as my compiler/deployment tool. Is there a good tutorial or plugin to integrate JavaFX and Maven?
I have little quiz game I ve working on and am tracking correct answers. I have a text object that displays the number of consecutive correct answers. This is the content: content: bind consecutive....
Just a basic question about Java (haven t really done anything with it personally yet): Is it possible to write a Java program that runs in a web browser (via JRE) on the client machine? Is ...
I know there is already a question about the performance of Flex, JavaFX, and Silverlight. My question is a bit more broad: We are evaluating the merits of JavaFX and Silverlight to serve as the GUI ...
Is it possible to simplify / clean up svg code by replacing the use-tags with standard svg elements? Maybe an inkscape plugin? Haven t found anything... Background: I m converting some svgs to javafx ...
I am making a game in JavaFX and have implemented a slider for controlling the game speed. I have a simple slider (javafx.scene.control.Slider) and I m binding the time attribute for the gameloop to ...
I am working on a game in JavaFX and I m sending people the compiled game once in a while for them to try out. As I m still in the middle of developing it, I have several pieces of code intended ...
I am reviewing currently a medium size code base (around 30K LOC) which uses a huge Applet and interfaces with other systems. It s a tool to create custom labels, so we need drag-n-drop and other ...