Exemplo n.º 1
0
  private GridPane getTopPane() {
    topPane = new GridPane();

    // Top pane
    Label DateL = new Label("Date");
    Label surveyDateL = new Label("Surveyed Date");
    Label NameL = new Label("Name");
    Label spouseNameL = new Label("Spouse Name");
    Label addressL = new Label("Address");
    Label ageL = new Label("Age");
    Label yearofResidencyL = new Label("Year of Residency");
    Label numofChildrenL = new Label("Number of Children");

    // search nodes declaration

    // topPane nodes declaration
    dateField = new TextField(Utility.getCurrentDate());

    datePicker = new DatePicker();
    Name = new TextField();
    SpouseName = new TextField();
    agefield = new TextField();
    addressF = new TextField();
    yrResidency = new TextField();
    numofChildrenF = new TextField();

    // nodes initialization
    dateField.setAlignment(Pos.CENTER);
    dateField.setDisable(true);
    numofChildrenF.setText("0");

    Name.setPromptText("First Name");
    LastName.setPromptText("Last Name");
    MidlleName.setPromptText("Middle Name");

    SpouseName.setPromptText("Spouse Full Name");
    agefield.setPromptText("35");
    addressF.setPromptText("e.g 12345 Manga st. Mabalacat");
    yrResidency.setPromptText("e.g 2012");
    numofChildrenF.setPromptText("Number of children");

    SpouseName.setDisable(true);

    maritalCBox = new ComboBox(getMaritalStatus());
    barangayCb = new ComboBox(getBarangayListModel());
    genderCB = new ComboBox(getGender());

    maritalCBox.setPrefWidth(140);
    maritalCBox.setPromptText("Marital Status");
    maritalCBox.setEditable(false);

    genderCB.setPromptText("Gender");
    genderCB.setPrefWidth(140);

    barangayCb.setPromptText("Barangay");
    barangayCb.setEditable(false);

    // --------------------- Layouting ----------------------------///

    int indexYTop = 0;

    topPane.setConstraints(topTitleL, 0, indexYTop, 1, 1, HPos.LEFT, VPos.TOP);

    indexYTop++;
    topPane.setConstraints(DateL, 0, indexYTop, 1, 1, HPos.LEFT, VPos.CENTER);
    topPane.setConstraints(dateField, 1, indexYTop, 1, 1, HPos.CENTER, VPos.CENTER);
    topPane.setConstraints(barangayCb, 5, indexYTop, 1, 1, HPos.CENTER, VPos.CENTER);

    indexYTop++;

    topPane.setConstraints(surveyDateL, 0, indexYTop, 1, 1, HPos.LEFT, VPos.CENTER);
    topPane.setConstraints(datePicker, 1, indexYTop, 1, 1, HPos.CENTER, VPos.CENTER);
    bottomPane.setConstraints(maritalCBox, 5, indexYTop, 1, 1, HPos.CENTER, VPos.CENTER);

    indexYTop++;
    bottomPane.setConstraints(yearofResidencyL, 0, indexYTop, 1, 1, HPos.LEFT, VPos.CENTER);
    bottomPane.setConstraints(yrResidency, 1, indexYTop, 1, 1, HPos.LEFT, VPos.CENTER);
    bottomPane.setConstraints(genderCB, 5, indexYTop, 1, 1, HPos.CENTER, VPos.CENTER);

    indexYTop++;
    bottomPane.setConstraints(numofChildrenL, 0, indexYTop, 1, 1, HPos.LEFT, VPos.CENTER);
    bottomPane.setConstraints(numofChildrenF, 1, indexYTop, 1, 1, HPos.LEFT, VPos.CENTER);
    topPane.setConstraints(ageL, 4, indexYTop, 1, 1, HPos.RIGHT, VPos.CENTER);
    topPane.setConstraints(agefield, 5, indexYTop, 1, 1, HPos.CENTER, VPos.CENTER);

    indexYTop++;
    topPane.setConstraints(NameL, 0, indexYTop, 1, 1, HPos.LEFT, VPos.CENTER);
    topPane.setConstraints(Name, 1, indexYTop, 3, 1, HPos.CENTER, VPos.CENTER);
    topPane.setConstraints(LastName, 4, indexYTop, 1, 1, HPos.CENTER, VPos.CENTER);
    topPane.setConstraints(MidlleName, 5, indexYTop, 1, 1, HPos.CENTER, VPos.CENTER);

    indexYTop++;
    topPane.setConstraints(spouseNameL, 0, indexYTop, 1, 1, HPos.LEFT, VPos.CENTER);
    topPane.setConstraints(SpouseName, 1, indexYTop, 5, 1, HPos.CENTER, VPos.CENTER);

    indexYTop++;
    topPane.setConstraints(addressL, 0, indexYTop, 1, 1, HPos.LEFT, VPos.CENTER);
    topPane.setConstraints(addressF, 1, indexYTop, 5, 1, HPos.CENTER, VPos.CENTER);

    dateField.setPrefColumnCount(6);
    agefield.setPrefColumnCount(6);

    // adding nodes to the top gridpane
    topPane
        .getChildren()
        .addAll(
            topTitleL,
            DateL,
            dateField,
            surveyDateL,
            datePicker,
            barangayCb,
            yearofResidencyL,
            yrResidency,
            maritalCBox,
            numofChildrenL,
            numofChildrenF,
            genderCB,
            NameL,
            Name,
            LastName,
            MidlleName,
            ageL,
            agefield,
            spouseNameL,
            SpouseName,
            addressL,
            addressF);

    addTopComponentListeners();

    return topPane;
  }
