textfield

Limiting and formatting a JTextfield

岁酱吖の 提交于 2019-12-02 11:52:30
I have a JTextfield where a user enters a "social security number". The SSN has 9 digits and 2 dashes for a total of 11 characters. How do I limit the JTextField to 11 characters and also have 2 dashes in the textfield at the 4 th and 7 th position of the 11 characters? You might want to use : JFormattedTextField See this for more help : How to Use Formatted Text Fields Also this might help : MaskFormatter Here is a sample snippet : MaskFormatter formatter = new MaskFormatter("####-###-####"); EDIT : After some research I found out that a DocumentFilter would do things better, See this for

JavaFx expandable Textfield sample

一个人想着一个人 提交于 2019-12-02 09:59:01
in my company we got a task to implement an autoexpandable textfield. As this functionality is not provided by default we had to develop it from scratch. There are many posibilities across web, how it can be achived, but no one worked for as, so we decided to put our code on SO, so other devs can also use it. As it is not possbile to expand a textfield the solution is textarea based: public class TextFieldExpandable extends TextArea { private final double DEFAULT_HEIGHT = 17.0; public TextFieldExpandable() { setMinHeight(DEFAULT_HEIGHT); setPrefHeight(DEFAULT_HEIGHT); setMaxHeight(DEFAULT

Get caret position (x, y) in input TextField AS3?

我的未来我决定 提交于 2019-12-02 08:25:31
问题 I need to get the position of the caret in my input textfield. I don't need to set the position, i need to get the current location of the caret. Can't figure this out and it's driving me crazy! 回答1: Check the Texfield.caretIndex property and TextField.getCharBoundaries() method in documentation. It's actually easy but it gets tricky when the field is empty or the next char is a empty/newline. import flash.text.TextField; import flash.text.TextFormat; import flash.text.TextFieldType; import

How to remove unnecessary wrapping in PDF, generated using JasperReports (jrxml)?

牧云@^-^@ 提交于 2019-12-02 08:03:29
问题 I am using jasper report for generating my PDF report. I use following textField configuration in jrxml file. <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement uuid="ec0e2f1f-82d6-46fd-ba68-394be7f6b015" positionType="Float" stretchType="RelativeToTallestObject" isPrintRepeatedValues="false" mode="Transparent" x="0" y="0" width="100" height="16" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/> <box topPadding="2" leftPadding="5" bottomPadding="0"

Why numeric constraint didn't work on Virtual keyboard in LWUIT?

安稳与你 提交于 2019-12-02 07:19:00
I have tested many ways to give the numeric and password constraint in the TextField. But its not working, See the below code. textField.setConstraint(TextField.NUMERIC | TextField.PASSWORD); textField.setInputModeOrder(new String[]{"123"}); Above code should work on the non touch mobiles. But its not working on the touch mobiles. So i have set the input mode value for VKB and bind that TextField with VKB , see this code. TextField txt = new TextField(); txt.setConstraint(TextField.NUMERIC |TextField.PASSWORD); txt.setInputModeOrder(new String[]{"123"}); VirtualKeyboard vkb = new

Get caret position (x, y) in input TextField AS3?

霸气de小男生 提交于 2019-12-02 06:31:41
I need to get the position of the caret in my input textfield. I don't need to set the position, i need to get the current location of the caret. Can't figure this out and it's driving me crazy! Check the Texfield.caretIndex property and TextField.getCharBoundaries() method in documentation. It's actually easy but it gets tricky when the field is empty or the next char is a empty/newline. import flash.text.TextField; import flash.text.TextFormat; import flash.text.TextFieldType; import flash.events.KeyboardEvent; import flash.geom.Rectangle; var t:TextField = new TextField(); t.x = t.y = 20; t

How to add separator after every 2 character while changing text in textfield in Swift 4

可紊 提交于 2019-12-02 04:53:31
In my project I need to put device MAC address validation while adding text in text field. My device mac address format is “AB:5E:CF:45:S5:6D”. So when ever I will add any character it should be changed with adding colon after 2 character in textfield. Example : “45DF5R6” = “45:DF:5R:6” “SD45ER65DF6G” = “SD:45:ER:65:DF:6G” Appreciated your help. Thanks in advance. You're looking for delegate function of a UITextField: func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool You can write input specific logic in that function.

focused component reference

别来无恙 提交于 2019-12-02 04:09:26
问题 I am working on a simple java swing based application. How would I get and set the text of the currently focused textfield/textarea of a form? I know how to determine which component has focus but I can not figure out how I can get the selected text of the component. I use getFocusOwner() but it return a Component and therefore does not implement the method getSelectedText(). Do I somehow need to do a typecast? 回答1: Depending on your exact context, you might consider to use a custom

JavaFX TextField validation for integer input and also allow either K or k(for Thousand) or M or m(for Million) in last

不打扰是莪最后的温柔 提交于 2019-12-02 03:33:37
I want to add validation in javafx TextField such that user should only be able to insert integer values ([0-9] and Dot ). Also user should be able to insert either B or b(for Billion) and K or k (for Thousand) and M or m( for Million). Basically it should be an amountfield. Delete and Backspace should also work. for example : 10k should become 10,000.00 as soon as user hit k and K should not be displayed on amountfield (textfield) Similarly 10M or 10m should convert into 10,000,000.00 adsadi342fn3 or 31233123werwer or dsad342134k should not be allowed to enter in the textfield. I have used

In iOS - When touching a text field in a scroll view the view can not scroll

时间秒杀一切 提交于 2019-12-02 01:53:52
问题 When trying to scroll a view by touching and dragging on a text field, similarly to how you would scroll around on the edit contacts view on the iPhone, the view will not move, touching and dragging in between the text fields or off to the side of the text fields in the scroll view works but not when touching a textfield. Any insights would be greatly appreciated. Thanks! 回答1: Try setting the delaysContentTouches property to YES for the UIScrollView to which you have added to text field. This