當前位置: 首頁>>代碼示例>>Java>>正文


Java TableColumn.setSortable方法代碼示例

本文整理匯總了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);
}
 
開發者ID:ITB15-S4-GroupD,項目名稱:Planchester,代碼行數:40,代碼來源:EditRequestsController.java

示例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();
}
 
開發者ID:lttng,項目名稱:lttng-scope,代碼行數:76,代碼來源:TableViewTesting.java

示例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);
 }
 
開發者ID:X-Cats,項目名稱:Scout2017,代碼行數:78,代碼來源:ScoutAnalyzerController.java


注:本文中的javafx.scene.control.TableColumn.setSortable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。