本文整理汇总了Java中javafx.scene.control.Cell类的典型用法代码示例。如果您正苦于以下问题:Java Cell类的具体用法?Java Cell怎么用?Java Cell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cell类属于javafx.scene.control包,在下文中一共展示了Cell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTextField
import javafx.scene.control.Cell; //导入依赖的package包/类
static <T> TextField createTextField(final Cell<T> cell, final StringConverter<T> converter) {
final TextField textField = new TextField(getItemText(cell, converter));
// Use onAction here rather than onKeyReleased (with check for Enter),
// as otherwise we encounter RT-34685
textField.setOnAction(event -> {
if (converter == null) {
throw new IllegalStateException(
"Attempting to convert text input into Object, but provided "
+ "StringConverter is null. Be sure to set a StringConverter "
+ "in your cell factory.");
}
cell.commitEdit(converter.fromString(textField.getText()));
event.consume();
});
textField.setOnKeyReleased(t -> {
if (t.getCode() == KeyCode.ESCAPE) {
cell.cancelEdit();
t.consume();
}
});
return textField;
}
示例2: updateItem
import javafx.scene.control.Cell; //导入依赖的package包/类
static <T> void updateItem(final Cell<T> cell,
final StringConverter<T> converter,
final HBox hbox,
final Node graphic,
final ChoiceBox<T> choiceBox
) {
if (cell.isEmpty()) {
cell.setText(null);
cell.setGraphic(null);
} else if (cell.isEditing()) {
if (choiceBox != null) {
choiceBox.getSelectionModel().select(cell.getItem());
}
cell.setText(null);
if (graphic != null) {
hbox.getChildren().setAll(graphic, choiceBox);
cell.setGraphic(hbox);
} else {
cell.setGraphic(choiceBox);
}
} else {
cell.setText(getItemText(cell, converter));
cell.setGraphic(graphic);
}
}
示例3: startEdit
import javafx.scene.control.Cell; //导入依赖的package包/类
static <T> void startEdit(final Cell<T> cell,
final StringConverter<T> converter,
final HBox hbox,
final Node graphic,
final TextField textField
) {
if (textField != null) {
textField.setText(getItemText(cell, converter));
}
cell.setText(null);
if (graphic != null) {
hbox.getChildren().setAll(graphic, textField);
cell.setGraphic(hbox);
} else {
cell.setGraphic(textField);
}
textField.selectAll();
// requesting focus so that key input can immediately go into the
// TextField (see RT-28132)
textField.requestFocus();
}
示例4: updateItem
import javafx.scene.control.Cell; //导入依赖的package包/类
static <T> void updateItem(final Cell<T> cell, final StringConverter<T> converter, final HBox hbox, final Node graphic,
final TextField textField) {
if (cell.isEmpty()) {
cell.setText(null);
cell.setGraphic(null);
} else {
if (cell.isEditing()) {
if (textField != null) {
textField.setText(getItemText(cell, converter));
}
cell.setText(null);
if (graphic != null) {
hbox.getChildren().setAll(graphic, textField);
cell.setGraphic(hbox);
} else {
cell.setGraphic(textField);
}
} else {
cell.setText(getItemText(cell, converter));
cell.setGraphic(graphic);
}
}
}
示例5: startEdit
import javafx.scene.control.Cell; //导入依赖的package包/类
static <T> void startEdit(final Cell<T> cell, final StringConverter<T> converter, final HBox hbox, final Node graphic,
final TextField textField) {
if (textField != null) {
textField.setText(getItemText(cell, converter));
}
cell.setText(null);
if (graphic != null) {
hbox.getChildren().setAll(graphic, textField);
cell.setGraphic(hbox);
} else {
cell.setGraphic(textField);
}
textField.selectAll();
// requesting focus so that key input can immediately go into the
// TextField (see RT-28132)
textField.requestFocus();
}
示例6: createTextField
import javafx.scene.control.Cell; //导入依赖的package包/类
static <T> TextField createTextField(final Cell<T> cell, final StringConverter<T> converter) {
final TextField textField = new TextField();
textField.setPromptText("user password.");
textField.setText(getItemText(cell, converter));
// Use onAction here rather than onKeyReleased (with check for Enter),
// as otherwise we encounter RT-34685
textField.setOnAction(event -> {
if (converter == null) {
throw new IllegalStateException("Attempting to convert text input into Object, but provided "
+ "StringConverter is null. Be sure to set a StringConverter " + "in your cell factory.");
}
cell.commitEdit(converter.fromString(textField.getText()));
event.consume();
});
textField.setOnKeyReleased(t -> {
if (t.getCode() == KeyCode.ESCAPE) {
cell.cancelEdit();
t.consume();
}
});
return textField;
}
示例7: cellWithValue
import javafx.scene.control.Cell; //导入依赖的package包/类
@Factory
public static <T> Matcher<Node> cellWithValue(final Matcher<T> contentsMatcher) {
return new TypeSafeMatcher<Node>(Cell.class) {
@Override
protected boolean matchesSafely(Node item) {
return contentsMatcher.matches(((Cell) item).getItem());
}
@Override
public void describeTo(Description description) {
description.appendText(Cell.class.getSimpleName())
.appendText(" ")
.appendText("with value")
.appendDescriptionOf(contentsMatcher);
}
};
}
示例8: marathon_select
import javafx.scene.control.Cell; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public boolean marathon_select(String value) {
TextInputControl tc = (TextInputControl) getComponent();
Boolean isCellEditor = (Boolean) tc.getProperties().get("marathon.celleditor");
tc.setText("");
if (isCellEditor != null && isCellEditor) {
super.sendKeys(value, JavaAgentKeys.ENTER);
Cell cell = (Cell) tc.getProperties().get("marathon.cell");
cell.commitEdit(value);
} else {
super.sendKeys(value);
}
return true;
}
示例9: createChoiceBox
import javafx.scene.control.Cell; //导入依赖的package包/类
static <T> ChoiceBox<T> createChoiceBox(
final Cell<T> cell,
final ObservableList<T> items,
final ObjectProperty<StringConverter<T>> converter
) {
final ChoiceBox<T> choiceBox = new ChoiceBox<>(items);
choiceBox.setMaxWidth(Double.MAX_VALUE);
choiceBox.converterProperty().bind(converter);
choiceBox.getSelectionModel().selectedItemProperty().addListener((ov, oldValue, newValue) -> {
if (cell.isEditing()) {
cell.commitEdit(newValue);
}
});
return choiceBox;
}
示例10: createComboBox
import javafx.scene.control.Cell; //导入依赖的package包/类
static <T> ComboBox<T> createComboBox(final Cell<T> cell,
final ObservableList<T> items,
final ObjectProperty<StringConverter<T>> converter
) {
final ComboBox<T> comboBox = new ComboBox<>(items);
comboBox.converterProperty().bind(converter);
comboBox.setMaxWidth(Double.MAX_VALUE);
comboBox.getSelectionModel().selectedItemProperty()
.addListener((ov, oldValue, newValue) -> {
if (cell.isEditing()) {
cell.commitEdit(newValue);
}
});
return comboBox;
}
示例11: setCellStyle
import javafx.scene.control.Cell; //导入依赖的package包/类
/** Set style of table cell to reflect optional background color
* @param cell
* @param row Table row
* @param col Table column
*/
private void setCellStyle(Cell<String> cell, final int row, final int col)
{
final Color color = getCellColor(row, col);
if (color == null)
cell.setStyle(null);
else
{ // Based on modena.css
// .table-cell has no -fx-background-color to see overall background,
// but .table-cell:selected uses this to get border with an inset color
cell.setStyle("-fx-background-color: -fx-table-cell-border-color, " + JFXUtil.webRGB(color) +
";-fx-background-insets: 0, 0 0 1 0;");
}
}
示例12: testGetCellAdjuster
import javafx.scene.control.Cell; //导入依赖的package包/类
@Test
public void testGetCellAdjuster() {
Adjuster adjuster = Adjuster.getAdjuster(Cell.class);
assertThat(adjuster, is(instanceOf(ControlAdjuster.class)));
assertThat(adjuster.getNodeClass(), is(sameInstance(Control.class)));
}
示例13: updateItem
import javafx.scene.control.Cell; //导入依赖的package包/类
static <T> void updateItem(final Cell<T> cell,
final StringConverter<T> converter,
final HBox hbox,
final Node graphic,
final TextField textField)
{
if (cell.isEmpty())
{
cell.setText(null);
cell.setGraphic(null);
} else
{
if (cell.isEditing())
{
if (textField != null)
{
textField.setText(getItemText(cell, converter));
}
cell.setText(null);
if (graphic != null)
{
hbox.getChildren().setAll(graphic, textField);
cell.setGraphic(hbox);
} else
{
cell.setGraphic(textField);
}
} else
{
cell.setText(getItemText(cell, converter));
cell.setGraphic(graphic);
}
}
}
示例14: startEdit
import javafx.scene.control.Cell; //导入依赖的package包/类
static <T> void startEdit(final Cell<T> cell,
final StringConverter<T> converter,
final HBox hbox,
final Node graphic,
final TextField textField)
{
if (textField != null)
{
textField.setText(getItemText(cell, converter));
}
cell.setText(null);
if (graphic != null)
{
hbox.getChildren().setAll(graphic, textField);
cell.setGraphic(hbox);
} else
{
cell.setGraphic(textField);
}
textField.selectAll();
// requesting focus so that key input can immediately go into the
// TextField (see RT-28132)
textField.requestFocus();
}
示例15: getItemText
import javafx.scene.control.Cell; //导入依赖的package包/类
private static <T> String getItemText(Cell<T> cell, StringConverter<T> converter) {
return converter == null
? cell.getItem() == null ? "" : cell.getItem().toString()
: converter.toString(cell.getItem());
}