I set a tooltip on a text element in JavaFx, everything works as long as I do not hover mouse on the text, the tooltip does not get displayed.
<Text layoutX="329.0" layoutY="202.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Tcond[C]" textAlignment="CENTER">
<Tooltip text="'%Empty_Bundle'"/>
</Text>
That's the fxml code which should create a tooltip on this text.
How to fix it without creating assign text to an object in my view controller and setting on the tooltip by using .setTooltp() method?
In FXML, if you embed one instance element directly inside another, without a property element, it is used to set the property annotated as the #DefaultProperty on the outer instance element.
If you check the documentation for Text you will see that the default property is "text": so your FXML is equivalent to
<Text layoutX="329.0" layoutY="202.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Tcond[C]" textAlignment="CENTER">
<text>
<Tooltip text="'%Empty_Bundle'"/>
</text>
</Text>
In other words, you are trying to set the text of your Text object to the tooltip.
Text doesn't actually have a setTooltip(...) method at all; that method is defined in the Control class, of which Text is not a subclass. The only way to set a tooltip on a Text instance is by using the Tooltip.installTooltip(...) method, which you can only call from the controller (there is no FXML equivalent to calling this static method).
Your other option, if it works, would be to replace the Text with a Label:
<Label layoutX="329.0" layoutY="202.0" text="Tcond[C]" textAlignment="CENTER">
<tooltip>
<Tooltip text="'%Empty_Bundle'"/>
</tooltip>
</Label>
Note that Label does not allow you to directly configure the stroke, as a Text does, so you would lose that functionality (or at least have to use CSS instead).
Related
I am trying to colorize my tablerows using customdata but i just dont understand how to do it.
In the code below u can see me trying to add customdata, it works but its not added to the tablerow. Instead, the one inside the text elements obviously adds it to the text, the second one only adds it to one header row above my column. Any helpers?
<k:TreeTable
id="treeTable"
selectionMode="Single"
enableColumnReordering="false"
visibleRowCountMode="Auto"
>
<k:columns>
<k:Column label="" id="test">
<k:template>
<Text text="{Description}" wrapping="false" class="myListItemClass">
<customData>
<core:CustomData key="mydata" value="{path: 'DrillState', formatter: '.formatter.colorString'}" writeToDom="true" />
</customData>
</Text>
</k:template>
<k:customData>
<core:CustomData key="mydata" value="{path: 'DrillState', formatter: '.formatter.colorString'}" writeToDom="true" />
</k:customData>
</k:Column>
</k:columns>
</k:TreeTable>
Hi i have spend some days searching for the answer how to solve this
This is what i want, just made a image how it should look like
What is the best solution to use to solve this?
I tryed to do this with a Frame but it just allowed be to use 1 content .
Can i use more then one content in some way
( Content can just have one setup of fontcolor and fontsize and so on. )
I just get to this part
Here i try to put a label with margin with - so it go above.
But this is really bad to to. because i need to have the implementation under the frams. like this.
_stack.Children.Add(frame);
_stack.Children.Add(bordertext);
and when i fill the frame with content the lable apear in another position because how it relate to the margin when the Frame get higher.
But if i put the lable implementation above the Frame then it appear in the background of the frame
_stack.Children.Add(bordertext);
_stack.Children.Add(frame);
And the label get weard with the shadow that i cant figure out how to get rid of.
C#
Frame frame = new Frame
{
BorderColor = Color.Brown,
CornerRadius = 10,
HasShadow = false,
Margin = 10,
BackgroundColor = Color.White,
};
Label bordertext = new Label( );
bordertext.Text = "BorderText";
bordertext.Margin = new Thickness(40, -65,0 , 0);
bordertext.BackgroundColor = Color.White;
_stack.Children.Add(frame);
_stack.Children.Add(bordertext);
PART OF THE SOLUTION
#Jason 's solution to put
the Content in a Stacklayout and then put it in a Frame Solves the problem with having more then one text with different font,sizes and stuff.
But i put a text outside the Stacklayout so i can have the Text on the border. But because i put the Bordertext first and then the Frame. Then the Border text gets in the background.
If i put it after the Frame then i gets in the front. But then i have a big problem with dynamic text that the BorderText will appear very strange depending on how much text.
How i cant put the BorderText in front even if i implement in before so i cant move it down a little bit.
_stack.Children.Add(new Label { Text = "Bordertext", Margin = new Thickness(0, 0, 0, -25) });
_stack.Children.Add(_frame);
To compose a layout, first determine what boxes (rectangles) you need inside other boxes. Each "box" is some container (layout) type.
I see one box "A", the size of the parent-container, containing the border lines "B", overlaid by a box "C" that blocks part of one line, and contains a text "D".
I see a second box "E", inset slightly from the parent-container, which contains additional content "F".
To overlay multiple items, use a one-cell Grid, with children at (row,column) of 0,0 - which can be omitted because is default:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="FormsApp1.MainPage">
<Grid BackgroundColor="Violet">
<!-- Border lines formed by one box visually "inside" another, via margins.
Instead use "Rectangle" if need rounded corners. -->
<BoxView BackgroundColor="Red" Margin="10"/>
<BoxView BackgroundColor="LightCoral" Margin="16"/>
<!-- Text "box" given size by putting inside a StackLayout. -->
<!-- Some of these dimensions may not be needed. -->
<StackLayout WidthRequest="300" HeightRequest="30">
<Label Text="Header Text" TextColor="Black" BackgroundColor="White" FontSize="18"
HorizontalOptions="Start"
WidthRequest="150" HeightRequest="30" Margin="20,0" Padding="20,0,0,0"/>
</StackLayout>
<!-- this contains your contents. -->
<StackLayout BackgroundColor="#2196F3" Padding="10" Margin="40">
<Label Text="Content line 1" HorizontalTextAlignment="Center" TextColor="White"/>
<Label Text="Content line 2" HorizontalTextAlignment="Center" TextColor="White"/>
</StackLayout>
</Grid>
</ContentPage>
"Positioning" is done via "Margin" and "Padding" properties.
I've used various colors, so you can see the parts of this layout. "ContentPage" wrapper might not be needed; use whatever your app expects as topmost container.
layout of group' frame' with header text:
I have text and image in one row. and now I want to put button over the row with exact size of row.
used flexDirection: 'row'
Any help?
You can wrap your text and image inside the TouchableOpacity component
<TouchableOpacity onPress={() => doYourThing()}>
<Text>{yourText}</Text>
<Image source={{}} />
</TouchableOpacity>
If the text and image are already wrapped in a View, you can just replace the View component with the TouchableOpacity component. It takes all the props which View takes.
I created ChoiceBox using scene builder 2.0 and attached to IntelliJ Idea and add below code to add item to ChoiceBox in Main class
ChoiceBox genderBox = (ChoiceBox) scene.lookup("#gender");
genderBox.setItems(FXCollections.observableArrayList("Boy", "Girl"));
genderBox.getSelectionModel().select(0);
Choice box code from FXML is as below
<ChoiceBox id="gender" prefHeight="16.0" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="11">
<GridPane.margin>
<Insets left="10.0" />
</GridPane.margin>
</ChoiceBox>
Anyway, when running the Main class I see the choice box as below. choice box width is not matched with context menu(popup) width.
How to set a width to the context menu?
EDIT
Anyway setting width to the context menu in combo box is working fine. So I moved with combo box. see example fxml.
First, set width of the ChoiceBox itself...
<ChoiceBox prefWidth="150">
...
</ChoiceBox>
Then, set width of the popup list via CSS...
.choice-box .menu-item > .label {
-fx-pref-width: 100;
}
note: the box is about 50px wider than the list because of the drop-down button.
I know it's possible to do that in FXML:
<Spinner fx:id="spinner" min="0" max="100" initialValue="3" >
<editable>true</editable>
</Spinner>
But I can't find how it's possible to do that in sceneBuilder
I got the same problem, I didn't found Spinner in Scene Build and I put in Scenne Builder manually. This is my code.
I have modified .fxml document to put the Spinner in Pane.
<Pane fx:id="paneTamano" layoutX="527.0" layoutY="46.0" prefHeight="125.0" prefWidth="141.0" stylesheets="#css.css">
<children>
<Spinner fx:id="spinnerTamano" layoutX="17.0" layoutY="49.0" onMouseClicked="#tamano" prefHeight="25.0" prefWidth="110.0" />
</children>
</Pane>
I created an ObservableList at DocumentController.java to give values to the spinner.
ObservableList<String> listaTamanos = FXCollections.observableArrayList("Grande", "Mediana", "Pequeña");
Finally insert values in to the Spinner.
SpinnerValueFactory<String> valueFactory = new SpinnerValueFactory.ListSpinnerValueFactory<String>(listaTamanos);
spinnerTamano.setValueFactory(valueFactory);
valueFactory.setValue("Pequeña");
Spinner was introduced in JavaFX 8. It has no Stylesheet handling like the one in (for ex.) Slider implemented right now, so SceneBuilder don't know the properties that are stylable.
Compare Spinner and for example Slider source code, there is missing a nested StyleableProperties class in Spinner.