I am trying to add a tooltip to my ToggleButton to explain to the user what's going to happen if they press it. The problem is, my explanation is too long and the tooltip cuts it off with "..." (the ellipsis string, was it?) Anyway, when I set the max/pref width via a TooltipBuilder like in this example:
this.watched = new ToggleButton("Watched?");
Tooltip tooltip = TooltipBuilder.create().wrapText(true).text(
"Rather than specifying individual images, you can make this source \'watched\',which means that every" +
" time this gallery is viewed, all the images in this directory will be listed.").build();
tooltip.prefWidth(50);
watched.setTooltip(tooltip);
I get this result:
My attempts to set the width via maxWidth(double), maxWidthProperty().set(double), prefWidth(double), and prefWidthProperty().set(double) have been ignored.
Is there any way to overcome this?
In my code, I was setting wrapText(boolean) before setting the width. It seems like JavaFX doesn't like this so much. I changed it to look something like this:
TooltipBuilder.create().prefWidth(300).wrapText(true).<other properties>.build();
This gives me a successful wrap!
In javaFx 2.2 use this:
Tooltip toolTip = TooltipBuilder.create().text(string).prefWidth(500).wrapText(true).build();
Related
I'm using JavaFX for my application's GUI. I want to implement a validation method for all the textfields inside the sign up window. I want to check them all and than, whether they are true or false, I want to use a mark to show the user what field is incorrect. I also want to be able to show a small message box when I hover the mouse pointer over those marks.
Simple way is to create HBox , put TextField,Label in there ,label will be Bound on the textProperty/ or do it with listener
txtField.textProperty().addListener((v, oldValue, newValue) -> {
//code here if valid, set label visible false, else set label visible true(red image crossed or whatever)
});
, when value changes it will check if that is ACCEPTABLE/FAILED state , for instance empty box.States will be changed on property change , use array of your hboxes to check if they are valid or invalid at the time , you can check this based on visibility of Label or internal boolean state value.
For the hover over part , use Tooltip on label.
If you want to go lazyer way , take a look at controlsfx validation it will take care of graphics for you.And its already embedded in its component.Just create validation process
Good beginner reference might be newboston videos so you understand concept.In javafx you gonna use property binding ,listeners etc often , get familiar with them as you cant avoid it.
https://www.youtube.com/watch?v=s8GomyEOA8w
https://www.youtube.com/watch?v=6Zi2L0kHSx4
Since you've given no code I can't give you answer that involves actual coding, because I've got no way of knowing whether or not what I give you will be viable or conflict etc..
In regards to the validation that depends entirely on how your accessing a username/password to compare it to what the user has entered and with out knowing how you're thinking of doing it I cannot give you a good answer.
There are quite a few options to display your red x, you could draw it internally etc..
But the easiest is probably going to be creating an image and importing it to your project, you can set a label next to your JTextField and have the picture set to that lable. Once the user inputs the username/password if either or both are incorrect you could have a method that would set the label to be visible.
The message box is as simple as a tooltip that you could also place on the label which would tell the user that the information they entered is wrong.
I want to remove the Selected page label (see image below) of the Pagination control.
After digging into caspian.css I wasn't able to find any clue about how to do that. By code I also didn't find any method to remove (or eventually hide) this label.
Is there a way to do that in JavaFX without re-implementing the whole control ?
Use -fx-page-information-visible
It's described within these links:
http://docs.oracle.com/javafx/2/ui_controls/pagination.htm
https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/pagination.htm#JFXUI459
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#pagination
I couldn't find a way either to hide just the label, but would it help to hide the whole button?
.number-button:selected{
-fx-opacity: 0;
}
That would hide the current selected button.
It's not what you actually wanted but maybe it can help you.
I am using the below library JDateChooser, which is a Date Picker GUI which we can put into Netbeans pallet.
http://plugins.netbeans.org/plugin/658/jdatechooser-1-2
However this do not display any dates. Dates are empty. Below is the image.
I do not have to post the code here, because I did nothing other than dragging and dropping the GUI element. Can someone please tell me why this is happening?
JDateChooser from vadimig doesn't seem to work with Nimbus, seems to work okay for Windows look and feel, you'd have to test it with the other system looks feels.
Either change the component you are using or change the look and feel you are using
The problem is the width of the component, just increase that value.
If your DateChooserCombo is called chooserDate, it must be like this:
Dimension size = chooserDate.getCalendarPreferredSize();<br>
size.width += 90;<br>
chooserDate.setCalendarPreferredSize(size);<br>
I looked on google but didn't find what exactly i am looking for.
I want a edit text to have text or image which i can change by tapping it and selecting new text or image. Also i want hint followed by that text or image.
I tried multiple experiment and was able to add text(by changing selection location and adding text) and image(using drawable addition from android code)
For text :
edt.setText("Fixed Text");
Selection.setSelection(edt.getText(), edt.getText().length());
Image through XML:
android:drawableLeft="#drawable/ic_launcher"
But when i add text, i won't be able to add hint. In case of image hints get added. Also i want my permanent text and image to be tappable and updatable.
Any help would be really helpful. I want $ to be fixed and tappable, and want to change it to different currency. but want 52.63 to be hint and can be editable by user tap.
EDIT to give more clarity:
Example: i want to add part of the text as permanent and part as hint for example $ 52, so $ is permanent and not editable through user, he can select it through list view by tapping on $, but 52 he can change using android keyboard.
I am not quite sure about the whole part about the image being placed into the EditText as a hint, but if you wanted to create the $52.63 as a hint in the EditText, all you would have to do is:
edt.setHint("$52.63");
in your onCreate() method. I am not sure if this is what you are looking for, but this is a simple way to add a hint to a textEdit. If you wanted the hint to change when the user tapped the screen or something like that, I would look into adding a tap listener of the android component that you desire to be tapped to change the hint, and then modify the hint using the method above.
I am extending GWT DialogBox and my constructor looks like:
public MyBox() {
setGlassEnabled(true);
setAnimationEnabled(true);
setWidth("400px");
VerticalPanel contents = new VerticalPanel();
contents.setWidth("400px");
// init widgets
}
When I comment out second line everything works well. With animation enabled is the size of my dialog "broken". When I inspect HTML site the element has correctly 400px, but it just doesn't fully animate :/
I have few such widgets (animated boxes) and some (smaller ones) works well. What might be the problem? Thanks
EDIT:
Here is weird thing. The table element has 432px, but my DialogBox has 400px set everywhere and no padding set. I tried to force padding 0 with css and still no result.
Did you try setting the width before setting animationEnabled? Are you using an XML layout? MAybe try setting the width in there instead of in the class? I suspect the animation actually tweaks the width property and those two are conflicting.
I just looked at an example of something I did that does the same, and I changed the size of the HTMLPanel that is contained inside the dialog box, not the size of the dialog box itself. And this works with animationEnabled.