本文整理汇总了Java中javafx.scene.control.TableColumn.setSortable方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumn.setSortable方法的具体用法?Java TableColumn.setSortable怎么用?Java TableColumn.setSortable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TableColumn
的用法示例。
在下文中一共展示了TableColumn.setSortable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createColumns
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
private void createColumns() {
TableColumn<RequestEntry, String> eventTypeCol = new TableColumn("Type");
eventTypeCol.setMinWidth(100);
eventTypeCol.setCellValueFactory(new PropertyValueFactory<>("eventType"));
eventTypeCol.setSortable(false);
TableColumn<RequestEntry, String> eventNameCol = new TableColumn("Name");
eventNameCol.setMinWidth(100);
eventNameCol.setCellValueFactory(new PropertyValueFactory<>("eventName"));
eventNameCol.setSortable(false);
TableColumn<RequestEntry, String> eventDateTimeCol = new TableColumn("Time");
eventDateTimeCol.setMinWidth(200);
eventDateTimeCol.setCellValueFactory(new PropertyValueFactory<>("eventDateTime"));
eventDateTimeCol.setSortable(false);
TableColumn<RequestEntry, String> eventLocationCol = new TableColumn("Location");
eventLocationCol.setMinWidth(100);
eventLocationCol.setCellValueFactory(new PropertyValueFactory<>("eventLocation"));
eventLocationCol.setSortable(false);
TableColumn<RequestEntry, String> eventConductorCol = new TableColumn("Conductor");
eventConductorCol.setMinWidth(100);
eventConductorCol.setCellValueFactory(new PropertyValueFactory<>("eventConductor"));
eventConductorCol.setSortable(false);
TableColumn<RequestEntry, RequestTypeGUI> requestTypeCol = new TableColumn("Request");
requestTypeCol.setCellFactory((param) -> new RequestRadioButtonCell<>(EnumSet.allOf(RequestTypeGUI.class)));
requestTypeCol.setCellValueFactory(new PropertyValueFactory<>("requestType"));
requestTypeCol.setSortable(false);
TableColumn<RequestEntry, TextField> eventDescriptionCol = new TableColumn("Description");
eventDescriptionCol.setMinWidth(300);
eventDescriptionCol.setCellValueFactory(new PropertyValueFactory<RequestEntry, TextField>("requestDescription"));
eventDescriptionCol.setResizable(false);
eventDescriptionCol.setSortable(false);
table.getColumns().addAll(eventTypeCol, eventNameCol, eventDateTimeCol, eventLocationCol, eventConductorCol, requestTypeCol, eventDescriptionCol);
}
示例2: start
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) {
if (primaryStage == null) {
return;
}
DirectoryChooser dirChooser = new DirectoryChooser();
dirChooser.setTitle("Select CTF trace directory");
File dir = dirChooser.showDialog(primaryStage);
if (dir == null) {
return;
}
Path tracePath = dir.toPath();
CtfTrace trace = new CtfTrace(tracePath);
// FIXME Reading all events into memory
List<CtfTraceEvent> events = new ArrayList<>();
try (TraceIterator<CtfTraceEvent> iter = trace.iterator()) {
Iterators.addAll(events, iter);
}
ObservableList<CtfTraceEvent> eventList = FXCollections.observableList(events);
/* Setup the filter text field */
TextField filterField = new TextField();
FilteredList<CtfTraceEvent> filteredData = new FilteredList<>(eventList, p -> true);
filterField.textProperty().addListener((observable, oldValue, newValue) -> {
filteredData.setPredicate(event -> {
// If filter text is empty, display everything
if (newValue == null || newValue.isEmpty()) {
return true;
}
if (event.toString().toLowerCase().contains(newValue.toLowerCase())) {
return true;
}
return false;
});
});
/* Setup the table */
TableColumn<CtfTraceEvent, String> col1 = new TableColumn<>("Timestamp");
col1.setCellValueFactory(p -> new ReadOnlyObjectWrapper(p.getValue().getTimestamp()));
col1.setSortable(false);
TableColumn<CtfTraceEvent, String> col2 = new TableColumn<>("CPU");
col2.setCellValueFactory(p -> new ReadOnlyObjectWrapper(p.getValue().getCpu()));
col2.setSortable(false);
TableColumn<CtfTraceEvent, String> col3 = new TableColumn<>("All");
col3.setCellValueFactory(p -> new ReadOnlyObjectWrapper(p.getValue().toString()));
col3.setSortable(false);
TableView<CtfTraceEvent> tableView = new TableView<>();
tableView.setFixedCellSize(24);
tableView.setCache(true);
tableView.setCacheHint(CacheHint.SPEED);
tableView.getColumns().addAll(col1, col2, col3);
tableView.setItems(filteredData);
/* Setup the full scene */
Label filterLabel = new Label("Filter:");
filterLabel.setPadding(new Insets(5));
HBox filterBox = new HBox(filterLabel, filterField);
filterBox.setAlignment(Pos.CENTER_LEFT);
filterBox.setPadding(new Insets(5));
BorderPane borderPane = new BorderPane();
borderPane.setTop(filterBox);
borderPane.setCenter(tableView);
primaryStage.setScene(new Scene(borderPane, 800, 350));
primaryStage.setTitle("tableview");
primaryStage.show();
}
示例3: updateRankTable
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
@FXML
public void updateRankTable(){
double oldMaxBall = 0;
double oldMaxClimb = 0;
double oldMaxGear = 0;
genTeamList();
TableColumn<TeamPerf, Number> placeCol = new TableColumn<>("Place");
TableColumn<TeamPerf, Number> numCol = new TableColumn<>("Team #");
TableColumn<TeamPerf, String> nameCol = new TableColumn<>("Team Name");
TableColumn<TeamPerf, Number> gearModCol = new TableColumn<>("Avg. # of Gears (Mod.)");
TableColumn<TeamPerf, Number> gearCenterCol = new TableColumn<>("Auto Gear in Center");
TableColumn<TeamPerf, Number> gearSideCol = new TableColumn<>("Auto Gear on Side");
TableColumn<TeamPerf, Number> ballModCol = new TableColumn<>("Avg. # of Balls (Mod.)");
TableColumn<TeamPerf, Number> gearTotalCol = new TableColumn<>("Total # of Gears Placed");
TableColumn<TeamPerf, Number> climbPercentage = new TableColumn<>("Climb Percentage");
TableColumn<TeamPerf, Number> rankCol = new TableColumn<>("Raw Rank");
for(int i = 0; i < teamNames.size(); i++){
String teamNum = teamNames.get(i).substring(0, teamNames.get(i).indexOf(" "));
ArrayList<Integer> matches = new ArrayList<>();
ArrayList<Integer> gears = new ArrayList<>();
ArrayList<Integer> balls = new ArrayList<>();
ArrayList<Boolean> climb = new ArrayList<>();
ArrayList<Boolean> autoSide = new ArrayList<>();
ArrayList<Boolean> autoCenter = new ArrayList<>();
String dataQuery = "SELECT matchnum,teleopgearsplaced,teleballs,climb,autogearleft,autogearright,autogearcenter FROM " + Main.getCurrentSchema() + ".match_team_performance WHERE teamnum = " + teamNum + " ORDER BY matchnum;";
dbread.setQuery(dataQuery);
dbread.executeQuery();
ResultSet RS = dbread.rs;
try {
while(RS.next()){
matches.add(RS.getInt(1));
gears.add(RS.getInt(2));
balls.add(RS.getInt(3));
climb.add(RS.getBoolean(4));
autoSide.add(RS.getBoolean(5) || RS.getBoolean(6));
autoCenter.add(RS.getBoolean(7));
System.out.println(autoCenter);
}
TeamPerf newTeamPerf = new TeamPerf(Integer.parseInt(teamNum), teamNames.get(i).substring(teamNames.get(i).lastIndexOf("- ")+2), gears, matches,balls,climb,autoCenter, autoSide, 1);
if(newTeamPerf.getClimbPerc() > oldMaxClimb) oldMaxClimb = newTeamPerf.getClimbPerc();
if(newTeamPerf.getAvgGearMod() > oldMaxGear) oldMaxGear = newTeamPerf.getAvgGearMod();
if(newTeamPerf.getAvgBallMod() > oldMaxBall) oldMaxBall = newTeamPerf.getAvgBallMod();
teamPerf.add(newTeamPerf);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
placeCol.setSortable(false);
final double maxBall = oldMaxBall;
System.out.println(oldMaxBall);
final double maxGear = oldMaxGear;
System.out.println(maxGear);
final double maxClimb = oldMaxClimb;
System.out.println(maxClimb);
placeCol.setCellValueFactory(column -> new ReadOnlyObjectWrapper<Number>(1 + rankTable.getItems().indexOf(column.getValue())));
numCol.setCellValueFactory(c -> new SimpleIntegerProperty(c.getValue().getTeamNum()));
nameCol.setCellValueFactory(c -> new SimpleStringProperty(c.getValue().getTeamName()));
ballModCol.setCellValueFactory(c -> new SimpleDoubleProperty(c.getValue().getAvgBallMod()));
gearModCol.setCellValueFactory(c -> new SimpleDoubleProperty(c.getValue().getAvgGearMod()));
gearTotalCol.setCellValueFactory(c -> new SimpleIntegerProperty(c.getValue().getGearSum()));
rankCol.setCellValueFactory(c -> new SimpleDoubleProperty(c.getValue().calcRank(maxBall,maxGear,maxClimb)*100.0));
climbPercentage.setCellValueFactory(c -> new SimpleDoubleProperty(c.getValue().getClimbPerc()));
gearCenterCol.setCellValueFactory(c -> new SimpleDoubleProperty(c.getValue().getCenterSum()));
gearSideCol.setCellValueFactory(c -> new SimpleDoubleProperty(c.getValue().getSideSum()));
//Remove old data to avoid duplicates
rankTable.getColumns().removeAll(rankTable.getColumns());
rankTable.getItems().clear();
//Now add the new data
rankTable.getItems().addAll(teamPerf);
//Finally add the rows. TODO Make this effected by the treeview on the side. Currently very quick and dirty.
rankTable.getColumns().addAll(placeCol,numCol,nameCol,gearModCol,gearTotalCol,rankCol,climbPercentage,ballModCol,gearCenterCol,gearSideCol);
}