Package javafx.scene.control

Examples of javafx.scene.control.Label


        setDisplayedCalendarFromSpinners();
      }
    });
   
    // double click here to show today
    todayLabel = new Label("   ");
    todayLabel.onMouseClickedProperty().set(new EventHandler<MouseEvent>()
    {
      @Override
      public void handle(MouseEvent event)
      {
        if (event.getClickCount() < 1) return;
        setDisplayedCalendarToToday();
      }
    });
   
    // weekday labels
    for (int i = 0; i < 7; i++)
    {
      // create buttons
      Label lLabel = new Label("" + i);
      // style class is set together with the label
      lLabel.getStyleClass().add("weekday-label");
      lLabel.setMaxWidth(Integer.MAX_VALUE); // this is one of those times; why the @#$@#$@#$ do I need to specify this in order to make the damn label centered?
     
      // remember the column it is associated with
      lLabel.setUserData(Integer.valueOf(i));
      lLabel.onMouseClickedProperty().set(weekdayLabelMouseClickedPropertyEventHandler);

      // remember it
      weekdayLabels.add(lLabel);
    }
   
    // weeknumber labels
    for (int i = 0; i < 6; i++)
    {
      // create buttons
      Label lLabel = new Label("" + i);
      lLabel.getStyleClass().add("weeknumber");
      lLabel.setAlignment(Pos.BASELINE_RIGHT);
     
      // remember it
      weeknumberLabels.add(lLabel);
     
      // remember the row it is associated with
      lLabel.setUserData(Integer.valueOf(i));
      lLabel.onMouseClickedProperty().set(weeknumerLabelMouseClickedPropertyEventHandler);
    }
   
    // setup: 6 rows of 7 days per week (which is the maximum number of buttons required in the worst case layout)
    for (int i = 0; i < 6 * 7; i++)
    {
View Full Code Here


      .withHGap(5)
      .withVGap(5)
      .withPadding(new Insets(10, 10, 10, 10))
      .withGridLinesVisible(true);

      gridPane.add(new Label("SingleCell"), new GridPane.C().col(1).row(0));
    gridPane.add(new Label("RIGHT"), new GridPane.C().col(2).row(0).halignment(HPos.RIGHT));

    gridPane.add(new Label("Span2Row\nSpan2Row\nSpan2Row"), new GridPane.C().col(0).row(0).colSpan(1).rowSpan(2));

      gridPane.add(new Label("Span2Columns Span2Columns"), new GridPane.C().col(1).row(1).colSpan(2).rowSpan(1));

    gridPane.add(new Label("Single"), new GridPane.C().col(0).row(2));
    gridPane.add(new Label("Span2Col2RowCenter\nSpan2Col2RowCenter\nSpan2Col2RowCenter\nSpan2Col2RowCenter\nSpan2Col2RowCenter"), new GridPane.C().col(1).row(2).colSpan(2).rowSpan(2).halignment(HPos.CENTER));

    gridPane.add(new Label("BOTTOM"), new GridPane.C().col(0).row(3).valignment(VPos.BOTTOM));

      gridPane.add(new Label("TOP"), new GridPane.C().col(3).row(3).valignment(VPos.TOP));
     
        // setup scene
    Scene scene = new Scene(gridPane, 800, 200);
   
        // create stage
View Full Code Here

    List<String> lWeekdayLabels = getWeekdayLabels();
   
    // set them
    for (int i = 0; i < weekdayLabels.size(); i++)
    {
      Label lLabel = weekdayLabels.get(i);
      lLabel.setText( lWeekdayLabels.get(i) );
      lLabel.getStyleClass().removeAll("weekend", "weekday");
      lLabel.getStyleClass().add(isWeekdayWeekend(i) ? "weekend" : "weekday");
    }
  }
View Full Code Here

    List<Integer> lWeeknumbers = getWeeknumbers();
   
    // set them
    for (int i = 0; i < lWeeknumbers.size(); i++)
    {
      Label lLabel = weeknumberLabels.get(i);
      lLabel.setText( (lWeeknumbers.get(i).intValue() < 10 ? "0" : "") + lWeeknumbers.get(i).toString() );
    }
  }
