jtextfield

Disabling 'paste' in a jTextfield

Hi I have an app that is written in Swing, awt. I want to prevent users from pasting values into the textfields. is there any way to do this without using action listeners? ...

Java GUI Creating Components

I hope it is correct term-wise to say that components in a GUI is like JButton, JPanel, JTextField, all that good stuff. I want to create a text field that takes in an integer. Then a submit button can be pressed and based on the integer that was inputted, create that many textfields in a popup window or whatever. I have no clue, could...

Getting ENTER to work with a JSpinner the way it does with a JTextField

First, to make my job explaining a bit easier, here's some of my code: JSpinner spin = new JSpinner( ); JFormattedTextField text = getTextField( spin ); text.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed( java.awt.event.ActionEvent evt ) { // Do stuff... } ...

Adding JTextField to a JPanel and showing them

I'm building a little app using Java and Swing in NetBeans. Using NetBeans design window, I created a JFrame with a JPanel inside. Now I want to dynamically add some jTextFields to the JPanel. I wrote something like that: Vector textFieldsVector = new Vector(); JTextField tf; int i = 0; while (i < 3) { tf = new JTextField(); te...

No blanks in JTextField

How can I forbid users to put blanks into a JTextField? It should not even be possible to write blanks. ...

loop through JPanel

Hi there, In order to initialise all JTextfFields on a JPanlel when users click a "clear button" I need to loop through the JPanel (instead of setting all individual field to ""). Can someone please show me how to use a For Each loop in order to iterate thru the JPanel in search of JTextFields. Very much appreciated Dallag. ...

JTextfield array help

I have been trying to create a JFormattedTextField array which populates in a pane. Once a click event occurs, the actions get processed and the textfields are populated using setText(). The code for the array and initializing is in the constructor method here: JFormattedTextField[] balance=new JFormattedTextField[360]; JFormattedText...

non-editable JTextField: Set visible area

Hi, I have a JTextField with a fixed width, let´s say 100 pixel. Now, I put a text inside this JTextField whose length is greater than "100 pixel", means you have to scroll in the JTextField (possible width mouse). The JTextField isn´t editable. How can I make sure that the part of the text I see is the beginning, not the end of the t...

JButton needs to change JTextfield text

This is homework. Beginning Java class. Still wrapping my head around this stuff. The project is to make an Inventory Management System. I have everything figured out except how to make this button change the text in a JTextField. It needs to add info from an array of a product (DVD's in this case). The book talks about different wa...

JButtons need to modify 8 JTextFields using an Array. Listen to Buttons or Text?

This is homework. Beginning Java class. Still wrapping my head around this stuff. This questions Extends this one So there is a button for First, Prev, Next, and Last Each should modify Item ID, Name, Rating, Price, Units, Value, Fee, ValueW/Fee, Total Inventory Value The last one is a static total of all units) I am not sure if ...

KeyListener(KeyPressed) doesn't working

I try to make it like this : Try using a key listener to detect each time the user enters text into the field. Each time the key event is triggered, get the length() of the text in the JTextField. If the length >= limit, then disable editing. However, if the delete key is pressed, remove the last character in the JTextField and setEditab...

Ctrl-Delete in JTextField

How can I get JTextFields to allow Ctrl-Delete and Ctrl-Backspace when editing text? In various other programs, these key combinations can delete an entire word in one go. From what I can tell, the default behaviour of a JTextField allows the user to use CTRL to jump over an entire word when using left and right keys, and to select an ...

How to disable default textfield shortcuts in JTextField

I have a custom textfield class that extends the JTextField class in Swing. I need to find a way to disable the default actions for Ctrl-A (select all), Ctrl-H (backspace) etc, so that the window containing the textfield can map these shortcuts to whatever it wants. Any help would be greatly appreciated. ...

How do I fire an action when the user leaves a JTextBox?

I've got a JTextField, and I'd like the system to do some processing on what the user typed whenever the user leaves the text field. The ActionListener that you can add to just the JTextField only fires when the user presses enter, however. I'd like the processing routine to run whenever the user leaves the text box by any means - tabs,...

Mac L&F problems: Differing behavior of JTextField.requestFocus()

I have a problem with JTextField.requestFocus() behavior that appears to be different on Mac OS X. Here is my situation: I have a dialog with a JList and a JTextField. The user is supposed to write a boolean expression in the text field, and the list contains the names of all the variables that might be entered in the expression. Becau...

Java: link JSlider and JTextfield for float value

what is the best and easiest way to link a JSlider and a JTextField so that if one changes, the other gets updated too, but there is no recursive loop? thanks! ...

JTextField and \r\n problems

Hello, Part of an app I am working on includes a log file viewer, with a find text function, which calls a pattern matcher on JTextField#getText(), like so: Matcher m = somePattern.matcher(textField.getText()); m.find(startPosn); System.out.println("startPosn: " + m.start()); System.out.println("endPosn: " + m.end()); where textField...

Change the direction of growth for a JTexField object.

Hi SOers, I need to change the direction of the growth of JTextField object when more characters are added to it. Currently when I add more stuff to it, it grows from left to right but I need this growth of the bounds of the JTextField from right to left. For e.g. when I add "StackOverflow" to this JTextField the o/p is, <empty space>St...

Is there an easy way to get characters from the keyboard without hitting enter in Java?

I'd like to know if there is an easy way to get character input from a JTextField in Java as they happen, not after an enter keystroke. In my case I want the characters (text) to be read in, and when the enter key is hit, do something with the characters already collected. ...

Putting the contents of a JTextField into a Variable - Java & Swing

So i creating a little java app and am just wondering how i can get the contents of a JTextField and then assign the value into a String variable, I thought below would work: JTextField txt_cust_Name = new JTextField(); String cust_Name; txt_cust_Name.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ...