コード例 #1
0
  public MainStageController(Controller controller) {
    this.controller = controller;
    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainStage.fxml"));
    fxmlLoader.setController(this);
    try {
      root = fxmlLoader.load();
    } catch (IOException e) {
      e.printStackTrace();
    }

    currentUserMenuButton.setText(controller.getCurrentUser().getName());
    collectAccountTable();
    accountsTable
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            new ChangeListener<Account>() {
              @Override
              public void changed(
                  ObservableValue<? extends Account> observable,
                  Account oldValue,
                  Account newValue) {
                controller.setCurrentAccount(accountsTable.getSelectionModel().getSelectedItem());
                showRecords(controller.getCurrentAccount());
                showBalanceLabel();
              }
            });

    showRecords(controller.getCurrentAccount());
    showBalanceLabel();
  }
コード例 #2
0
ファイル: ButtonBar.java プロジェクト: vanwang/MyExpenses
 public MenuButton addButton(int text, int drawable, int id) {
   LayoutInflater inflater = LayoutInflater.from(getContext());
   MenuButton b = (MenuButton) inflater.inflate(R.layout.button, this, false);
   b.setBackgroundResourceKeepPadding(buttonBackgroundNormalId);
   b.setText(text);
   b.setId(id);
   if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
     b.setCompoundDrawablesWithIntrinsicBounds(drawable, 0, 0, 0);
   } else {
     b.setCompoundDrawablesWithIntrinsicBounds(0, drawable, 0, 0);
   }
   addView(b);
   b.setOnClickListener((MyExpenses) getContext());
   b.setOnLongClickListener((MyExpenses) getContext());
   return b;
 }