Creating front-end user interactive table using MySQL as back-end - java

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

Related

Connecting two columns in two different comboBoxes

I connected MySql database with Java app, I see data from two different columns (Items, Price) but I want to connect them somehow, for example, if choose in first combobox item "Desk" the other combobox should automatic find "Desk" price and display it in second combobox. Anyone have idea how to make that ?
You could write a changelistener for the first box, then have it go into another sql query which will populate the second box. Check out this guide, it'll explain to you how to do it
https://docs.oracle.com/javase/tutorial/uiswing/events/changelistener.html
First, I think that you don't want to ComboBoxes being correlated in such a way. There must be a better design for your gui.
Is your ComboBox from JFace? There are JFace Data Bindings. Normally, you use them to automatically update your model if someone changes values in the user interface. If your model contains an id from your database, both comboboxes can have a binding to this id.

Oracle ADF stop validation on empty table row, validate in popup form instead

I'm currently developing a simple application which does crud operations on a few tables.
It looks like this:
I have a problem with the add item form, invoked by pressing the button saying "Nova jedinica mjere". It opens a popup containing an ADF form as follows:
As you can see it does a create insert operation on popup fetch event, creating an empty row. When I fill the form with data, and press OK(the ok button is handled in the bean, doing a commit operation), I get an empty error message as follows:
This only happens if the table is editable(consisting of input text elements). If it is set to click to edit, this problem does not occur. How can I make validation only occur on form fields?
If you need any more info, please let me know because I too am new to adf.
EDIT:
This is the page in question:(posted as a pastebin link to not take up much space).
http://pastebin.com/5TKyPxEs
The form in the popup is a static region from a task flow with a method call and a page:
http://pastebin.com/9h69fRW4
You mean to say that when you enter the value in the form and Click OK, it should be there in the Table,If so, the values are not getting displayed in Table. It means your Iterator is not fetching the values. You have to Refresh your Iterator, VO and Table Compoent through Bean. So that the values in the form once you click OK, it will be there in the Table.

How to edit Rows in an Abstract Table Model

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.

How to Extract Data from a JTable filled by user in Java

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.

Change the data of database dynamically without changing the frame in swing

I am a doing a project on Exam Suit in Netbeans swing java application. I have done all my work like login page, sign up page etc etc. But the main problem stick with exam page. I have inserted all the question and there choices with answer(not shown) in a database. I have designed one frame, 1 label for question and three radio buttons for choices and an OK button to select the choices and NEXT button to goto next question. I can easily get the data from database of only one row. But to get the other question I should keep the code in NEXT button, but this can be done only one time. I just want to change the data from table dynamically on click of NEXT button. I am unable to do this, Please help me. Thank You.....
Since your program acesses a database, I assume that you are using ResultSet from JDBC. You need to call ResultSet.next() each time the user clicks on the "Next" button. As long as you keep a reference to the ResultSet, you can call this method until you reach the end of the data set.

Categories

Resources