Here you can find the source of adjustTextToRight(JTextField textField)
Parameter | Description |
---|---|
textField | jTextField a utilizar |
private static void adjustTextToRight(JTextField textField)
//package com.java2s; //License from project: Open Source License import javax.swing.JTextField; public class Main { /**/*from w w w. j a va 2s .c o m*/ * Metodo que quita los espacios que estan solo al final del texto * en el jTextField entregado * @param textField jTextField a utilizar */ private static void adjustTextToRight(JTextField textField) { String text = textField.getText(); String newText = ""; boolean segmentWithoutLetters = false; for (int i = 0; i < text.length(); i++) { if (text.substring(i, text.length()).trim().isEmpty()) segmentWithoutLetters = !segmentWithoutLetters; if (!segmentWithoutLetters) newText += text.charAt(i); } textField.setText(newText); } }