From 2197f64c2fbb8135f7cfb0c592d6fad6f1028ece Mon Sep 17 00:00:00 2001 From: sehl Date: Sat, 25 Oct 2025 19:31:20 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20limite=20de=20caract=C3=A8re?= =?UTF-8?q?=20demand=C3=A9=20pour=20lorsque=20l'utilisateur=20ajoute?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fr/iutfbleau/papillon/LimiteContenu.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/fr/iutfbleau/papillon/LimiteContenu.java diff --git a/src/fr/iutfbleau/papillon/LimiteContenu.java b/src/fr/iutfbleau/papillon/LimiteContenu.java new file mode 100644 index 0000000..e72a597 --- /dev/null +++ b/src/fr/iutfbleau/papillon/LimiteContenu.java @@ -0,0 +1,20 @@ +import javax.swing.text.*; + +public class LimiteContenu extends PlainDocument { + private int limite; + + public LimiteContenu(int limite) { + this.limite = limite; + } + + @Override + public void insertString(int offset, String str, AttributeSet attr) + throws BadLocationException { + if (str == null){ + return; + } + if ((getLength() + str.length()) <= limite) { + super.insertString(offset, str, attr); + } + } +}