I want a jTextField that shows suggestions in a popup as the user types (like google suggests). I want suggestions data to be fetched from a database table. I have been looking at SwingX and GlazedLists but I think they provide jComboBox autocomplete, and jTextField does not show a popup in these libraries.
I want to monitor user input and re-query the database after specific intervals.
Thanks.
I would keep looking into SwingX or GlazedLists, to avoid re-inventing the wheel. But if you are doing it yourself:
Add a KeyListener to the field and show a popup just below the text field whenever the user types. The popup could just be a menu with possible items or maybe even a JList. Make sure your database query can keep up with the typing or put the work on a separate thread.
Related
Java Swing: I recently started learning Swing and I want to add several labels, one button, and three combo box INSIDE A Drop Down Pane! When the user clicks the drop down pane, you can see labels, textfields and comboboxes which will contain the values and when the users clicks drop down pane again, then all the textfields, labels etc are hidden. Is it possible and if yes then could you please help me out (code would be very much appreciated). If you did not understand the design then please visit emirates.com and click on 'Book a Flight'! I'll be trying to implement that type of design
If you want a multi-row data display object, and you want multiple interactable components on the row, don't use the wrong tool, a JComboBox, for this. Use a better tool: a JTable.
I am looking for a way to create a popup dialog box when a user double clicks a textinput field that will contain a scroll-able list (from database table) where the user can select a field, hit ok, and have it placed into the textbox when popup closes.
The other major requirement is to have a filter/ or search field in the popup to aid the user in finding the correct option to select from quicker.
What is the best way to implement this?
Modification to gwt's popup panel? maybe a JOptionPane? are there any simple solutions already designed for free commercial use?
You could implement this with a com.google.gwt.user.client.ui.PopupPanel. You can make a PopupPanel that contains a ListBox with your data from the database, along with a OK button. When a user selects a value and hits OK, you should utilize an EventBus along with a custom Event that will pass the value to the field on the page. The page will have an event handler that will catch the event and put it into the field.
Another option is to use a com.google.gwt.user.client.ui.SuggestBox. It is a box that autocompletes / suggests values as you type, kind of like the Youtube search bar.
I can offer more resources to help you accomplish this, if you'd like.
I have a Swing Application with a JTextField that the user is Supposed to Input ID Numbers. The ID Numbers are Stored in a database. During Inquiry from the DB the End user is again required to Input the ID Number so as to Query the DB. I need suggestions as to what to do so that when the user Inputs the First Digits of the ID Number, Guesses appear below the JtextField for the User to Choose from. Is this Possible with Swing and what Is the Best way to Implement it?
http://www.orbital-computer.de/JComboBox/ Maybe this helps. I know I shouldn't post just a link. But I cannot write everything explained there again here.
Try AutoCompleteDecorator in swingx. Check this post.
still not sure,
you can to use AutoCompleted JComboBox / JTextField (AFAIK ther no issues with Document, Focus, Caret and Selection/HightLighter)
(and to combine with a.m. point) to use filtering in JTable (with one Column and/or without JTableHeader) placed in the undecorated JDialog or JWindow(undecorated by default) in case that you want to display popup window with long list of sentences in the scrollabel contents, that could be clickable
use Swing Timer (5 -10 seconds for autohide for popup window)
share (use the same) model for JTable and AutoCompleted JComboBox / JTextField based on Vector or ArrayList,
to check focus lifecycle (nothing better aroung) for popup window as Java Calendar by Kai Toedter (download codesource)
You should write a PickList class which must contain a SQL Query select * from dbtableName where empId %getUserInput()%;
Creating front-end (Java) user interactive table using MySQL as back-end
Now im trying to create user interactive form.
Untill now, I have created a form view, using swing components, JLable, JTextfield where user enters data. JButtons, 'new' 'save' 'delete' 'edit', which listens user action through ActionListner.
A table that 'extends' AbstractTableModel. Table values are the ResultSet values. i have used MySQL connectivity.
Table is displayed. User can now add new row to it, using 'New' and 'Save' button.
My problem is, i need the corresponding TextFields to display the corresponding row user selects in the displayed table, so that 'edit' and 'delete' would be user interactive. users are allowed to select table's row. Need Help.
Im sorry if any mistake in my question format and language. Thank you!
i need code for creating table ...
ple help me on tis....
i need code for creating table
How much will you pay? :)
..i need the corresponding TextFields to display the corresponding row user selects in the displayed table..
For that you can use,
Give a button, like EDIT and in the event handler for EDIT use something like,
jTextField.setText( jTable.getValueAt(
jTable.getSelectedRow(),
jTable.getSelectedColumn())
.toString()
);
2.As an alternative you can also utilize the event in jtable like mouseClicked with the above code
Now regarding the edit and delete , you may utilize the focusLost event of the textfield or use a EDIT or DELETE button, and carryout the updation, which will be much reasonable option.
Additionaly have a look at this : Using JDBC with GUI API
I'm working on a form and I'd like to have a drop-down box where you select a person. It brings up their stored information in the text-fields below, but as soon as you edit one of the text-fields it disables the drop-down box until you save or cancel the changes. The purpose of this is to prevent the user from editing something, thinking it's saved, and then changing to a different person and losing their changes.
Add a DocumentListener to all your text fields. Whenever any data is changed you disable the combo box. When the data is saved you enable the combo box.
See How to Write a DocumentListener for more information and examples.
A better approach might be to popup a JDialog with the data to be changed.
Dynamically disabling combo boxes doesn't seem like a common practice. Perhaps instead you could indicate to the user when something is saved, and if the user attempts to switch people after info has been inputted, you could notify them and ask if they want to continue and lose the data. Is it not possible that some users will enter data, try to use a disabled combo box, and not knowing why it is disabled, they will think you program is broken?