View Full Code Here

      StackPane lStackPane = new StackPane();
      Circle c = new Circle(1, Color.WHITE);
      c.radiusProperty().bind(lCircularPane.widthProperty().divide(2.0));
      lStackPane.getChildren().add(c);
      lStackPane.getChildren().add(lCircularPane);
      Label l = new Label("H");
      l.getStyleClass().add("center");
      lStackPane.getChildren().add(l);
      lHBox.add(lStackPane);
    }
   
    {
      CircularPane lCircularPane = new CircularPane();
      lCircularPane.setStartAngle(-360.0 / 12 / 2);
      lCircularPane.setDiameter(150.0);
      //lCircularPane.setStyle("-fx-border-color:black;");
      lCircularPane.setChildrenAreCircular(true);
      //lCircularPane.setShowDebug(lShowDebug);
      lCircularPane.setAnimationInterpolation(CircularPane::animateOverTheArc);
      final List<Label> labels = new ArrayList<>();
      final List<Circle> circles = new ArrayList<>();
      for (int i = 0; i < 12; i++) {
        javafx.scene.shape.Circle c = new javafx.scene.shape.Circle(10, Color.TRANSPARENT);
        circles.add(c);
        javafx.scene.control.Label t = new javafx.scene.control.Label("" + (i * 5));
        t.getStyleClass().add("time");
        labels.add(t);
        StackPane lStackPane = new StackPane();
        lStackPane.getChildren().add(c);
        lStackPane.getChildren().add(t);
        lCircularPane.add(lStackPane);
      }
      StackPane lStackPane = new StackPane();
      Circle c = new Circle(1, Color.WHITE);
      c.radiusProperty().bind(lCircularPane.widthProperty().divide(2.0));
      lStackPane.getChildren().add(c);
      lStackPane.getChildren().add(lCircularPane);
      Label l = new Label("M");
      l.getStyleClass().add("center");
      lStackPane.getChildren().add(l);
      lHBox.add(lStackPane);
    }
   
    {
      CircularPane lCircularPane = new CircularPane();
      lCircularPane.setDiameter(90.0);
      //lCircularPane.setStyle("-fx-border-color:black;");
      //lCircularPane.setChildrenAreCircular(true);
      lCircularPane.setShowDebug(lShowDebug);
      lCircularPane.setAnimationInterpolation(CircularPane::animateOverTheArc);
      final List<Label> labels = new ArrayList<>();
      final List<Circle> circles = new ArrayList<>();
      final AtomicReference<Circle> lastFocus = new AtomicReference<>();
      final AtomicBoolean isPM = new AtomicBoolean(false);
      for (int i = 0; i < 12; i++) {
        javafx.scene.shape.Circle c = new javafx.scene.shape.Circle(10, Color.GRAY);
        circles.add(c);
        javafx.scene.control.Label t = new javafx.scene.control.Label("" + (i * 5));
        t.getStyleClass().add("time");
        labels.add(t);
        StackPane lStackPane = new StackPane();
        lStackPane.getChildren().add(c);
        lStackPane.getChildren().add(t);
        lCircularPane.add(lStackPane);
      }
      StackPane lStackPane = new StackPane();
      lStackPane.getChildren().add(lCircularPane);
      Label l = new Label("S");
      l.getStyleClass().add("center");
      lStackPane.getChildren().add(l);
      lHBox.add(lStackPane);
    }
   
    {
View Full Code Here

    // use a pane to force the scene large enough
    stackPane = new StackPane();
    stackPane.setMinSize(600, 600);
   
    // place label
    label = new Label();
    stackPane.getChildren().add(label);
   
    // create menu
    circlePopupMenu = new CirclePopupMenu(this.stackPane, MouseButton.SECONDARY)
      .withAnimationInterpolation(null);
View Full Code Here

    // use a pane to force the scene large enough
    stackPane = new StackPane();
    stackPane.setMinSize(600, 600);
   
    // place label
    label = new Label();
    stackPane.getChildren().add(label);
   
    return stackPane;
  }
View Full Code Here

      lGridPane.setVgap(5.0);
      lGridPane.setPadding(new Insets(5.0));
      int lRowIdx = 0;
     
      {
        lGridPane.add(new Label("Empty list"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>();
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Cyclic list"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c")
          .withCyclic(true)
          ;
        lGridPane.add(lSpinner, 1, lRowIdx);
       
        final TextField lValueTextField = new TextField();
        lValueTextField.textProperty().bind(lSpinner.valueProperty());
        lGridPane.add(lValueTextField, 2, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Cyclic list with null"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>( "a", "b", "c", null )
          .withCyclic(true)
          ;
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Editable cyclic list"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>( "a", "b", "c", "d", "e" )
          .withCyclic(true)
          .withEditable(true)
          .withStringConverter(StringConverterFactory.forString())
          ;
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Editable and adding cyclic list"), 0, lRowIdx);
        final ObservableList<String> lObservableList = FXCollections.observableArrayList("a", "b", "c", "d", "e");
        ListSpinner<String> lSpinner = new ListSpinner<String>( lObservableList )
          .withCyclic(true)
          .withEditable(true)
          .withStringConverter(StringConverterFactory.forString())
          .withAddCallback(new Callback<String, Integer>()
          {         
            @Override
            public Integer call(String text)
            {
              lObservableList.add(text);
              return lObservableList.size() - 1; // notify spinner the value is appended at the end
            }
          })
          ;
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Observable list, 'z' prepended"), 0, lRowIdx);
        final ObservableList<String> lObservableList = FXCollections.observableArrayList("a", "b", "c", "d", "e");
        ListSpinner<String> lSpinner = new ListSpinner<String>( lObservableList );
        lObservableList.add(0, "z");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Observable list, first removed"), 0, lRowIdx);
        final ObservableList<String> lObservableList = FXCollections.observableArrayList("a", "b", "c", "d", "e");
        ListSpinner<String> lSpinner = new ListSpinner<String>( lObservableList );
        lObservableList.remove("a");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
//      {
//        lGridPane.add(new Label("Observable list, emptied"), 0, lRowIdx);
//        final ObservableList<String> lObservableList = FXCollections.observableArrayList("a", "b", "c", "d", "e");
//        ListSpinner<String> lSpinner = new ListSpinner<String>( lObservableList );
//        lObservableList.clear(); // TODO: causes exception
//        lGridPane.add(lSpinner, 1, lRowIdx++);
//      }
      {
        lGridPane.add(new Label("BigInteger range"), 0, lRowIdx);
        ListSpinner<BigInteger> lSpinner = new ListSpinner<BigInteger>(new ListSpinnerBigIntegerList(BigInteger.valueOf(Long.MIN_VALUE), BigInteger.valueOf(Long.MIN_VALUE + 1000)));
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Integer range"), 0, lRowIdx);
        ListSpinner<Integer> lSpinner = new ListSpinner<Integer>(new ListSpinnerIntegerList());
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Integer range 10..110"), 0, lRowIdx);
        ListSpinner<Integer> lSpinner = new ListSpinner<Integer>(10, 110);
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Integer range 10..110 with setIndex 50"), 0, lRowIdx);
        ListSpinner<Integer> lSpinner = new ListSpinner<Integer>(10, 110);
        lSpinner.setIndex(50);
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Integer range 0..1000 step 10"), 0, lRowIdx);
        ListSpinner<Integer> lSpinner = new ListSpinner<Integer>(0, 100, 10);
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Integer range -10..10"), 0, lRowIdx);
        ListSpinner<Integer> lSpinner = new ListSpinner<Integer>(-10, 10);
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Integer range 10..-10"), 0, lRowIdx);
        ListSpinner<Integer> lSpinner = new ListSpinner<Integer>(10, -10);
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("align right"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>( "a", "b", "c", "d", "e" );
        lSpinner.setStyle("-fxx-value-alignment:CENTER_RIGHT;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("align right"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>( "a", "b", "c", "d", "e" )
          .withEditable(true)
          .withStringConverter(StringConverterFactory.forString())
          ;
        lSpinner.setStyle("-fxx-value-alignment:CENTER_RIGHT;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Integer range 0..100 with %"), 0, lRowIdx);
        ListSpinner<Integer> lSpinner = new ListSpinner<Integer>(0, 100)
            .withPostfix("%")
            ;
        lSpinner.setStyle("-fxx-value-alignment:CENTER_RIGHT;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Integer range 0..100 with %"), 0, lRowIdx);
        ListSpinner<Integer> lSpinner = new ListSpinner<Integer>(0, 100)
            .withPostfix("%")
            .withEditable(true)
            .withStringConverter(StringConverterFactory.forInteger())
            ;
        lSpinner.setStyle("-fxx-value-alignment:CENTER_RIGHT;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Integer currency 0..100"), 0, lRowIdx);
        ListSpinner<Integer> lSpinner = new ListSpinner<Integer>(0, 100)
            .withPrefix("$ ")
            ;
        lSpinner.setStyle("-fxx-value-alignment:CENTER_RIGHT;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("Integer currency 0..100"), 0, lRowIdx);
        final ListSpinner<Integer> lSpinner = new ListSpinner<Integer>(0, 100)
            .withPrefix("$ ")
            .withEditable(true)
            .withStringConverter(StringConverterFactory.forInteger())
            ;
        lSpinner.setStyle("-fxx-value-alignment:CENTER_RIGHT;");
       
        Button lButton = new Button("change CSS");
        lButton.onMouseClickedProperty().set(new EventHandler<MouseEvent>()
        {
          @Override
          public void handle(MouseEvent arg0)
          {
            //lSpinner.setStyle("-fxx-arrow-position:SPLIT;");
            //lSpinner.setStyle("-fxx-arrow-direction:VERTICAL;;");
            lSpinner.setStyle("-fxx-value-alignment:CENTER_LEFT; -fxx-arrow-direction:VERTICAL; -fxx-arrow-position:SPLIT;");
          }
        });
        lGridPane.add(lButton, 2, lRowIdx);
       
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
     
      lHBox.getChildren().add(lGridPane);
    }
   
    {
      GridPane lGridPane = new GridPane();
      lGridPane.setVgap(5.0);
      lGridPane.setPadding(new Insets(5.0));
      int lRowIdx = 0;

      // arrow position
      {
        lGridPane.add(new Label("DEFAULT"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("HORIZONTAL LEADING"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c");
        lSpinner.setStyle("-fxx-arrow-direction:HORIZONTAL; -fxx-arrow-position:LEADING;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("HORIZONTAL TRAILING"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c");
        lSpinner.setStyle("-fxx-arrow-direction:HORIZONTAL; -fxx-arrow-position:TRAILING;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("HORIZONTAL SPLIT"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c");
        lSpinner.setStyle("-fxx-arrow-direction:HORIZONTAL; -fxx-arrow-position:SPLIT;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("VERTICAL LEADING"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c");
        lSpinner.setStyle("-fxx-arrow-direction:VERTICAL; -fxx-arrow-position:LEADING;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("VERTICAL TRAILING"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c");
        lSpinner.setStyle("-fxx-arrow-direction:VERTICAL; -fxx-arrow-position:TRAILING;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("VERTICAL SPLIT"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c");
        lSpinner.setStyle("-fxx-arrow-direction:VERTICAL; -fxx-arrow-position:SPLIT;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("CSS"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c");
        lGridPane.add(lSpinner, 1, lRowIdx++);
        lSpinner.setId("TheSpinner");
      }
      {
        lGridPane.add(new Label("HORIZONTAL LEADING"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c").withEditable(true);
        lSpinner.setStyle("-fxx-arrow-direction:HORIZONTAL; -fxx-arrow-position:LEADING;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("HORIZONTAL TRAILING"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c").withEditable(true);
        lSpinner.setStyle("-fxx-arrow-direction:HORIZONTAL; -fxx-arrow-position:TRAILING;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("HORIZONTAL SPLIT"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c").withEditable(true);
        lSpinner.setStyle("-fxx-arrow-direction:HORIZONTAL; -fxx-arrow-position:SPLIT;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("VERTICAL LEADING"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c").withEditable(true);
        lSpinner.setStyle("-fxx-arrow-direction:VERTICAL; -fxx-arrow-position:LEADING;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("VERTICAL TRAILING"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c").withEditable(true);
        lSpinner.setStyle("-fxx-arrow-direction:VERTICAL; -fxx-arrow-position:TRAILING;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("VERTICAL SPLIT"), 0, lRowIdx);
        ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c").withEditable(true);
        lSpinner.setStyle("-fxx-arrow-direction:VERTICAL; -fxx-arrow-position:SPLIT;");
        lGridPane.add(lSpinner, 1, lRowIdx++);
      }
      {
        lGridPane.add(new Label("CSS SPLIT"), 0, lRowIdx);
        final ListSpinner<String> lSpinner = new ListSpinner<String>("a", "b", "c").withEditable(true);
       
        lGridPane.add(lSpinner, 1, lRowIdx++);
        lSpinner.setId("TheEditableSpinner");
      }
View Full Code Here

      T lValue = spinner.getValue();
     
      // label not yet created
      if (this.label == null)
      {
        this.label = new Label();
      }
      this.label.setText( lValue == null ? "" : spinner.getPrefix() + getStringConverter().toString(lValue) + spinner.getPostfix() );
      return this.label;
    }
View Full Code Here

        for (Object lChild : lSkinBase.getChildren()) {
          printHierarchy(stringBuilder, (Node)lChild, offset + 1);
        }
      }
      if (lControl instanceof Label) {
        Label lLabel = (Label)lControl;
        stringBuilder.append(" text=" + lLabel.getText() );
      }
    }
    else if (n instanceof Pane) {
      Pane lPane = (Pane)n;
      for (Node lChild : lPane.getChildren()) {
View Full Code Here

TOP

Related Classes of javafx.scene.control.Label

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.