Exemplo n.º 2
0
  public Browser(final Stage stage) {
    // apply the styles
    getStyleClass().add("browser");

    for (int i = 0; i < captions.length; i++) {
      // create hyperlinks
      Hyperlink hpl = hpls[i] = new Hyperlink(captions[i]);
      Image image = images[i] = new Image(getClass().getResourceAsStream(imageFiles[i]));
      hpl.setGraphic(new ImageView(image));
      final String url = urls[i];
      final boolean addButton = (hpl.getText().equals("Help"));

      // process event
      hpl.setOnAction(
          (ActionEvent e) -> {
            needDocumentationButton = addButton;
            webEngine.load(url);
          });
    }

    comboBox.setPrefWidth(60);

    // create the toolbar
    toolBar = new HBox();
    toolBar.setAlignment(Pos.CENTER);
    toolBar.getStyleClass().add("browser-toolbar");
    toolBar.getChildren().add(comboBox);
    toolBar.getChildren().addAll(hpls);
    toolBar.getChildren().add(createSpacer());

    // set action for the button
    toggleHelpTopics.setOnAction(
        (ActionEvent t) -> {
          webEngine.executeScript("toggle_visibility('help_topics')");
        });

    smallView.setPrefSize(120, 80);

    // handle popup windows
    webEngine.setCreatePopupHandler(
        (PopupFeatures config) -> {
          smallView.setFontScale(0.8);
          if (!toolBar.getChildren().contains(smallView)) {
            toolBar.getChildren().add(smallView);
          }
          return smallView.getEngine();
        });

    // process history
    final WebHistory history = webEngine.getHistory();
    history
        .getEntries()
        .addListener(
            (Change<? extends Entry> c) -> {
              c.next();
              c.getRemoved()
                  .stream()
                  .forEach(
                      (e) -> {
                        comboBox.getItems().remove(e.getUrl());
                      });
              c.getAddedSubList()
                  .stream()
                  .forEach(
                      (e) -> {
                        comboBox.getItems().add(e.getUrl());
                      });
            });

    // set the behavior for the history combobox
    comboBox.setOnAction(
        (Event ev) -> {
          int offset = comboBox.getSelectionModel().getSelectedIndex() - history.getCurrentIndex();
          history.go(offset);
        });

    // process page loading
    webEngine
        .getLoadWorker()
        .stateProperty()
        .addListener(
            (ObservableValue<? extends State> ov, State oldState, State newState) -> {
              toolBar.getChildren().remove(toggleHelpTopics);
              if (newState == State.SUCCEEDED) {
                JSObject win = (JSObject) webEngine.executeScript("window");
                win.setMember("app", new JavaApp());
                if (needDocumentationButton) {
                  toolBar.getChildren().add(toggleHelpTopics);
                }
              }
            });
    // adding context menu
    final ContextMenu cm = new ContextMenu();
    MenuItem cmItem1 = new MenuItem("Print");
    cm.getItems().add(cmItem1);
    toolBar.addEventHandler(
        MouseEvent.MOUSE_CLICKED,
        (MouseEvent e) -> {
          if (e.getButton() == MouseButton.SECONDARY) {
            cm.show(toolBar, e.getScreenX(), e.getScreenY());
          }
        });

    // processing print job
    cmItem1.setOnAction(
        (ActionEvent e) -> {
          PrinterJob job = PrinterJob.createPrinterJob();
          if (job != null) {
            webEngine.print(job);
            job.endJob();
          }
        });

    // load the home page
    webEngine.load("http://www.cnn.com");

    // add components
    getChildren().add(toolBar);
    getChildren().add(browser);
  }
Exemplo n.º 3
0
  private GridPane getBottomPane() {

    // ======================================= BOTTOM PANE =======================================//

    bottomPane = new GridPane();

    // Labels
    Label underEmployedL = new Label("Under Employed");
    Label otherIncomeL = new Label("Other Income Resource");
    Label typeofOwnershipL = new Label("Ownership");
    Label below8kL = new Label("Below 8,000php");
    Label occupancyL = new Label("Occupancy");
    Label schoolage = new Label("Children in School");

    // Combobox

    underEmployedCBox = new ComboBox(getYesNo());
    otherIncomeCbox = new ComboBox(getYesNo());
    ownershipCbox = new ComboBox(getOwnerShip());
    below8kCbox = new ComboBox(getYesNo());
    occupancyCBox = new ComboBox(getOccupancy());
    childrenSchlCBox = new ComboBox(getChildrenSchool());

    ownershipCbox.setPrefWidth(115);
    childrenSchlCBox.setPrefWidth(115);
    childrenSchlCBox.setDisable(true);
    occupancyCBox.setPrefWidth(115);

    underEmployedCBox.setDisable(true);

    int indexY = 0;

    bottomPane.setConstraints(bottomTitle, 0, indexY, 1, 1, HPos.LEFT, VPos.CENTER);

    indexY++;
    bottomPane.setConstraints(otherIncomeL, 0, indexY, 1, 1, HPos.LEFT, VPos.CENTER);
    bottomPane.setConstraints(otherIncomeCbox, 1, indexY, 1, 1, HPos.LEFT, VPos.CENTER);

    indexY++;
    bottomPane.setConstraints(below8kL, 0, indexY, 1, 1, HPos.LEFT, VPos.CENTER);
    bottomPane.setConstraints(below8kCbox, 1, indexY, 1, 1, HPos.LEFT, VPos.CENTER);

    indexY++;
    bottomPane.setConstraints(typeofOwnershipL, 0, indexY, 1, 1, HPos.LEFT, VPos.CENTER);
    bottomPane.setConstraints(ownershipCbox, 1, indexY, 1, 1, HPos.LEFT, VPos.CENTER);

    indexY++;
    bottomPane.setConstraints(occupancyL, 0, indexY, 1, 1, HPos.LEFT, VPos.CENTER);
    bottomPane.setConstraints(occupancyCBox, 1, indexY, 1, 1, HPos.LEFT, VPos.CENTER);

    indexY++;
    bottomPane.setConstraints(underEmployedL, 0, indexY, 1, 1, HPos.LEFT, VPos.CENTER);
    bottomPane.setConstraints(underEmployedCBox, 1, indexY, 1, 1, HPos.LEFT, VPos.CENTER);

    indexY++;
    bottomPane.setConstraints(schoolage, 0, indexY, 1, 1, HPos.LEFT, VPos.CENTER);
    bottomPane.setConstraints(childrenSchlCBox, 1, indexY, 1, 1, HPos.LEFT, VPos.CENTER);

    indexY++;
    bottomPane.setConstraints(save, 0, indexY, 2, 1, HPos.CENTER, VPos.CENTER);
    bottomPane.setConstraints(cancel, 1, indexY, 2, 1, HPos.CENTER, VPos.CENTER);

    bottomPane.setMargin(save, new Insets(5, 65, 5, 0));
    bottomPane.setMargin(cancel, new Insets(5, 50, 5, 0));

    addBottomComponentListeners();

    bottomPane
        .getChildren()
        .addAll(
            bottomTitle,
            underEmployedL,
            underEmployedCBox,
            otherIncomeL,
            otherIncomeCbox,
            typeofOwnershipL,
            ownershipCbox,
            below8kL,
            below8kCbox,
            occupancyL,
            occupancyCBox,
            schoolage,
            childrenSchlCBox,
            save,
            cancel);

    return bottomPane;
  }
Exemplo n.º 4
0
  private BorderPane webViewScene() {
    url = new TextField();
    url.setPrefWidth(800);
    browser = new WebView();
    engine = browser.getEngine();

    url.setText(fileUrl);
    engine.load(fileUrl);

    history = browser.getEngine().getHistory();

    backButton = new Button(null, new ImageView(new Image("res/BrowserIcons/back.png")));
    backButton.setOnAction(
        (ActionEvent e) -> {
          if (!checkIntConnection(defaultUrl)) {
            alert();
          } else browser.getEngine().load(goBack());
        });
    backButton.addEventHandler(
        MouseEvent.MOUSE_ENTERED, event -> backButton.setEffect(new DropShadow()));
    backButton.addEventHandler(MouseEvent.MOUSE_EXITED, event -> backButton.setEffect(null));

    forwardButton = new Button(null, new ImageView(new Image("res/BrowserIcons/forward.png")));
    forwardButton.setOnAction(
        (ActionEvent e) -> {
          if (!checkIntConnection(defaultUrl)) {
            alert();
          } else browser.getEngine().load(goForward());
        });
    forwardButton.addEventHandler(
        MouseEvent.MOUSE_ENTERED, event -> forwardButton.setEffect(new DropShadow()));
    forwardButton.addEventHandler(MouseEvent.MOUSE_EXITED, event -> forwardButton.setEffect(null));

    reloadButton = new Button(null, new ImageView(new Image("res/BrowserIcons/reload.png")));
    reloadButton.setOnAction(
        event -> {
          if (!checkIntConnection(defaultUrl)) {
            alert();
          } else browser.getEngine().reload();
        });
    reloadButton.addEventHandler(
        MouseEvent.MOUSE_ENTERED, event -> reloadButton.setEffect(new DropShadow()));
    reloadButton.addEventHandler(MouseEvent.MOUSE_EXITED, event -> reloadButton.setEffect(null));

    goButton = new Button(null, new ImageView(new Image("res/BrowserIcons/go.jpg")));
    goButton.setOnAction(
        event -> {
          // adding the http or https prefix if user didn't type it
          if (!checkIntConnection(defaultUrl)) {
            alert();
          } else {
            if (url.getText().length() > 7
                && (url.getText(0, 7).equals("http://") || url.getText(0, 8).equals("https://"))) {
              browser.getEngine().load(url.getText());
            } else if (url.getText().length() > 7 && !url.getText(0, 7).equals("http://")) {
              browser.getEngine().load("http://" + url.getText());
            } else {
              browser.getEngine().load("https://" + url.getText());
            }
          }
        });
    goButton.addEventHandler(
        MouseEvent.MOUSE_ENTERED, event -> goButton.setEffect(new DropShadow()));
    goButton.addEventHandler(MouseEvent.MOUSE_EXITED, event -> goButton.setEffect(null));

    webHistoryComboBox = new ComboBox();
    webHistoryComboBox.setPromptText("Web History");
    webHistoryComboBox.setPrefWidth(200);
    webHistoryComboBox.setOnAction(
        event -> {
          // Navigate to the link in the history index
          int offset =
              webHistoryComboBox.getSelectionModel().getSelectedIndex() - history.getCurrentIndex();
          history.go(offset);
        });

    // Displying browse history in a combo box
    history
        .getEntries()
        .addListener(
            (ListChangeListener<WebHistory.Entry>)
                c -> {
                  c.next();
                  for (WebHistory.Entry e : c.getRemoved())
                    webHistoryComboBox.getItems().remove(e.getUrl());
                  for (WebHistory.Entry e : c.getAddedSubList())
                    webHistoryComboBox.getItems().add(e.getUrl());
                });

    // Enabling and Disabling back and forward buttons
    browser
        .getEngine()
        .getLoadWorker()
        .stateProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (!browser.getEngine().getHistory().getEntries().isEmpty()) {
                int index = browser.getEngine().getHistory().getCurrentIndex();
                url.setText(browser.getEngine().getHistory().getEntries().get(index).getUrl());
                if (index == 0) {
                  backButton.setDisable(true);
                } else {
                  backButton.setDisable(false);
                }
                if (browser.getEngine().getHistory().getEntries().size() == 1) {
                  forwardButton.setDisable(true);
                } else if (index < browser.getEngine().getHistory().getEntries().size() - 2) {
                  forwardButton.setDisable(false);
                } else if (index < browser.getEngine().getHistory().getEntries().size() - 1) {
                  forwardButton.setDisable(false);
                } else if (index == browser.getEngine().getHistory().getEntries().size() - 1) {
                  forwardButton.setDisable(true);
                }
              }
            });

    progress.setPrefSize(25, 25);
    progress.visibleProperty().bind(browser.getEngine().getLoadWorker().runningProperty());
    BorderPane border = new BorderPane();
    HBox topBar = new HBox();
    topBar.setAlignment(Pos.CENTER);
    topBar.setSpacing(10);
    topBar.setPadding(new Insets(10, 10, 10, 10));
    topBar
        .getChildren()
        .addAll(
            progress, reloadButton, url, goButton, backButton, forwardButton, webHistoryComboBox);

    border.setTop(topBar);
    border.setCenter(browser);
    border.setPrefHeight(Screen.getPrimary().getVisualBounds().getHeight());
    border.setPrefWidth(Screen.getPrimary().getVisualBounds().getWidth());

    return border;
  }