I am having a problem on my viewing function in my desktop application.
The program lets the user view the names and corresponding details by clicking the "view all" button.
The problem is if the user clicks the "View all" button again it will add another set of the list stored in the database.
This is what happened after the second click
Can you help me stop this problem?
Clear the JTextArea in the View All button's actionhandler. Use the setText(String s) method to achieve that.
Your data is not formatted in a legible manner. It would probably be better to use a JTable to display the data. Read the section from the Swing tutorial on How to Use Tables for more information and working examples.
When you are ready to refresh the data you create a new TableModel with the updated data. Then you update the table with the new data by using:
table.setModel( yourNewModel );
Related
Hello i have this Abstract Table which im making a video hiring application with. I want the user to be able to sort through the table with buttons I have supplied. In the buttons I have a "Show only overDue videos" so when the user hits this button in my action listener i want to be able to hide the rows not delete them so when the user clicks another button they will re-appear any ideas on how i would go about doing this?
Use the filtering support provided by JTable.
Read the section from the Swing tutorial on Sorting and Filtering for more information and examples.
1) Maintain a master Data list. Intially the table model data will reflect the Master data.
2) When the user "press show only over due vidoes", iterate the master data and filter only the required elements and clear the table model and add only the filtered data to the table model and fire table model changed.
I have created a JTable using GUI Builder in NetBeans. It is Currently Having no data. The table is editable, and is Displayed in on a Panel. This Table is called passengerDetailsTable. Now I want users to Write data in its cells and after entering data, when they press submit, data should be extracted from table and available for processing. But I am unable to do it.
I have written sample code to do above:
TableModel tm = passengerDetailsTable.getModel();
Object o = tm.getValueAt(1,1);
System.out.println(o.toString());
This code is triggered when I press submit button.
According to me It should print the value at cell(1,1). But it gives Null pointer exception. Please help me to resolve it.
Now I want users to Write data in its cells and after entering data,
Did the data get saved to the model?
See Table Stop Editing for a way to make sure the data is save when you click a button.
If this doesn't help then post a proper SSCCE that demonstrates the problem because we don't have enough information to keep guessing what you might be doing.
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.
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 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.