JAVA FX TAB功能

时间:2018-03-10 09:12:30

标签: java function javafx methods tabs

我的问题是如果已经打开则禁用新标签,如果在菜单项上再次选中已打开标签,则将焦点设置在原始内容上。

enter image description here

public class TapsMainController extends SANodeController {

    BorderPane BP;
    Tab tb;

    public static synchronized TapsMainController getInstance() {
        return newInstance(TapsMainController.class.getResource("/ph/softartifact/taps/client/fx/bpar/view/TapsMain.fxml"));
    }
    @FXML
    private MenuBar MenuBar;
    @FXML
    private Menu Menu;
    @FXML
    private MenuItem EmpReg;
    @FXML
    private MenuItem EmpApproval;
    @FXML
    private TabPane TB;

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        EmpReg.setOnAction(e -> empReg());
        EmpApproval.setOnAction(e -> empApproval());

    }

    @Override
    public void postComponentInit() {

    }

    public void empReg() {
        EmployeeRegistrationController ER = EmployeeRegistrationController.getInstance();
        SingleSelectionModel<Tab> selectionModel = TB.getSelectionModel();
        ER.setSAPlatBridge(new UserPlatBridge(), null, null);
        ER.postComponentInit();
        BP = new BorderPane();
        tb = new Tab();
        selectionModel.select(tb);
        TB.getTabs().add(tb);
        tb.setContent(BP);
        tb.setText("Employee Registration");
        BP.setCenter(ER.getFxmlNode());

    }

    public void empApproval() {
        EmployeeeApprovalController ER = EmployeeeApprovalController.getInstance();
        SingleSelectionModel<Tab> selectionModel = TB.getSelectionModel();
        ER.setSAPlatBridge(new UserPlatBridge(), null, null);
        ER.postComponentInit();
        BP = new BorderPane();
        tb = new Tab();
        selectionModel.select(tb);
        TB.getTabs().add(tb);
        tb.setContent(BP);
        tb.setText("Employee Approval and Revision");
        BP.setCenter(ER.getFxmlNode());
    }

}

0 个答案:

没有答案