Category Archives: JavaFX

V1.1 Final Release

There is no additional feature in this release, only bug fixes, code enhancements and deprecated methods removal. Please get the binary in TiwulFX download page. However, there is MainMenu prototype control that is used in TiwulFX Demo application. Take a look at the screenshot below, the left panel is MainMenu control. It is collapsible. Please ignore the random icons chosen in the menu.

TiwulFX Demo [Using TiwulFX 1.1]_020

 

Enhancements & Bug Fixes:

  1. Redraw icon.
  2. Fix bug: in insert mode agile editing = true, after delete an unpersisted row, the cell editors are not displayed. Now after delete a new row, the other new row is selected and the cell editors are displayed.
  3. Fix bug: cannot commit edit by pressing enter if the edited row is the last row. Now the new value is committed by pressing enter. Pressing escape afterwards will trigger navigation mode while the new value remains.
  4. Fix bug: if CheckBoxColumn is not required and null label is defined, pasting the null label throws an exception. Now pasting null label text works as expected.
  5. Include implementation version in generated manifest file. To check the version, run java -jar tiwulfx.jar in terminal.
  6. Delete deprecated methods.
  7. [TiwulFX Demo] Replace toolbar with MainMenu prototype.
  8. [TiwulFX Demo] Display tiwulfx version in the title bar.
  9. [TiwulFX Demo] Remove tick column in “Edit in Form” form.
  10. [TiwulFX Demo] Display a message after generating new records.

V1.1_rc1 Release

TiwulFX Release Candidate 1 (actually v1.1_rc1) has been released. It is planned to be the last release before final. The next sprint will focus on testing and bug fixing. New features will be developed in v.1.2 cycle. Grab the demo and the library in our repository download page.

tiwulfxdemo_rc1

New Features

  1. Implement TickColumn. This column is just to mark a row. Use CheckBoxColumn to display boolean value of record.
  2. Implement Paste from Excel. String separated by tab will be put in next cell. String in the next line (separated with \n) will be put in below cell.
  3. Export to excel support stacked header as in TableControl.
  4. Changed row has different background defined in tiwulfx.css.
  5. [TiwulFX Demo] Demo tick column.
  6. [TiwulFX Demo] Provide Master Detail table demo.

Bug Fix

  1. Changing date value in DateColumn by clicking calendar button and selects a date is not committed. Because the date field cell editor is not focused. Same happens to LookupColumn.
  2. Nested column always be put in the last columns of spreadsheet. Now the column order is the same with TableControl.
  3. Export to excel exports value as in database. Now exports value as displayed in TableControl.
  4. Newly added row is not always visible. Now TableControl will scroll to the new row right after clicking insert button.
  5. Refine UI looks.
  6. [TiwulFX Demo] Replace EclipseLink with Hibernate to enable filtering in joined columns and to enable lazy initialization.

Please let us know if you have any problems, feature requests or if you find bugs. TiwulFX issue tracker is the best place to discuss them. Please notice that some API are deprecated. Check API documentation to get information of the replacement method. The deprecated methods will be excluded in final release.

Provide More Colors for Chart Series

The source code is in gist.

JavaFX chart only provides 8 colors. If there are more than 8 series, the colors are reused. As an example, below chart has 11 series.

barchart_1

Notice that the colors are restarted after the 8th. Watermelons has the same color with Apples, Pineapples with Lemons and Coconuts with Oranges.

Let’s find out what styles applied to the series. ScenicView gives what we need here.

scenic_view

After comparing the series styles, the conclusion is we need to change the default-color-x style of series that the index is bigger than 7 (the index of 8th series is 7) with our own colors. The legend items should be adjusted as well.

First, define the css style. In this example, we will provide ten colors. But since there are already 8 provided by JavaFX, we need to define 2 styles only.

