Defining own style for Hyperlink in JavaFX - css

I am new to JavaFX programming, and I need to develop an own style for Hyperlink objects. Basically is:
black color when is created, disabled, pressed and any other case before the following second case.
blue color after an email, that is written in this hyperlink, was succesfully sent.
Thanks in advance.

Related

What are the advantages of putting TextField inside Button (JavaFX)

In SceneBuilder it is possible to put TextField inside a Button:
Is it for just decorative purposes or it has some functionality like when clicking button it gets child info and so on? If it has some functionality, are there any examples?
From the documentation:
A simple button control. The button control can contain text and/or a
graphic.
The graphic is changeable for every subclass of Labeled.
You can put any node as graphic into e. g. the button. It gives you a very high level of customization.
A good example is the customization of the header of a TitledPane.
As for your concrete example I see no advantage, rather a disadvantage as it's not common to have a textfield inside a button. But you nevery know with what people come up with.

Changing colour of the text in Javafx textfield WHILE typing

i'm new to javafx. currently i'm trying to change the colour of a text INSIDE a textfield as the user is typing. I'm not trying to change the colour of the text somewhere else but in the textfield itself.
I've searched everywhere and everyone is talking about how to change the colour in another textfield, using Text object or TextFlow. But I'm trying to change the colour of a particular word when user is typing.
For example, if user type " go to school by 2pm" , i would like to change the colour of the word "by" to green (in the textfield itself when the user is typing).
is there anyway to achieve this? Or can this not be done?
Thank you in advance :)
You cannot change the color of an individual word in a TextField, only all words in the TextField. The closest you can do is subvert the selection highlight mechanism, but that is really a bit of a hack and isn't really applicable for your context where the user is actively typing in the TextField.
Rather than using the inbuilt TextField (which is not a good fit for your requirements), you might want to investigate alternate options such as Tomas Mikula's RichTextFX control.

Keep Selection in JavaFX Textfield even if application is not focussed

Background:
I'm trying to implement a find/replace function for java-Fx table view. Whenever I find an occurance of the text to find, I switch the table view into edit mode and select the text found programatically in the textfield which is used during edit mode.
The focus in this situation remains in the modal find/replace dialog, so the selection in the textfield is not visible until I close the modal dialog.
The problem:
A textfield in Java-Fx shows it's selection only while it has the focus (as its standard behaviour). When the Java-Application loses focus the selection becomes invisible, when it gets the focus back the selection is visible again.
Here is the question:
Is it possible to keep the selection visible in a textfield though focus is lost?
What I tried:
I expected that CSS could help here:
textField.setStyle("-fx-highlight-fill: lightgray");
This changes the color of the highlighting but
I wanted to keep the original color for the focussed Textfield
I wanted to change the color from"invisible" to "lightgray" only for
the non-focussed Textfield
What is the correct way?
Or is there a way to highlight text in a TableView without activating the TextField?
Thanks
Ingo
If I am understanding correctly, the solution will be in the modality of your find/replace dialog.
It works for me when I do the following: Note that the java file this is written in extends Stage. If you are not extending stage then just call the methods on your find/replace stage.
owner = myApplicationStage;
initModality(Modality.NONE);//important for the solution!
initOwner(owner);
initStyle(StageStyle.UTILITY);
setScene(myFindAndReplaceScene);
stage = this;
stage.show();
This works perfectly for me, if you have any problems then hopefully I can help.

How to completely disable value highlighting of qspinboxes?

Half of my answer was found here: How to prevent QSpinBox from automatically highlighting contents
However, the program still allows for a mouse or touch-drag to highlight the values of the spinboxes. I need absolutely no highlighting as my application is for an embedded device interface.
How do completely disable highlighting of any kind while still maintaining the spinbox up/down button functionality.
What we ended up doing was to connect a couple signals to the textEditDeselect slot.
foreach(QSpinBox* sb, ui.main->findChildren<QSpinBox*>())
{
sb->findChildren<QLineEdit*> ().at(0)->setReadOnly(true);
connect(sb,SIGNAL(valueChanged(int)),this,SLOT(textEditDeselect()), Qt::QueuedConnection);
connect(sb->findChild<QLineEdit*> (), SIGNAL(cursorPositionChanged(int,int)),this, SLOT(textEditDeselect()),Qt::QueuedConnection);
}
The easiest solution is to change the palette in Qt Designer.
Select qspinbox, click "Change Palette" and for HighlightedText choose black color. This will disable blue background, at least on windows.

GWT designing a Button

I would like to do some notification stuff for my website.
I am done with the backend coding but i would like to display properly in the VIEW.
So exactly what i need to do is when ever there is a message i would like my button to change its color.I mean i want to do something which indicates that there is a message waiting for the user.
So basically i need to make my button blinking or change color so that it indicates the user that he has some message waiting for him
So can you please suggest me any button which can have an image as a display and a corresponding css file which i need to use which can blink when ever there is a message.
Both PushButton and ToggleButton allow setting an image as the face of the button. However, you should be able to make a normal Button "blink" just by using CSS and a Timer. Use addStyleName() and removeStyleName() in combination with the Timer - on new message, add your "blink" style (it's up to you to come up with it ;)), add a Timer and in its run() method removeStyleName() the "blink" style.
PS: See this blog post, to see how the Google team created the cross-browser, customizable buttons in GMail - but that's an overkill in this situation, IMHO ;)

Resources