[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] FYI: Prevent multiple lines in JTextField
From: |
Roman Kennke |
Subject: |
Re: [cp-patches] FYI: Prevent multiple lines in JTextField |
Date: |
Tue, 15 Nov 2005 14:50:47 +0100 |
Hi again,
> The simplest way to reach the identical behaviour is to override setText
> and replaceSelection, replacing (if present) line feeds and carriage
> returns by spaces.
I have looked into this. The simplest way is to do it in
PlainDocument.insertString(), exactly where I implemented this feature,
but asking for the filterNewlines of the document, just as the JDK does.
This should prevent newlines from going into JTextField when the
filterNewlines property is set on the document. Unfortunately this
property is never set, although it should be (on the JDK this property
is set to true by default).
I checked in the attached patch to fix this. This should also solve your
problem and there is no need to check in your patch.
2005-11-15 Roman Kennke <address@hidden>
* javax/swing/JTextField.java
(createDefaultModel): Set the filterNewlines property on the
created
model.
/Roman
patch.diff
Description: Text Data
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil