T
- この型は、ListViewsのitems
ObservableListに格納されているオブジェクトの型を表す場合に使用されます。また、selection model
およびfocus model
でも使用されます。@DefaultProperty(value="items") public class ListView<T> extends Control
名前のListView (Strings)を作成し、移入する方法の簡単な例を次に示します。
ObservableList<String> names = FXCollections.observableArrayList(
"Julia", "Ian", "Sue", "Matthew", "Hannah", "Stephan", "Denise");
ListView<String> listView = new ListView<String>(names);
ListViewの要素は、items
ObservableList
内に含まれています。このObservableListはListViewによって自動的に監視されるため、ObservableList内でなんらかの変更が発生すると、その変更がListView自体に自動的に表示されます。ObservableList
をListViewコンストラクタに渡すことが現実的でない場合は、単に呼び出してアイテムを設定するアプローチをお薦めします。
ObservableList<T> content = ...
listView.setItems(content);
この最終的な結果として、前述のように、ListViewによって、リストのアイテムを表現するビューが自動的にリフレッシュされます。
次に示す別のアプローチはListViewで許容されていますが、お薦めしません。
List<T> content = ...
getItems().setAll(content);
ここに示したアプローチの問題は、コンテンツ・リストがアイテム・リストにコピーされることです。つまり、その後にコンテンツ・リストに加えられる変更が監視されず、ListViewに視覚的に反映されません。
選択およびフォーカスを追跡するには、SelectionModel
クラスおよびFocusModel
クラスに習熟することが必要です。ListViewはこれらのクラスごとに最大でも1つのインスタンスを保持し、それぞれselectionModel
プロパティおよびfocusModel
プロパティから使用できます。このAPIを使用すると新しい選択モデルを設定できますが、ほとんどの場合は、デフォルトの選択モデルおよびフォーカス・モデルが機能するため、このことは必要ありません。
デフォルトのSelectionModel
は、ListViewのインスタント化がMultipleSelectionModel
抽象クラスの実装の場合に使用されます。ただし、selectionMode
プロパティのAPIドキュメントに示されているように、デフォルト値はSelectionMode.SINGLE
です。デフォルトのListViewインスタンスで複数選択を有効にするには、次のことを行う必要があります。
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
ListViewのビジュアルは、デフォルトのcell factory
を置き換えることで、完全にカスタマイズできます。セル・ファクトリは、ListViewのアイテムを表すために使用されるListCell
インスタンスを生成するために使用されます。カスタム・セルを作成する方法の詳細は、Cell
クラスのドキュメントを参照してください。
このコントロールは値のインライン編集をサポートしており、このセクションでは使用可能なAPIの概要とその使用方法を示します。
まず、通常、セルを編集する場合は、セルを編集しないときとは異なるユーザー・インタフェースが必要となります。このことは、使用するCell
実装によって行います。ListViewの場合、このことはcell factory
によって行います。セルを永続的に編集状態にするか(たとえば、このことはCheckBox
セルでは一般的です)、編集が開始されたとき(たとえば、セルでダブルクリックを受け取ったとき)に別のUIに切り替えるかは任意です。
セルに対する編集がいつリクエストされたかを知るには、単にCell.startEdit()
メソッドをオーバーライドし、セルのtext
プロパティおよびgraphic
プロパティを適切に更新します(たとえば、textをnullに設定し、graphicをTextField
に設定します)。また、編集が完了したときにUIを元の視覚的状態にリセットするようにCell.cancelEdit()
もオーバーライドします。どちらの場合も、スーパー・メソッドを呼び出して、編集モードを開始または終了するために必要なすべての作業をセルで実行するようにすることが重要です。
セルが編集状態になったら、次に、現在行っている編集をコミットまたは取り消す方法を確認しておきましょう。このことは、セル・ファクトリ・プロバイダとしてユーザーが行います。セル実装は、ユーザー入力に基づいて(たとえば、ユーザーがキーボードで[Enter]キーまたは[Esc]キーを押したとき)、編集の終了を認識します。このことが発生したときは、Cell.commitEdit(Object)
またはCell.cancelEdit()
を適切に呼び出す必要があります。
Cell.commitEdit(Object)
を呼び出すと、ListViewに対してイベントが起動され、このイベントはsetOnEditCommit(javafx.event.EventHandler)
を介してEventHandler
を追加することで監視できます。また、edit start
とedit cancel
の編集イベントを監視することもできます。
デフォルトでは、ListView編集コミット・ハンドラはnull以外であり、デフォルトのハンドラでは、現在編集中の行のアイテムのプロパティ値を上書きすることを試みます。このことは、Cell.commitEdit(Object)
メソッドに新しい値が渡され、これが、起動されるListView.EditEvent
を介して編集コミット・ハンドラに渡されると、実行可能になります。これは単に、この値を取得するためのListView.EditEvent.getNewValue()
の呼出しの問題です。
setOnEditCommit(javafx.event.EventHandler)
を独自のEventHandler
とともに呼び出すと、デフォルトのハンドラが削除されることに注意することは非常に重要です。その後、プロパティ(または関連するデータ・ソース)へのライトバックを処理しないかぎり、何も実行されません。このことは、Node.addEventHandler(javafx.event.EventType, javafx.event.EventHandler)
メソッドを使用し、2番目の引数を目的のEventHandler
として、EDIT_COMMIT_EVENT
EventType
を追加することによって回避できます。このメソッドを使用すると、デフォルトの実装は置き換えられず、編集コミットが発生したときに通知されるようになります。
このサマリーでは、よくある質問に対して答えを示すことを意図しています。JavaFXには、かわりにすべての編集要件を処理する、数多くの事前作成のセル・ファクトリが付属しています。これらの事前作成のセル・ファクトリは、javafx.scene.control.cellパッケージにあります。
ListCell
、MultipleSelectionModel
、FocusModel
Type | プロパティと説明 |
---|---|
ObjectProperty<Callback<ListView<T>,ListCell<T>>> |
cellFactory
カスタム・セル・ファクトリを設定すると、すべてのセル作成を遅延する効果があり、セルのすべてのカスタマイズが許可されます。
|
BooleanProperty |
editable
このListViewが編集可能かどうかを指定します - ListViewおよびその中のListCellが両方とも編集可能な場合にのみ、ListCellが編集状態になります。
|
ReadOnlyIntegerProperty |
editingIndex
編集が行われている場合にアイテムの索引が現在ListViewで編集されていることを表し、アイテムが編集されていない場合に-1を表すために使用されるプロパティ。
|
DoubleProperty |
fixedCellSize
このコントロールが指定された値の固定された高さであるセルを持つかどうかを指定します。
|
ObjectProperty<FocusModel<T>> |
focusModel
FocusModelは、ListView内の単一のアイテムのフォーカスを取得および設定できるAPIを提供します。
|
ObjectProperty<ObservableList<T>> |
items
ListViewの基礎となるデータ・モデル。
|
ObjectProperty<EventHandler<ListView.EditEvent<T>>> |
onEditCancel
このイベント・ハンドラは、ユーザーがセルの編集を取り消すと起動されます。
|
ObjectProperty<EventHandler<ListView.EditEvent<T>>> |
onEditCommit
このプロパティは、編集入力が永続化されるアクションをユーザーが実行すると使用されます。
|
ObjectProperty<EventHandler<ListView.EditEvent<T>>> |
onEditStart
このイベント・ハンドラは、ユーザーが編集を正常に開始すると起動されます。
|
ObjectProperty<EventHandler<ScrollToEvent<Integer>>> |
onScrollTo
scrollTo(int) またはscrollTo(Object) を使用してビューのインデックスをスクロールするリクエストがある場合に呼び出されます。 |
ObjectProperty<Orientation> |
orientation
ListView の向き - 水平または垂直を指定できます。 |
ObjectProperty<Node> |
placeholder
表示するコンテンツがリストビューにない場合は、このノードがユーザーに表示されます。
|
ObjectProperty<MultipleSelectionModel<T>> |
selectionModel
SelectionModelには、ListView内の1つまたは複数のアイテムを選択でき、ユーザーがどのアイテムを選択したかを調べることもできるAPIが用意されています。
|
contextMenu、skin、tooltip
background、border、cacheShape、centerShape、height、insets、maxHeight、maxWidth、minHeight、minWidth、opaqueInsets、padding、prefHeight、prefWidth、scaleShape、shape、snapToPixel、width
needsLayout
accessibleHelp、accessibleRoleDescription、accessibleRole、accessibleText、blendMode、boundsInLocal、boundsInParent、cacheHint、cache、clip、cursor、depthTest、disabled、disable、effectiveNodeOrientation、effect、eventDispatcher、focused、focusTraversable、hover、id、inputMethodRequests、layoutBounds、layoutX、layoutY、localToParentTransform、localToSceneTransform、managed、mouseTransparent、nodeOrientation、onContextMenuRequested、onDragDetected、onDragDone、onDragDropped、onDragEntered、onDragExited、onDragOver、onInputMethodTextChanged、onKeyPressed、onKeyReleased、onKeyTyped、onMouseClicked、onMouseDragEntered、onMouseDragExited、onMouseDragged、onMouseDragOver、onMouseDragReleased、onMouseEntered、onMouseExited、onMouseMoved、onMousePressed、onMouseReleased、onRotate、onRotationFinished、onRotationStarted、onScrollFinished、onScroll、onScrollStarted、onSwipeDown、onSwipeLeft、onSwipeRight、onSwipeUp、onTouchMoved、onTouchPressed、onTouchReleased、onTouchStationary、onZoomFinished、onZoom、onZoomStarted、opacity、parent、pickOnBounds、pressed、rotate、rotationAxis、scaleX、scaleY、scaleZ、scene、style、translateX、translateY、translateZ、visible
修飾子と型 | クラスと説明 |
---|---|
static class |
ListView.EditEvent<T>
編集関連イベントを表すために特にListViewで使用される
Event サブクラス。 |
USE_COMPUTED_SIZE、USE_PREF_SIZE
BASELINE_OFFSET_SAME_AS_HEIGHT
コンストラクタと説明 |
---|
ListView()
コンテンツを垂直に積み上げて表示するデフォルトのListViewを作成します。
|
ListView(ObservableList<T> items)
指定された
ObservableList から取得したコンテンツを垂直に積み上げるデフォルトのListViewを作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
ObjectProperty<Callback<ListView<T>,ListCell<T>>> |
cellFactoryProperty()
カスタム・セル・ファクトリを設定すると、すべてのセル作成を遅延する効果があり、セルのすべてのカスタマイズが許可されます。
|
protected Skin<?> |
createDefaultSkin()
このコントロールのデフォルト・スキンの新しいインスタンスを作成します。
|
void |
edit(int itemIndex)
ListViewが
editable である場合、指定されたインデックスのアイテムの編集を開始するようにListViewに指示します。 |
BooleanProperty |
editableProperty()
このListViewが編集可能かどうかを指定します - ListViewおよびその中のListCellが両方とも編集可能な場合にのみ、ListCellが編集状態になります。
|
static <T> EventType<ListView.EditEvent<T>> |
editAnyEvent()
なんらかの編集イベントが発生したことを示すEventType。
|
static <T> EventType<ListView.EditEvent<T>> |
editCancelEvent()
ListViewに対して起動された編集イベントが取り消されたことを示すEventType。
|
static <T> EventType<ListView.EditEvent<T>> |
editCommitEvent()
ListViewに対して起動された編集イベントがコミットされたことを示すEventType。
|
ReadOnlyIntegerProperty |
editingIndexProperty()
編集が行われている場合にアイテムの索引が現在ListViewで編集されていることを表し、アイテムが編集されていない場合に-1を表すために使用されるプロパティ。
|
static <T> EventType<ListView.EditEvent<T>> |
editStartEvent()
ListViewに対して起動された編集イベントが開始されたことを示すEventType。
|
DoubleProperty |
fixedCellSizeProperty()
このコントロールが指定された値の固定された高さであるセルを持つかどうかを指定します。
|
ObjectProperty<FocusModel<T>> |
focusModelProperty()
FocusModelは、ListView内の単一のアイテムのフォーカスを取得および設定できるAPIを提供します。
|
Callback<ListView<T>,ListCell<T>> |
getCellFactory()
現在のセル・ファクトリを返します。
|
static List<CssMetaData<? extends Styleable,?>> |
getClassCssMetaData() |
List<CssMetaData<? extends Styleable,?>> |
getControlCssMetaData() |
int |
getEditingIndex()
ListViewで現在編集中のアイテムのインデックスを返すか、または編集中のアイテムがない場合には-1を返します。
|
double |
getFixedCellSize()
固定セル・サイズ値を返します。
|
FocusModel<T> |
getFocusModel()
現在インストールされている
FocusModel を返します。 |
ObservableList<T> |
getItems()
現在ユーザーに表示されているアイテムを含む
ObservableList を返します。 |
EventHandler<ListView.EditEvent<T>> |
getOnEditCancel()
ユーザーが編集を取り消したときに呼び出される
EventHandler を返します。 |
EventHandler<ListView.EditEvent<T>> |
getOnEditCommit()
ユーザーが編集をコミットしたときに呼び出される
EventHandler を返します。 |
EventHandler<ListView.EditEvent<T>> |
getOnEditStart()
ユーザーが編集を開始したときに呼び出される
EventHandler を返します。 |
EventHandler<ScrollToEvent<Integer>> |
getOnScrollTo()
プロパティonScrollToの値を取得します。
|
Orientation |
getOrientation()
垂直にスクロールするか水平にスクロールするかを決定する、ListViewの現在の向きを返します。
|
Node |
getPlaceholder()
プロパティ・プレースホルダの値を取得します。
|
MultipleSelectionModel<T> |
getSelectionModel()
現在インストールされている選択モデルを返します。
|
boolean |
isEditable()
プロパティeditableの値を取得します。
|
ObjectProperty<ObservableList<T>> |
itemsProperty()
ListViewの基礎となるデータ・モデル。
|
ObjectProperty<EventHandler<ListView.EditEvent<T>>> |
onEditCancelProperty()
このイベント・ハンドラは、ユーザーがセルの編集を取り消すと起動されます。
|
ObjectProperty<EventHandler<ListView.EditEvent<T>>> |
onEditCommitProperty()
このプロパティは、編集入力が永続化されるアクションをユーザーが実行すると使用されます。
|
ObjectProperty<EventHandler<ListView.EditEvent<T>>> |
onEditStartProperty()
このイベント・ハンドラは、ユーザーが編集を正常に開始すると起動されます。
|
ObjectProperty<EventHandler<ScrollToEvent<Integer>>> |
onScrollToProperty()
scrollTo(int) またはscrollTo(Object) を使用してビューのインデックスをスクロールするリクエストがある場合に呼び出されます。 |
ObjectProperty<Orientation> |
orientationProperty()
ListView の向き - 水平または垂直を指定できます。 |
ObjectProperty<Node> |
placeholderProperty()
表示するコンテンツがリストビューにない場合は、このノードがユーザーに表示されます。
|
Object |
queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)
*アクセシビリティ処理* *
|
void |
scrollTo(int index)
ListViewをスクロールして、指定されたインデックスのアイテムがエンド・ユーザーに表示されるようにします。
|
void |
scrollTo(T object)
TableViewをスクロールして、指定されたオブジェクトがビューポート内に表示されるようにします。
|
ObjectProperty<MultipleSelectionModel<T>> |
selectionModelProperty()
SelectionModelには、ListView内の1つまたは複数のアイテムを選択でき、ユーザーがどのアイテムを選択したかを調べることもできるAPIが用意されています。
|
void |
setCellFactory(Callback<ListView<T>,ListCell<T>> value)
ListViewで使用する新規セル・ファクトリを設定します。
|
void |
setEditable(boolean value)
プロパティeditableの値を設定します。
|
void |
setFixedCellSize(double value)
このコントロールの新しい固定セル・サイズを設定します。
|
void |
setFocusModel(FocusModel<T> value)
ListViewで使用する
FocusModel を設定します。 |
void |
setItems(ObservableList<T> value)
ListViewの基礎となるデータ・モデルを設定します。
|
void |
setOnEditCancel(EventHandler<ListView.EditEvent<T>> value)
ユーザーが編集を取り消したときに呼び出される
EventHandler を設定します。 |
void |
setOnEditCommit(EventHandler<ListView.EditEvent<T>> value)
ユーザーが編集を完了したときに呼び出される
EventHandler を設定します。 |
void |
setOnEditStart(EventHandler<ListView.EditEvent<T>> value)
ユーザーが編集を開始したときに呼び出される
EventHandler を設定します。 |
void |
setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value)
プロパティonScrollToの値を設定します。
|
void |
setOrientation(Orientation value)
垂直にスクロールするか水平にスクロールするかを決定する、ListViewの向きを設定します。
|
void |
setPlaceholder(Node value)
プロパティ・プレースホルダの値を設定します。
|
void |
setSelectionModel(MultipleSelectionModel<T> value)
ListViewに使用される
MultipleSelectionModel を設定します。 |
computeMaxHeight、computeMaxWidth、computeMinHeight、computeMinWidth、computePrefHeight、computePrefWidth、contextMenuProperty、executeAccessibleAction、getBaselineOffset、getContextMenu、getCssMetaData、getSkin、getTooltip、isResizable、layoutChildren、setContextMenu、setSkin、setTooltip、skinProperty、tooltipProperty
backgroundProperty、borderProperty、cacheShapeProperty、centerShapeProperty、getBackground、getBorder、getHeight、getInsets、getMaxHeight、getMaxWidth、getMinHeight、getMinWidth、getOpaqueInsets、getPadding、getPrefHeight、getPrefWidth、getShape、getUserAgentStylesheet、getWidth、heightProperty、insetsProperty、isCacheShape、isCenterShape、isScaleShape、isSnapToPixel、layoutInArea、layoutInArea、layoutInArea、layoutInArea、maxHeight、maxHeightProperty、maxWidth、maxWidthProperty、minHeight、minHeightProperty、minWidth、minWidthProperty、opaqueInsetsProperty、paddingProperty、positionInArea、positionInArea、prefHeight、prefHeightProperty、prefWidth、prefWidthProperty、resize、scaleShapeProperty、setBackground、setBorder、setCacheShape、setCenterShape、setHeight、setMaxHeight、setMaxSize、setMaxWidth、setMinHeight、setMinSize、setMinWidth、setOpaqueInsets、setPadding、setPrefHeight、setPrefSize、setPrefWidth、setScaleShape、setShape、setSnapToPixel、setWidth、shapeProperty、snappedBottomInset、snappedLeftInset、snappedRightInset、snappedTopInset、snapPosition、snapSize、snapSpace、snapToPixelProperty、widthProperty
getChildren、getChildrenUnmodifiable、getManagedChildren、getStylesheets、isNeedsLayout、layout、lookup、needsLayoutProperty、requestLayout、requestParentLayout、setNeedsLayout、updateBounds
accessibleHelpProperty、accessibleRoleDescriptionProperty、accessibleRoleProperty、accessibleTextProperty、addEventFilter、addEventHandler、applyCss、autosize、blendModeProperty、boundsInLocalProperty、boundsInParentProperty、buildEventDispatchChain、cacheHintProperty、cacheProperty、clipProperty、computeAreaInScreen、contains、contains、cursorProperty、depthTestProperty、disabledProperty、disableProperty、effectiveNodeOrientationProperty、effectProperty、eventDispatcherProperty、fireEvent、focusedProperty、focusTraversableProperty、getAccessibleHelp、getAccessibleRole、getAccessibleRoleDescription、getAccessibleText、getBlendMode、getBoundsInLocal、getBoundsInParent、getCacheHint、getClip、getContentBias、getCursor、getDepthTest、getEffect、getEffectiveNodeOrientation、getEventDispatcher、getId、getInputMethodRequests、getLayoutBounds、getLayoutX、getLayoutY、getLocalToParentTransform、getLocalToSceneTransform、getNodeOrientation、getOnContextMenuRequested、getOnDragDetected、getOnDragDone、getOnDragDropped、getOnDragEntered、getOnDragExited、getOnDragOver、getOnInputMethodTextChanged、getOnKeyPressed、getOnKeyReleased、getOnKeyTyped、getOnMouseClicked、getOnMouseDragEntered、getOnMouseDragExited、getOnMouseDragged、getOnMouseDragOver、getOnMouseDragReleased、getOnMouseEntered、getOnMouseExited、getOnMouseMoved、getOnMousePressed、getOnMouseReleased、getOnRotate、getOnRotationFinished、getOnRotationStarted、getOnScroll、getOnScrollFinished、getOnScrollStarted、getOnSwipeDown、getOnSwipeLeft、getOnSwipeRight、getOnSwipeUp、getOnTouchMoved、getOnTouchPressed、getOnTouchReleased、getOnTouchStationary、getOnZoom、getOnZoomFinished、getOnZoomStarted、getOpacity、getParent、getProperties、getPseudoClassStates、getRotate、getRotationAxis、getScaleX、getScaleY、getScaleZ、getScene、getStyle、getStyleableParent、getStyleClass、getTransforms、getTranslateX、getTranslateY、getTranslateZ、getTypeSelector、getUserData、hasProperties、hoverProperty、idProperty、inputMethodRequestsProperty、intersects、intersects、isCache、isDisable、isDisabled、isFocused、isFocusTraversable、isHover、isManaged、isMouseTransparent、isPickOnBounds、isPressed、isVisible、layoutBoundsProperty、layoutXProperty、layoutYProperty、localToParent、localToParent、localToParent、localToParent、localToParent、localToParentTransformProperty、localToScene、localToScene、localToScene、localToScene、localToScene、localToScene、localToScene、localToScene、localToScene、localToScene、localToSceneTransformProperty、localToScreen、localToScreen、localToScreen、localToScreen、localToScreen、lookupAll、managedProperty、mouseTransparentProperty、nodeOrientationProperty、notifyAccessibleAttributeChanged、onContextMenuRequestedProperty、onDragDetectedProperty、onDragDoneProperty、onDragDroppedProperty、onDragEnteredProperty、onDragExitedProperty、onDragOverProperty、onInputMethodTextChangedProperty、onKeyPressedProperty、onKeyReleasedProperty、onKeyTypedProperty、onMouseClickedProperty、onMouseDragEnteredProperty、onMouseDragExitedProperty、onMouseDraggedProperty、onMouseDragOverProperty、onMouseDragReleasedProperty、onMouseEnteredProperty、onMouseExitedProperty、onMouseMovedProperty、onMousePressedProperty、onMouseReleasedProperty、onRotateProperty、onRotationFinishedProperty、onRotationStartedProperty、onScrollFinishedProperty、onScrollProperty、onScrollStartedProperty、onSwipeDownProperty、onSwipeLeftProperty、onSwipeRightProperty、onSwipeUpProperty、onTouchMovedProperty、onTouchPressedProperty、onTouchReleasedProperty、onTouchStationaryProperty、onZoomFinishedProperty、onZoomProperty、onZoomStartedProperty、opacityProperty、parentProperty、parentToLocal、parentToLocal、parentToLocal、parentToLocal、parentToLocal、pickOnBoundsProperty、pressedProperty、pseudoClassStateChanged、relocate、removeEventFilter、removeEventHandler、requestFocus、resizeRelocate、rotateProperty、rotationAxisProperty、scaleXProperty、scaleYProperty、scaleZProperty、sceneProperty、sceneToLocal、sceneToLocal、sceneToLocal、sceneToLocal、sceneToLocal、sceneToLocal、sceneToLocal、sceneToLocal、screenToLocal、screenToLocal、screenToLocal、setAccessibleHelp、setAccessibleRole、setAccessibleRoleDescription、setAccessibleText、setBlendMode、setCache、setCacheHint、setClip、setCursor、setDepthTest、setDisable、setDisabled、setEffect、setEventDispatcher、setEventHandler、setFocused、setFocusTraversable、setHover、setId、setInputMethodRequests、setLayoutX、setLayoutY、setManaged、setMouseTransparent、setNodeOrientation、setOnContextMenuRequested、setOnDragDetected、setOnDragDone、setOnDragDropped、setOnDragEntered、setOnDragExited、setOnDragOver、setOnInputMethodTextChanged、setOnKeyPressed、setOnKeyReleased、setOnKeyTyped、setOnMouseClicked、setOnMouseDragEntered、setOnMouseDragExited、setOnMouseDragged、setOnMouseDragOver、setOnMouseDragReleased、setOnMouseEntered、setOnMouseExited、setOnMouseMoved、setOnMousePressed、setOnMouseReleased、setOnRotate、setOnRotationFinished、setOnRotationStarted、setOnScroll、setOnScrollFinished、setOnScrollStarted、setOnSwipeDown、setOnSwipeLeft、setOnSwipeRight、setOnSwipeUp、setOnTouchMoved、setOnTouchPressed、setOnTouchReleased、setOnTouchStationary、setOnZoom、setOnZoomFinished、setOnZoomStarted、setOpacity、setPickOnBounds、setPressed、setRotate、setRotationAxis、setScaleX、setScaleY、setScaleZ、setStyle、setTranslateX、setTranslateY、setTranslateZ、setUserData、setVisible、snapshot、snapshot、startDragAndDrop、startFullDrag、styleProperty、toBack、toFront、toString、translateXProperty、translateYProperty、translateZProperty、usesMirroring、visibleProperty
public final ObjectProperty<ObservableList<T>> itemsProperty
public final ObjectProperty<Node> placeholderProperty
getPlaceholder()
、setPlaceholder(Node)
public final ObjectProperty<MultipleSelectionModel<T>> selectionModelProperty
public final ObjectProperty<FocusModel<T>> focusModelProperty
public final ObjectProperty<Orientation> orientationProperty
ListView
の向き - 水平または垂直を指定できます。public final ObjectProperty<Callback<ListView<T>,ListCell<T>>> cellFactoryProperty
カスタム・セル・ファクトリを設定すると、すべてのセル作成を遅延する効果があり、セルのすべてのカスタマイズが許可されます。内部的には、ListViewによってListCellが再利用されます。カスタム・セル・ファクトリにとって必要なことは、ListViewの任意のアイテムを表すために使用できるListCellをこの関数から返すことのみです。
詳細は、Cell
クラスのドキュメントを参照してください。
public final DoubleProperty fixedCellSizeProperty
CSSでこのプロパティを設定するには、-fx-fixed-cell-sizeプロパティを使用します。これを-fx-cell-sizeプロパティと混同しないでください。この2つのCSSプロパティ間の違いは、-fx-cell-sizeではすべてのセルを指定されたサイズに設定しますが、これが唯一のサイズとはならないことです(このため、可変セル・サイズが許容され、パフォーマンスの向上を妨げる可能性があります)。このため、パフォーマンスを重視する場合は、-fx-cell-sizeではなく-fx-fixed-cell-sizeを使用してください。CSSに両方のプロパティを指定した場合は、-fx-fixed-cell-sizeが優先されます。
getFixedCellSize()
、setFixedCellSize(double)
public final BooleanProperty editableProperty
public final ReadOnlyIntegerProperty editingIndexProperty
編集が行われている場合にアイテムの索引が現在ListViewで編集されていることを表し、アイテムが編集されていない場合に-1を表すために使用されるプロパティ。
編集インデックスを設定することはできません。かわりに、edit(int)
を呼び出す必要があります。
getEditingIndex()
public final ObjectProperty<EventHandler<ListView.EditEvent<T>>> onEditStartProperty
public final ObjectProperty<EventHandler<ListView.EditEvent<T>>> onEditCommitProperty
このプロパティは、編集入力が永続化されるアクションをユーザーが実行すると使用されます。
このプロパティのEventHandlerを直接呼び出さないでください。かわりに、カスタムListCell内からListCell.commitEdit(java.lang.Object)
を呼び出します。これは、このイベントの作成、ビューの更新および編集状態の切替えを処理します。
public final ObjectProperty<EventHandler<ListView.EditEvent<T>>> onEditCancelProperty
public ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty
scrollTo(int)
またはscrollTo(Object)
を使用してビューのインデックスをスクロールするリクエストがある場合に呼び出されます。getOnScrollTo()
、setOnScrollTo(EventHandler)
public ListView()
ObservableList
が用意されていないため、空のObservableListが作成されます。つまり、必要に応じて直接getItems()
を呼び出すことができます。ただし、すでに説明したように、このアプローチはお薦めしません(かわりに、setItems(javafx.collections.ObservableList)
を呼び出してください)。
他のプロパティのデフォルト状態の詳細は、ListView
クラスのドキュメントを参照してください。
public ListView(ObservableList<T> items)
ObservableList
から取得したコンテンツを垂直に積み上げるデフォルトのListViewを作成します。
その後リストに加えられるすべての変更がユーザーに表示されるように、リスナーをObservableList
に追加することを試みます。
他のプロパティのデフォルト状態の詳細は、ListView
クラスのドキュメントを参照してください。
public static <T> EventType<ListView.EditEvent<T>> editAnyEvent()
EDIT_START_EVENT
、EDIT_COMMIT_EVENT
、EDIT_CANCEL_EVENT
の他のすべての編集イベントの親タイプです。public static <T> EventType<ListView.EditEvent<T>> editStartEvent()
public static <T> EventType<ListView.EditEvent<T>> editCancelEvent()
public static <T> EventType<ListView.EditEvent<T>> editCommitEvent()
public final void setItems(ObservableList<T> value)
public final ObservableList<T> getItems()
ObservableList
を返します。setItems(javafx.collections.ObservableList)
が以前に呼び出されたことがある場合、これはnullになることがあります。ただし、デフォルトでは空のObservableListになります。public final ObjectProperty<ObservableList<T>> itemsProperty()
public final ObjectProperty<Node> placeholderProperty()
getPlaceholder()
、setPlaceholder(Node)
public final void setPlaceholder(Node value)
public final Node getPlaceholder()
public final void setSelectionModel(MultipleSelectionModel<T> value)
MultipleSelectionModel
を設定します。MultipleSelectionModelを必要とするListViewでも、単一選択のみを許可するように構成できます(詳細は、MultipleSelectionModel.setSelectionMode(javafx.scene.control.SelectionMode)
を参照)。public final MultipleSelectionModel<T> getSelectionModel()
public final ObjectProperty<MultipleSelectionModel<T>> selectionModelProperty()
public final void setFocusModel(FocusModel<T> value)
FocusModel
を設定します。public final FocusModel<T> getFocusModel()
FocusModel
を返します。public final ObjectProperty<FocusModel<T>> focusModelProperty()
public final void setOrientation(Orientation value)
public final Orientation getOrientation()
public final ObjectProperty<Orientation> orientationProperty()
ListView
の向き - 水平または垂直を指定できます。public final void setCellFactory(Callback<ListView<T>,ListCell<T>> value)
ListCell
が破棄され、新しいセル・ファクトリで新しいListCellが作成されます。public final ObjectProperty<Callback<ListView<T>,ListCell<T>>> cellFactoryProperty()
カスタム・セル・ファクトリを設定すると、すべてのセル作成を遅延する効果があり、セルのすべてのカスタマイズが許可されます。内部的には、ListViewによってListCellが再利用されます。カスタム・セル・ファクトリにとって必要なことは、ListViewの任意のアイテムを表すために使用できるListCellをこの関数から返すことのみです。
詳細は、Cell
クラスのドキュメントを参照してください。
public final void setFixedCellSize(double value)
value
- 新しい固定セル・サイズ値。無効にするには、ゼロ以下の値(または、Region.USE_COMPUTED_SIZE)にします。public final double getFixedCellSize()
public final DoubleProperty fixedCellSizeProperty()
CSSでこのプロパティを設定するには、-fx-fixed-cell-sizeプロパティを使用します。これを-fx-cell-sizeプロパティと混同しないでください。この2つのCSSプロパティ間の違いは、-fx-cell-sizeではすべてのセルを指定されたサイズに設定しますが、これが唯一のサイズとはならないことです(このため、可変セル・サイズが許容され、パフォーマンスの向上を妨げる可能性があります)。このため、パフォーマンスを重視する場合は、-fx-cell-sizeではなく-fx-fixed-cell-sizeを使用してください。CSSに両方のプロパティを指定した場合は、-fx-fixed-cell-sizeが優先されます。
getFixedCellSize()
、setFixedCellSize(double)
public final void setEditable(boolean value)
public final boolean isEditable()
public final BooleanProperty editableProperty()
public final int getEditingIndex()
public final ReadOnlyIntegerProperty editingIndexProperty()
編集が行われている場合にアイテムの索引が現在ListViewで編集されていることを表し、アイテムが編集されていない場合に-1を表すために使用されるプロパティ。
編集インデックスを設定することはできません。かわりに、edit(int)
を呼び出す必要があります。
getEditingIndex()
public final void setOnEditStart(EventHandler<ListView.EditEvent<T>> value)
EventHandler
を設定します。
これはコンビニエンス・メソッドです。addEventHandler(ListView.EDIT_START_EVENT, eventHandler)
を呼び出して同じ結果を得ることができます。
public final EventHandler<ListView.EditEvent<T>> getOnEditStart()
EventHandler
を返します。public final ObjectProperty<EventHandler<ListView.EditEvent<T>>> onEditStartProperty()
public final void setOnEditCommit(EventHandler<ListView.EditEvent<T>> value)
EventHandler
を設定します。これは、ListCell.commitEdit(java.lang.Object)
メソッドの一部として呼び出されます。
これはコンビニエンス・メソッドです。addEventHandler(ListView.EDIT_START_EVENT, eventHandler)
を呼び出して同じ結果を得ることができます。
public final EventHandler<ListView.EditEvent<T>> getOnEditCommit()
EventHandler
を返します。public final ObjectProperty<EventHandler<ListView.EditEvent<T>>> onEditCommitProperty()
このプロパティは、編集入力が永続化されるアクションをユーザーが実行すると使用されます。
このプロパティのEventHandlerを直接呼び出さないでください。かわりに、カスタムListCell内からListCell.commitEdit(java.lang.Object)
を呼び出します。これは、このイベントの作成、ビューの更新および編集状態の切替えを処理します。
public final void setOnEditCancel(EventHandler<ListView.EditEvent<T>> value)
EventHandler
を設定します。public final EventHandler<ListView.EditEvent<T>> getOnEditCancel()
EventHandler
を返します。public final ObjectProperty<EventHandler<ListView.EditEvent<T>>> onEditCancelProperty()
public void edit(int itemIndex)
editable
である場合、指定されたインデックスのアイテムの編集を開始するようにListViewに指示します。このメソッドが呼び出されると、現在のcellFactoryProperty()
が編集をサポートするように設定されている場合には、ユーザー入力が有効になるようにCellの視覚的状態が切り替わります。itemIndex
- 編集対象のListViewのアイテムのインデックス。public void scrollTo(int index)
index
- ユーザーに表示されるようにするインデックス。0以上で、かつ、指定されたListView内に含まれているアイテム・リストのサイズ未満であることを想定しています。public void scrollTo(T object)
object
- ユーザーに表示するオブジェクト。public void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value)
scrollTo(int)
またはscrollTo(Object)
を使用してビューのインデックスをスクロールするリクエストがある場合に呼び出されます。public EventHandler<ScrollToEvent<Integer>> getOnScrollTo()
scrollTo(int)
またはscrollTo(Object)
を使用してビューのインデックスをスクロールするリクエストがある場合に呼び出されます。public ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty()
scrollTo(int)
またはscrollTo(Object)
を使用してビューのインデックスをスクロールするリクエストがある場合に呼び出されます。getOnScrollTo()
、setOnScrollTo(EventHandler)
protected Skin<?> createDefaultSkin()
-fx-skin
を介してスキンが提供されていない場合にコントロール用のスキンを作成するために、またはsetSkin(...)
を使用してサブクラスで明示的に設定するために呼び出されます。createDefaultSkin
、クラス: Control
public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
public List<CssMetaData<? extends Styleable,?>> getControlCssMetaData()
getControlCssMetaData
、クラス: Control
public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)
queryAccessibleAttribute
、クラス: Control
attribute
- リクエストされた属性parameters
- オプションのパラメータ・リストAccessibleAttribute
Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.