.default-color8.chart-bar { -fx-bar-fill: #babdb6; }
.default-color9.chart-bar { -fx-bar-fill: #4e9a06; }

Next, after initializing the BarChart object, redefined colors for each series.

/**
 * Set Series color
 */
for (int i = 0; i < barChartData.size(); i++) {
    for (Node node : chart.lookupAll(".series" + i)) {
        node.getStyleClass().remove("default-color" + (i % 8));
        node.getStyleClass().add("default-color" + (i % 10));
    }
}

/**
 * Set Legend items color
 */
int i = 0;
for (Node node : chart.lookupAll(".chart-legend-item")) {
    if (node instanceof Label && ((Label) node).getGraphic() != null) {
        ((Label) node).getGraphic().getStyleClass().remove("default-color" + (i % 8));
        ((Label) node).getGraphic().getStyleClass().add("default-color" + (i % 10));
    }
    i++;
}

The result is

barchart_2

Since there are 11 series while provided colors only 10, Watermelons and Oranges has the same color. For full source code, please get it here.

 

Creating Custom Menu Separator in JavaFX

We can create custom menu easily in JavaFX using CustomMenuItem class. I was thinking that using that class, I can creat menu separator that has label. What I want to use with that was to group menu items. Each group should have label name using the menu separator. So, I created a component namely LabelSeparator that will fill CustomMenuItem.

public class LabelSeparator extends StackPane {

    private Label lblText;

    public LabelSeparator(String label) {
        this(label, true);
    }

    public LabelSeparator(String label, boolean topPading) {
        HBox line = HBoxBuilder.create()
                .styleClass("line")
                .minHeight(2)
                .prefHeight(2)
                .prefWidth(USE_PREF_SIZE)
                .maxHeight(USE_PREF_SIZE)
                .build();
        if (topPading) {
            setPadding(new Insets(10, 0, 0, 0));
        }
        lblText = LabelBuilder.create().text(label).build();
        this.getChildren().addAll(line, lblText);
        this.getStyleClass().add("label-separator");

    }

    public void setText(String label) {
        textProperty().set(label);
    }

    public String getText() {
        return textProperty().get();
    }

    public StringProperty textProperty() {
        return lblText.textProperty();
    }
}

But when I used that class to fill CustomMenuItem and added it to ContextMenu, the menu item didn’t fill horizontally as I expected. It also still received blue-background when hovered. I checked the source code of SeparatorMenuItem, but I found no clues. I checked deeper by searching what classes use SeparatorMenuItem. I found that there are many line of

if (item instanceof SeparatorMenuItem) {
...
}

I came to a conclusion that SeparatorMenuItem is treated differently.

So I changed my approach. I created a class extending SeparatorMenuItem so it will be treated as one.

public class LabelSeparatorMenuItem extends SeparatorMenuItem {

    public LabelSeparatorMenuItem(String label) {
        this(label, true);
    }

    public LabelSeparatorMenuItem(String label, boolean topPading) {
        super();
        LabelSeparator content = new LabelSeparator(label, topPading);
        content.setPrefHeight(LabelSeparator.USE_COMPUTED_SIZE);
        content.setMinHeight(LabelSeparator.USE_PREF_SIZE);
        setContent(content);

    }

}

Nice, It worked as expected. The separator filled horizontally and it ignored mouse events.

LabelSeparatorMenuItem

The CSS for LabelSeparator is below

.label-separator .line {
    -fx-border-color: derive(-fx-background, -25%) -fx-background derive(-fx-background, 40%) -fx-background;
}

.label-separator .label {
    -fx-background-color: 
        #090a0c,
        linear-gradient(#38424b 0%, #1f2429 20%, #191d22 100%),
        linear-gradient(#20262b, #191d22),
        radial-gradient(center 50% 0%, radius 100%, rgba(114,131,148,0.9), rgba(255,255,255,0));
    -fx-background-radius: 5,4,3,5;
    -fx-background-insets: 0,1,2,0;
    -fx-text-fill: white;
    -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 );
    -fx-font-family: "Arial";
    -fx-text-fill: linear-gradient(white, #d0d0d0);
    -fx-font-size: 12px;
    -fx-padding: 2 10;
}

 

Beta 2 Release

TiwulFX Beta 2 has been released. It got new features and some bug fixes. Get the latest binaries (20130101_a) in repository download page.

beta_2_table

New Features

  1. Agile and Normal Editing. To toggle between them, checkout the table menu in the bottom-right. See the video on 50:59.
  2. Change the amount of rows in a page. This feature is located in table menu. See the video on 1:15
  3. Able to delete new rows in insert mode if there are more than one rows. The last new row is undelete-able. See the video on 5:14
  4. Key binding to change date in date field. keyboard up/down arrow to change day of month, combined with Ctrl to change month, combine with Ctrl + Shift to change year. See the video on 3:38
  5. Remove all filters located in table menu.
  6. Not-required combobox field has blank item to allow user to unspecify value. See the video on 2:21
  7. Key bindings to toggle checkbox cell state between true, false and null using up/down keyboard arrows.
  8. [TiwulFX-Demo] Allow user to generate more records to test performance.
  9. Added custom ProgressBar column. This column is not included in TiwulFX package as it is not editable. It is intended to show that creating custom column is possible.
  10. New UI Component: LabelSeparatorMenuItem used in Table menu.
  11. Pressing ESC in LookupDialog will close it and revert back Lookup field value.

Bug Fixes

  1. LookupField validation in TableColumn now validate the input before leaving cell
  2. A better way to refresh column’s value that depends on LookupColumn value.
  3. Pressing HOME and END key in Date and Lookup Column moves to the start/end of the textfield instead of selecting first/last row.
  4. ComboBox field can display value as expected although previous selected item is null. RT-24412
  5. Fix focus highlight in Date and Lookup field
  6. Tidy up Lookup Dialog window.
  7. Fix incorrect year when selecting a date from Calendar popup after typing date in DateControl input.

Please let us know if you have any problems, feature requests or if you find bugs. TiwulFX issue tracker is the best place to discuss them. Please notice that some API are deprecated. Check API documentation to get information of the replacement method. The deprecated methods will be excluded in final release.