jtextfield

Java. GUI WindowBuilder read from JTextField by clicking button

旧时模样 提交于 2019-12-04 05:39:25
问题 I'm useing WindowBuilder, and I want to ask how to search in a text file for specific word, which I enter to JTextField by clicking a Search button? My program looks like this: image http://img252.imageshack.us/img252/1410/39931036.png This is my JTextField and JButton : private void initialize() { frmInformacijaApieMuzikos = new JFrame(); frmInformacijaApieMuzikos.setResizable(false); frmInformacijaApieMuzikos.setIconImage(Toolkit.getDefaultToolkit() .getImage(KDVizualizuotas.class

setBorder on JTextField does not work ? or does it?

回眸只為那壹抹淺笑 提交于 2019-12-04 05:23:53
The code is like this: JTextField txt = new JTextField(); txt.setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.red)); However the text field is ignoring my call to setBorder . No changes whatsoever. I were to replace it with a JLabel (for instance) JLabel txt = new JLabel(); txt.setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.red)); I would see the red border. Can anybody tell me why? Or even better explain to me how to add a border in the JTextField ? Check out this explanation/recommendation from the Java API In general, when you want to set a border on a standard Swing

Change input language in java

痴心易碎 提交于 2019-12-04 05:22:37
问题 My application is in Hebrew. The computers that are running my app all have English set as the default language and Hebrew as the secondary language. Every time they need to input stuff to my JTextFields, they have to "alt + shift" to change language, Some of them don't even look at the monitor and just begin to write, and I get gibberish because they wrote in Hebrew but with English chars :) Is it possible to set the language when a JTextFields gets the focus , or maybe in some other way ?

Populating JTextField based on latest KeyStroke

ⅰ亾dé卋堺 提交于 2019-12-04 05:16:12
问题 The use case in my UI is to populate two JTextField components based on double clicking items in a JList . The easy was is to use a JCheckBox populate jTextField1 if the checkbox is selected, and populate the other if it is not selected or vice versa which is working perfectly. But I would like to explore if this can be done without the checkbox. As in, if I type something in jtextfield1 and double click the item in list to complete the text, the item clicked should be appended to jtextfield1

Filtering JList based on JTextField

亡梦爱人 提交于 2019-12-04 05:13:15
I have a JTextField and a JList in my program. The JList contains the user's contacts. I'd like to filter the JList based on the text on the JTextField. For example, if I type in "Mike" it will only show contacts including "Mike". When the user clears the JTextField it would reset the filter. I know I could do this manually by having two arrays. One for the original contacts and one for the filtered ones. When the user changes the value of the JTextField I would go trought the original list, update the temporary list and update the JList. I just wonder if there is some built in feature to

Best way to implement a selection box from a large number of entries

送分小仙女□ 提交于 2019-12-04 04:19:51
问题 I have a large set of data from which the user has to select one. I'm thinking of a way to implement it (of course, in a GUI). I have a few ideas. But just thought of posting here as there may be better alternatives.. Say, user has to select a name from a large set of user base. If I simply put a text field for user to enter the name, then there can be issues like entering same name in different formats, misspelling etc... I see two options here Using a combo box Using a list (Actually i'm

JTextArea and JTextField internal padding on text

非 Y 不嫁゛ 提交于 2019-12-04 03:21:19
I would like to increase the spacing / padding / insets for the JTextField and JTextArea . Effectively increase the spacing between the two red lines in the image below: Luhar You could also try using an EmptyBorder to put in gaps between the two components. If you already have a Border, you can use that in conjunction with an EmptyBorder to create a CompoundBorder. In the code fragment below, a new CompoundBorder is created that has a TitledBorder and an EmptyBorder which enforces a padding of 1 pixed around the component. testPanel.setBorder( javax.swing.BorderFactory.createCompoundBorder(

JTextField setEnabled vs setEditable

烈酒焚心 提交于 2019-12-04 02:59:41
What is the difference between JTextField.setEnabled() and JTextField.setEditable() ? In my code I have an Instance of a class inherited from JTextField . But when I set its property setEnabled(false) I can still edit and process its contents in my program. However when I set its property setEditable(false) I can no longer edit its text. If it is so. Then what is the purpose of setEnabled() property here? My Code for inherited class is: private static class CCField extends JTextField{ private static final long serialVersionUID = 1L; public CCField() { this( DEFAULT_COLUMN_COUNT ); } public

Small GUI issue I cannot fix. JTextFields

风流意气都作罢 提交于 2019-12-04 02:32:18
问题 Small error I can't manage to do. So right now my program GUI looks like this: Now there is a TextField under the 'Mark' column were the user can input their data. I also want the same for the weight section were I want to insert a TextField right under 'Weight' column. However when I try and put in a TextField, both the the Textfields turn like this when the window is small: and this when the window is enlarged: How can I make it so that there is a textfield under Mark AND Weight? Code:

Need to read input of two JTextfields after a button is clicked

前提是你 提交于 2019-12-04 02:19:56
问题 I'm working on a program that launches an applet that will demonstrate how the Extended-Euclid algorithm performs. I have two JTextFields that values will be entered in and need to be read/converted to ints, etc. I'm having trouble actually reading the input values to start with. Updated question: I've made changes to my code after reading the first answer. Instead of using a DocumentListener I'm doing everything in my actionPerformed method as suggested but when I try testing I'm still