Error opening a .fxml document in Scene Builder (Eclipse) - eclipse

I'm creating a login app in JavaFX. I received this error while opening the scenebuilder: "Could not open Loggin.fxml. Open operation has failed. Make sure that the chosen file is a valid fxml document."
Clicking on "Show details", it shown me this error:
java.io.IOException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 7; The processing instruction target matching "[xX][mM][lL]" is not allowed.
at com.oracle.javafx.scenebuilder.kit.fxom.glue.GlueLoader.load(GlueLoader.java:93)
at com.oracle.javafx.scenebuilder.kit.fxom.glue.GlueLoader.load(GlueLoader.java:76)
at com.oracle.javafx.scenebuilder.kit.fxom.glue.GlueDocument.<init>(GlueDocument.java:54)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:74)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:95)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:2370)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:655)
at com.oracle.javafx.scenebuilder.app.DocumentWindowController.loadFromFile(DocumentWindowController.java:386)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFiles(SceneBuilderApp.java:579)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleOpenFilesAction(SceneBuilderApp.java:447)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleLaunch(SceneBuilderApp.java:427)
at com.oracle.javafx.scenebuilder.app.AppPlatform.requestStartGeneric(AppPlatform.java:139)
at com.oracle.javafx.scenebuilder.app.AppPlatform.requestStart(AppPlatform.java:106)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.start(SceneBuilderApp.java:371)
at com.sun.javafx.application.LauncherImpl$8.run(LauncherImpl.java:837)
at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:335)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:301)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:298)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:298)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 7; The processing instruction target matching "[xX][mM][lL]" is not allowed.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1436)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPIData(XMLScanner.java:723)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanPIData(XMLDocumentFragmentScannerImpl.java:1018)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPI(XMLScanner.java:691)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:912)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.oracle.javafx.scenebuilder.kit.fxom.glue.GlueLoader.load(GlueLoader.java:91)
... 24 more
This is the fxml resource:
?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<TitledPane animated="false" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" text="WELCOME TO PAY-APP" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Login">
<content>
<AnchorPane fx:id="arch" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Label fx:id="lblog" layoutX="43.0" layoutY="43.0" text="LOG IN " textAlignment="CENTER" />
<TextField fx:id="user" layoutX="103.0" layoutY="74.0" />
<PasswordField fx:id="paswd" layoutX="103.0" layoutY="131.0" />
<Button fx:id="logbt" layoutX="152.0" layoutY="197.0" mnemonicParsing="false" onAction="#log" text="LOG IN" />
<Label layoutX="26.0" layoutY="78.0" text="USERNAME:" />
<Label layoutX="25.0" layoutY="135.0" text="PASSWORD:" />
<Button fx:id="sgnbt" layoutX="377.0" layoutY="280.0" mnemonicParsing="false" text="SIGN UP!" />
<Label fx:id="lbmem" layoutX="285.0" layoutY="43.0" text="NOT A MEMBER? SIGN UP!" />
<Label layoutX="288.0" layoutY="78.0" text="NAME:" />
<Label layoutX="288.0" layoutY="111.0" text="LAST NAME:" />
<Label layoutX="288.0" layoutY="148.0" text="USERNAME:" />
<Label layoutX="287.0" layoutY="189.0" text="PASSWORD:" />
<Label layoutX="287.0" layoutY="231.0" text="PASSWORD AGAIN:" />
<TextField fx:id="name" layoutX="399.0" layoutY="66.0" />
<TextField fx:id="usersg" layoutX="399.0" layoutY="144.0" />
<TextField fx:id="lname" layoutX="399.0" layoutY="107.0" />
<PasswordField fx:id="paswdsg" layoutX="399.0" layoutY="185.0" />
<PasswordField fx:id="pswdsga" layoutX="399.0" layoutY="227.0" />
</children></AnchorPane>
</content>
</TitledPane>
The thing is I worked with this document before and it was compiling without problems and errors. Now I just want to add a new button to my app and it seems I can't open it... Thanks a lot for helping!

Related

Unsure how to fix the error in the Azure Devops Migration Tool for very old TFS collections

We've been asked to migrate some very old legacy projects (i.e. from TFS 2010 days) onto Azure Devops Services. These very old projects have almost nothing in their Process Configuration and only have one error line in the logs from the migration tool for all project types (Scrum, Agile, Basic etc...).
[Info #15:27:48.998] === Found 1 error(s) when compared against process TFS 2019 Update 1 Scrum ===
[Error #15:27:48.998] Custom processConfiguration typeField count '0' is different than system '8'.
[Info #15:27:48.998] === End of error(s) when compared against process TFS 2019 Update 1 Scrum ===
When looking at their Process Configuation it is only a few lines:
<?xml version="1.0" encoding="utf-16"?>
<ProjectProcessConfiguration>
<RequirementBacklog workItemCountLimit="1000">
<AddPanel />
</RequirementBacklog>
<TaskBacklog workItemCountLimit="1000">
<AddPanel />
</TaskBacklog>
<Properties>
<Property name="BugsBehavior" value="Off" />
</Properties>
</ProjectProcessConfiguration>
The only project that has no errors was a project added much later on TFS 2015:
<?xml version="1.0" encoding="utf-16"?>
<ProjectProcessConfiguration>
<BugWorkItems category="Microsoft.BugCategory" pluralName="Bugs" singularName="Bug">
<States>
<State type="Proposed" value="New" />
<State type="InProgress" value="Active" />
<State type="Complete" value="Closed" />
<State type="Resolved" value="Resolved" />
</States>
</BugWorkItems>
<FeedbackRequestWorkItems category="Microsoft.FeedbackRequestCategory" pluralName="Feedback Requests" singularName="Feedback Request">
<States>
<State type="InProgress" value="Active" />
<State type="Complete" value="Closed" />
</States>
</FeedbackRequestWorkItems>
<FeedbackResponseWorkItems category="Microsoft.FeedbackResponseCategory" pluralName="Feedback Responses" singularName="Feedback Response">
<States>
<State type="InProgress" value="Active" />
<State type="Complete" value="Closed" />
</States>
</FeedbackResponseWorkItems>
<PortfolioBacklogs>
<PortfolioBacklog category="Microsoft.EpicCategory" pluralName="Epics" singularName="Epic" workItemCountLimit="1000">
<AddPanel>
<Fields>
<Field refname="System.Title" />
</Fields>
</AddPanel>
<Columns>
<Column width="100" refname="System.WorkItemType" />
<Column width="400" refname="System.Title" />
<Column width="100" refname="System.State" />
<Column width="50" refname="Microsoft.VSTS.Scheduling.Effort" />
<Column width="50" refname="Microsoft.VSTS.Common.BusinessValue" />
<Column width="100" refname="Microsoft.VSTS.Common.ValueArea" />
<Column width="200" refname="System.Tags" />
</Columns>
<States>
<State type="Proposed" value="New" />
<State type="InProgress" value="Active" />
<State type="InProgress" value="Resolved" />
<State type="Complete" value="Closed" />
</States>
</PortfolioBacklog>
<PortfolioBacklog category="Microsoft.FeatureCategory" parent="Microsoft.EpicCategory" pluralName="Features" singularName="Feature" workItemCountLimit="1000">
<AddPanel>
<Fields>
<Field refname="System.Title" />
</Fields>
</AddPanel>
<Columns>
<Column width="100" refname="System.WorkItemType" />
<Column width="400" refname="System.Title" />
<Column width="100" refname="System.State" />
<Column width="50" refname="Microsoft.VSTS.Scheduling.Effort" />
<Column width="50" refname="Microsoft.VSTS.Common.BusinessValue" />
<Column width="100" refname="Microsoft.VSTS.Common.ValueArea" />
<Column width="200" refname="System.Tags" />
</Columns>
<States>
<State type="Proposed" value="New" />
<State type="InProgress" value="Active" />
<State type="InProgress" value="Resolved" />
<State type="Complete" value="Closed" />
</States>
</PortfolioBacklog>
</PortfolioBacklogs>
<RequirementBacklog category="Microsoft.RequirementCategory" parent="Microsoft.FeatureCategory" pluralName="Stories" singularName="User Story" workItemCountLimit="1000">
<AddPanel>
<Fields>
<Field refname="System.Title" />
</Fields>
</AddPanel>
<Columns>
<Column width="100" refname="System.WorkItemType" />
<Column width="400" refname="System.Title" />
<Column width="100" refname="System.State" />
<Column width="50" refname="Microsoft.VSTS.Scheduling.StoryPoints" />
<Column width="100" refname="Microsoft.VSTS.Common.ValueArea" />
<Column width="200" refname="System.IterationPath" />
<Column width="200" refname="System.Tags" />
</Columns>
<States>
<State type="Proposed" value="New" />
<State type="InProgress" value="Active" />
<State type="InProgress" value="Resolved" />
<State type="Complete" value="Closed" />
</States>
</RequirementBacklog>
<TaskBacklog category="Microsoft.TaskCategory" parent="Microsoft.RequirementCategory" pluralName="Tasks" singularName="Task" workItemCountLimit="1000">
<AddPanel>
<Fields>
<Field refname="System.Title" />
</Fields>
</AddPanel>
<Columns>
<Column width="400" refname="System.Title" />
<Column width="100" refname="System.State" />
<Column width="100" refname="System.AssignedTo" />
<Column width="50" refname="Microsoft.VSTS.Scheduling.RemainingWork" />
</Columns>
<States>
<State type="Proposed" value="New" />
<State type="InProgress" value="Active" />
<State type="Complete" value="Closed" />
</States>
</TaskBacklog>
<TypeFields>
<TypeField refname="Microsoft.VSTS.Common.Activity" type="Activity" />
<TypeField refname="Microsoft.VSTS.Common.StackRank" type="Order" />
<TypeField refname="Microsoft.VSTS.Feedback.ApplicationLaunchInstructions" type="ApplicationLaunchInstructions" />
<TypeField refname="Microsoft.VSTS.Feedback.ApplicationStartInformation" type="ApplicationStartInformation" />
<TypeField refname="Microsoft.VSTS.Feedback.ApplicationType" type="ApplicationType">
<TypeFieldValues>
<TypeFieldValue type="ClientApp" value="Client application" />
<TypeFieldValue type="RemoteMachine" value="Remote machine" />
<TypeFieldValue type="WebApp" value="Web application" />
</TypeFieldValues>
</TypeField>
<TypeField format="{0} h" refname="Microsoft.VSTS.Scheduling.RemainingWork" type="RemainingWork" />
<TypeField refname="Microsoft.VSTS.Scheduling.StoryPoints" type="Effort" />
<TypeField refname="System.AreaPath" type="Team" />
</TypeFields>
<Weekends>
<DayOfWeek>Sunday</DayOfWeek>
<DayOfWeek>Saturday</DayOfWeek>
</Weekends>
<Properties>
<Property name="HiddenBacklogs" value="Microsoft.EpicCategory" />
<Property name="BugsBehavior" value="AsTasks" />
</Properties>
<WorkItemColors>
<WorkItemColor primary="FFCC293D" secondary="FFFAEAE5" name="Bug" />
<WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Code Review Request" />
<WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Code Review Response" />
<WorkItemColor primary="FFFF7B00" secondary="FFFFD7B5" name="Epic" />
<WorkItemColor primary="FF773B93" secondary="FFEEE2F2" name="Feature" />
<WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Feedback Request" />
<WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Feedback Response" />
<WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Issue" />
<WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Shared Parameter" />
<WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Shared Steps" />
<WorkItemColor primary="FFF2CB1D" secondary="FFF6F5D2" name="Task" />
<WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Test Case" />
<WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Test Plan" />
<WorkItemColor primary="FFFF9D00" secondary="FFFCEECF" name="Test Suite" />
<WorkItemColor primary="FF009CCC" secondary="FFD6ECF2" name="User Story" />
</WorkItemColors>
</ProjectProcessConfiguration>
Anyone know of a easy way to fix the older projects? We want to import the code with changeset histories into Azure Devop Services and none of them have actually have work items (was managed externally on JIRA), build and release configs etc... We just want to get them onto the cloud to retire the legacy onpremise TFS servers (which are now running Azure Devops Server 2020.1.1 as per the migration suggestions).
Thanks for any help.
Edit: we're using TFS Team Project Manager from Jelle Druyts to help do some of the analysis, and am wondering if we can use the Transform function under Process Configuration to import the working projects config into the other projects.
Mark.
Sorry for the late reply on this. Since we didn't need to preserve templates and work items/ task history, we ended up abandoning full migrations. Ended up using the git-tfs (https://git-tfs.com/) tool to convert the TFS projects to a local git repository, then attaching that to a new Azure git project. Preserved all our history which was great.

How to use a sapui5 SmartField without data binding?

I can't seem to figure out how to get a SmartField to work without data binding; the problem is that the value that is entered is cleared when there's no data binding.
I've been stuck with this for some days now; I've tried changing the 'sap:' tags in the metadata but to no avail. If I change the field to SmartMultiInput it works fine; there's also a specific example on SAPUI5's tutorial series for SmartMultiInput Without Data Binding - but nothing on SmartField.
myView.view.xml:
<mvc:View
controllerName="sap.ui.demo.smartControls.SmartField"
xmlns="sap.m"
xmlns:form="sap.ui.layout.form"
xmlns:mvc="sap.ui.core.mvc"
xmlns:smartField="sap.ui.comp.smartfield">
<form:SimpleForm
minWidth="1024"
maxContainerCols="2"
editable="true"
layout="ResponsiveGridLayout"
labelSpanL="3"
labelSpanM="3"
emptySpanL="4"
emptySpanM="4"
columnsL="1"
columnsM="1"
class="editableForm">
<form:content>
<smartField:SmartLabel labelFor="idProduct"/>
<smartField:SmartField value="{ProductId}" entitySet="Products" id="idProduct"/>
</form:content>
</form:SimpleForm>
</mvc:View>
myController.controller.js
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("sap.ui.demo.smartControls.SmartField", {
onInit: function() {
//SmartField will work if the following code is uncommented
//this.getView().bindElement("/Products('4711')");
}
});
});
metadata.xml
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0"
xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:sap="http://www.sap.com/Protocols/SAPData">
<edmx:DataServices m:DataServiceVersion="2.0">
<Schema Namespace="com.sap.wt02"
sap:schema-version="1" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityType Name="Product">
<Key>
<PropertyRef Name="ProductId" />
</Key>
<Property Name="ProductId" Type="Edm.String" />
<Property Name="Price" Type="Edm.String"
sap:unit="CurrencyCode" MaxLength="3" sap:label="Price"
sap:updatable="true" />
<Property Name="CurrencyCode" Type="Edm.String"
MaxLength="3" sap:label="Currency" sap:semantics="currency-code"
sap:updatable="true" />
</EntityType>
<EntityContainer m:IsDefaultEntityContainer="true"
sap:supported-formats="atom json">
<EntitySet Name="Products" EntityType="com.sap.wt02.Product" sap:creatable="true" sap:updatable="true" sap:addressable="true" sap:deletable="true" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Products.json
[
{
"ProductId": "4711",
"Price": 856.49,
"CurrencyCode": "EUR"
}
]

Jfoenix JFXToggleButton does not provide switch appearance

I am learning how to use JFoenix with Java FX.
I am using it from SceneBuilder so the only code I can show is that one :
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXToggleButton?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<SplitPane id="sp_main" dividerPositions="0.29797979797979796" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.171">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<VBox layoutX="-1.0" prefHeight="398.0" prefWidth="174.0">
<children>
<Pane prefHeight="200.0" prefWidth="200.0" />
<Pane prefHeight="200.0" prefWidth="200.0" />
<Pane id="p_action" prefHeight="200.0" prefWidth="200.0">
<children>
<VBox prefHeight="200.0" prefWidth="100.0" />
<JFXToggleButton />
</children>
</Pane>
</children>
</VBox>
</children></AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" />
</items>
</SplitPane>
According to the documentation when we the componenet JFXToggleButton whe should have some sort of switch button like :
But this is not what I have on my side, all I can get is a simple Toggle Button like :
Is there something I am missing ? Thanks a lot.
Note :
JavaFX Scene Builder 8.5.0
JFoenix 8.0.7 added manually from Library Manager with Maven
Documentation : https://github.com/jfoenixadmin/JFoenix/wiki/Toggle-Button#JFXButton
I'll post this as an answer as this is definitely weird...
When I finally run my application it is giving the correct output, it seems that using preview option of scene builder does not render it.

OpenXML stylesheet corruption

I'm getting an error on this (formatted for readability) OpenXML stylesheet at column 153, which seems to be the '.' in the 0.0% format identifier. Can anyone see what is wrong here? If I remove the numFmts then the issue goes away.
<?xml version="1.0" encoding="utf-16"?>
<x:styleSheet xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<x:numFmts count="2">
<x:numFmt />
<x:numFmt numFmtId="164" formatCode="0.0%" />
</x:numFmts>
<x:fonts count="2">
<x:font>
<x:sz val="11" />
<x:color rgb="000000" />
<x:name val="Calibri" />
</x:font>
<x:font>
<x:b />
<x:sz val="11" />
<x:color rgb="000000" />
<x:name val="Calibri" />
</x:font>
</x:fonts>
<x:fills count="1">
<x:fill>
<x:patternFill patternType="none" />
</x:fill>
</x:fills>
<x:borders count="1">
<x:border>
<x:left />
<x:right />
<x:top />
<x:bottom />
<x:diagonal />
</x:border>
</x:borders>
<x:cellXfs count="3">
<x:xf />
<x:xf fontId="1" applyFont="1" />
<x:xf numFmtId="164" applyNumberFormat="1" />
</x:cellXfs>
</x:styleSheet>
It's the empty <x:numFmt> element in the line above that's the cause of the issue. The numFmtId and formatCode are required elements within that element.
The schema from ECMA is:
<xsd:complexType name="CT_NumFmt">
<xsd:attribute name="numFmtId" type="ST_NumFmtId" use="required"/>
<xsd:attribute name="formatCode" type="s:ST_Xstring" use="required"/>
</xsd:complexType>
It's worth trying the OpenXml Productivity Tool in situations like these. It will validate files as well as backwards engineer code from a valid file. In your case you'd get something like this:

How to hide Text on overflow in JavaFX?

I am creating custom file chooser in JavaFX. Here is a button group for it:
And here is an fxml file content:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<GridPane hgap="5.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
minWidth="-Infinity" xmlns:fx="http://javafx.com/fxml/1"
xmlns="http://javafx.com/javafx/8.0.131">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="200.0"
prefWidth="200.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="25.0"
prefWidth="25.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="25.0"
prefWidth="25.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
minWidth="-Infinity" prefHeight="25.0" prefWidth="200.0"
style="-fx-background-color: lightgrey;" GridPane.valignment="CENTER">
<GridPane.margin>
<Insets/>
</GridPane.margin>
<children>
<Text stroke="BLACK" strokeType="OUTSIDE" strokeWidth="0.0"
text="Chosen file name" StackPane.alignment="CENTER_LEFT">
<StackPane.margin>
<Insets left="5.0"/>
</StackPane.margin>
</Text>
</children>
</StackPane>
<StackPane maxHeight="-Infinity" minHeight="-Infinity" prefHeight="25.0"
style="-fx-background-color: lightgrey;" GridPane.columnIndex="1"
GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="x"/>
</children>
</StackPane>
<StackPane maxHeight="-Infinity" minHeight="-Infinity" prefHeight="25.0"
style="-fx-background-color: lightgrey;" GridPane.columnIndex="2"
GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="..."
StackPane.alignment="CENTER"/>
</children>
</StackPane>
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</padding>
</GridPane>
When a user clicks on button (I am using Text as a button), it will show file chooser. After file chosen in should show file name. Everything works fine, but there is a problem when a file name is too long, the text is overflowing.
I want the text to be ended with "..." at the end instead of overflowing, and the size should not extend its parent size.
How to achieve this?
Use a Label instead. This automatically uses a ellipsis if the text gets too long for the available area. In contrast to Text it extends Region and therefore can be resized by the parent layout:
<?import javafx.scene.control.Label?>
...
<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
minWidth="-Infinity" prefHeight="25.0" prefWidth="200.0"
style="-fx-background-color: lightgrey;" GridPane.valignment="CENTER">
<GridPane.margin>
<Insets/>
</GridPane.margin>
<children>
<Label textFill="BLACK" text="Chosen file name" StackPane.alignment="CENTER_LEFT"
ellipsisString="..." textOverrun="ELLIPSIS" wrapText="false">
<StackPane.margin>
<Insets left="5.0"/>
</StackPane.margin>
</Label>
</children>
</StackPane>
...