I am currently trying to setEditable for a DatePicker to false so the value cannot be changed. Using the following only disables the text field, but still allows the changing of the date by clicking on the calendar button (the setEditable is for permissions, so I can enable/disable depending on the login):
exampleDatePicker.setEditable(user.getGroup().equals(admin));
Is there a way to disable the Calendar button on the DatePicker? I don't want to use setDisable, as I still want the field to be readable, and I can't change the CSS for disabled because I have other DatePickers that get disabled that I want greyed out.
For future searches, here's what I did:
dtpDate.setDisable(true);
dtpDate.setStyle("-fx-opacity: 1");
dtpDate.getEditor().setStyle("-fx-opacity: 1");
To disable it (i.e make it behave like it's disabled), call setDisable(...):
exampleDatePicker.setDisable(! user.getGroup().equals(admin));
To change the appearance from the default disabled look (which I agree is very hard to read), you can still use CSS, but choose this DatePicker specifically. The easiest way is probably to use a CSS pseudoclass:
PseudoClass notAuthenticated = PseudoClass.getPseudoClass("not-authenticated");
exampleDatePicker.setDisable(! user.getGroup().equals(admin));
exampleDatePicker.pseudoClassStateChanged(notAuthenticated, ! user.getGroup().equals(admin));
and then in your external CSS you can set styles for .date-picker:not-authenticated, e.g.:
.date-picker:not-authenticated, .date-picker:not-authenticated > .text-field {
-fx-opacity: 0.85 ;
}
I would recommend making the date picker look a little different from a truly active (not disabled) date picker, or else it may be confusing to the user.
Better way to do it:
yourDatepicker.setOnMouseClicked(e -> {
if(yourDatepicker.isDisabled && yourDatepicker.isShowing())
yourDatepicker.hide();
});
This way when you click on it, the popup won't show ;)
Cheers
datePicker.setEditable(false);
datePicker.setOnMouseClicked(e -> {
if(!datePicker.isEditable())
datePicker.hide();
});
I was confused in this issue. Finally I found that elegant way to resolve:
yourDatepicker.getEditor().setDisable(true);
Well, just get editor of your datepicker and disable it!
Related
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.
What is the purpose of onSearchRequested()? I am referring to here: http://developer.android.com/reference/android/app/Activity.html#onSearchRequested%28%29
The following is stated: "You can override this function to force global search, e.g. in response to a dedicated search key, or to block search entirely (by simply returning false)." Specifically, what does the bolded piece mean? Does it not mean that we are able to disable this button? I just had a heated discussion at: Android - How to disable Search button, how to implement onSearchRequested()?
As you can see, Phil is suggesting that I have to go the other route. My questions are: can JUST this function be used to disable the search button completely? Can just this function be used without having to disable this button from the dialog builder? What did google meant with the above quoted statement? Thank you for your time.
You should be able to disable the search button using it, i would think google mean that you can block someone trying to search from within your app( IE skipping a progress dialog)
but since most android phones don't come with search buttons anymore, its not a very used function.
and yes you should be able to disable it on the fly without going through the dialog builder.
Swift
i have the following problem:
i want a JButton with a line break. i am using the html method to get it done.
<hmlt>Bla<br>Bla</html>
the problem appears if i disable the button. it works fine except on the "html-styled" button. the color from the button stays the same.
on an other button i am just using ←+;(without the "+") and it works fine, the arrow gets grayed out if i disable him.
so i searched some time for the unicode or html number for the line break, but it didn´t work(for example 
+;)
so can anybody give me an advice? i know it could be done in java, but i prefer the html way, cause it is faster to implement :)
See How to Use HTML in Swing Components: ButtonHtmlDemo:
..Note also that when a button is disabled, its HTML text unfortunately remains black, instead of becoming gray. (Refer to bug #4783068 to see if this situation changes.)
I don't think components with HTML text will be affected by the modified text style that disabling them usually causes.
You could override the button's getText() method to return a different HTML including styling for the text depending on whether the button is disabled or not, but if you want to get it just right it would probably be easier to extend the UI to allow multiple lines without relying on HTML.
I'm using a DatePicker (org.apache.wicket.extensions.yui.calendar.DatePicker — Javadoc) in a form. The form consists of two fields. The first field is a dropdown, and the second changes dynamically based on the first. If "text" is selected, a textbox comes up; if "list" is selected, a dropdown menu comes up; and if "date" is selected, a date picker and associated field come up.
Here's a simplified version of my current code:
DateTextField dateField = new DateTextField("dateField", // ...
DatePicker datePicker = new DatePicker();
dateField.add(datePicker);
fieldOne.add(new OnChangeAjaxBehavior() {
protected void onUpdate(AjaxRequestTarget target) {
if (fieldOne.equalsIgnoreCase("list"))
{
dateField.setVisible(false);
// datePicker.setVisible(false); // This line is impossible
listField.setVisible(true);
textField.setVisible(false);
}
else if { /* similar visibility settings for dates and text */ }
}
});
The form currently works properly for changing to the date picker. The problem arises when date is selected and then the user selects something else. The date field disappears, but the date picker remains on the screen. Unfortunately, it doesn't seem to have a setVisible() method, or any equivalent. In fact, it's not even a true Wicket Component.
How can I make them appear/disappear together? If I can't set the picker's visibility directly, can I tie it to the field's visibility somehow?
By far the easiest yet still fairly maintainable solution is to group the components you want to hide together in a WebMarkupContainer. In the markup you'll probably want to use a <div> element for the container, but this depends on what you want to hide. (Sometimes the markup itself prevents you from using this method but let's hope your markup doesn't. :))
Then just change the visibility of the container.
A good idea with AjaxListeners also is to call .setOutputMarkupId(true) on the Component you want to handle. Otherwise you are possibly not able to "locate" it.
In case you are not rendering it on load, but intend to add the component later, I think you should also call setOutputMarkupPlaceholderTag(true).
This helped me several times...
i am using GWT Hyperlink for Click handling.I used rpc for showing the records in a dialog box by clicking on that link.but it is moving to home page immediately and showing the dialog box there.Please suggest me the solution for this problem.
Hyperlink should be used in combination with History (http://code.google.com/intl/nl-NL/webtoolkit/doc/latest/DevGuideCodingBasicsHistory.html) changes and not for click handling alone. When using Hyperlink the History token is updated, which will probably trigger the History change which will direct to the homepage, Next the click is handled which shows the dialog
EDIT:
Just as David mentions it's better to use the Anchor widget. Because Anchor is a native html element A, it's usability is better over using a span or div.
I concur with Hilbrand, but recommend anchor tags in such cases.
<g:Anchor name="whatever">Click me</g:anchor>
For this case I would suggest you to use CustomButton instead of HypherLink. For that custom button give some styles to look like a hypherlink. If you use label you cannot focus using keyboard.
Use hypherlink only if you are planning to give history support.