I am making an accounting software using Netbeans and MySQL.
I need to reload the page on a button click.
As in, the page takes entry for a product. When Add button is clicked, the entry should go into the database and the JFrame that takes the entry should be reloaded to take next entry.
The entry gets entered into the database but the reloading fails and the project needs to be rerun in order to upload next entry.
The entry system takes an input from a combo box and 10 other text boxes. On clicking the add button, the entries get added to the databas and all the fields are reset. Indeed. But the problem is, now the fields arent editable anymore.
revalidate() and repaint() aren't working.
What other options are there ?
Clear the JTextField text elements after clicking the button and change the selected indexes for the JComboBox elements. For instance, in your button's ActionListener:
tfTextField.setText("");
cbComboBox.setSelectedIndex(-1);
this.dispose();
JFrame f = new Add();
f.setVisible(true);
This did it.
The form gets disposed and then it loads again.
Related
I have a webpage See WebPage screen shot
Code
WebElement whatAirline = driver.findElement(By.cssSelector(".BaggageFlightDetailsView-airlineField input"));
whatAirline.sendKeys("AeroGal (2K)");
whatAirline.submit(); //This is kind of drop down menu list is the COMBOBOX with no class 'select', just class 'input'
WebElement confirmationCode = driver.findElement(By.cssSelector(".Input-input"));
confirmationCode.sendKeys("test");
whatAirline.submit();
It brings me to the previous page, though 'Next' button on this page becomes enabled!
IMPORTANT:'Next' button is not even a button it just has class -that's all, no other data! `class = ''PagerButtons-button PagerButtons-button--next''
What else i tried? Explicitly wait, click 'Next' as a button (though it is not even a button)
Nothing works ! HELP!
I think you have entered invalid data in any of two fields. So the next button may not be enabled, it automatically clicks enabled back button. Check your inputs.
Use select class for drop down list. Also use explicit Wait to click next button.
Solved!
The problem that i found was:
Combobox was not holding the value selected in drop-down, just typed it.
System was taking me back because 'Back' button was the only one enabled.
That is why submit was taking me back every time.
I added whatAirline.click(); before submit and it worked out!
Please note, that i should have not write button click as on top of everything i had no button at all, just an element that looked like a button.
I work with swing to build GUI. Hello everyone
I have 2 tabs (JTabbedPane) that I want to synchronize.
For example, on the image below, I would like that if I click on the Rent button, the line can be automatically added to the My leasing tab so that if I go to the My Leasing tab, I find the line that has just been added.
Currently, to see the line that has just been added to the My leasing tab, I must log out and log back in.
I tell myself that there may be a listener to put in place but I do not know which one.
You need to respond to the click of the "Rent" button.
Check out the Table Button Column. This class allows you to add an ActionListener which is invoked whenever the button is clicked (or activated by using the space bar).
The example code shows how to delete a row from the model. In your case you would want to copy the data from one model to the other.
I have created java swing application. In that application, there is a textfield.I have attached key listner for that text field also. Using that, enter key is identified and popup another JPanel. There is a JTable which is loaded data from DB and there is a JButton. The selected row from that table is loaded to that previous textfield.
There is a very rare issue with that implementation. when we have that JPanel, mistakenly the user pressed the enter button twice in very very short period at once. Then after we load that panel ther is a unusal behavior. by default the JButton is pressed without any key pressed.
According to my investigation, the problem can be solved, if we have a method to cler keylistner actions once it finished.
Are ther any methods?
Hy everyone,
I was just learning some new things with Java GUI, and I got stuck with a problem. This is what it looks like:
I want a button that adds the data from the second JPanel in to the first one.But not only once. I want it to go to the first JPanel, everytime it is pressed.
So, the button should create a new JTextField in the first JPanel, below their respective categories "name" and "age" everytime it is pressed. It means that I have to modify the "Y" field everytime, so all the new JTextFields created by the button "add data" dont get pilled up.
I don't know how to make the button "add data" Works, the other things, I know how to do. I know how to make the button creates a JTextField, with the data I want to store, only once (using getText() and setText() ), but not how to create new JTetFields with diferente "y" field everytime it is pressed.
Thank you for the help.
When you click on the button to add people you should not display a new JPanel. Instead you should display a modal JDialog. A JDialog is just like a frame but generally is only displayed for a specific function and then closed.
On this dialog you will probably want two buttons: 1) Save Data and 2) Close. This will allow you to enter information for multiple people before closing the dialog.
To display the "person" information you should probably be using a JTable. A table allows you to display data in a row/column format. See the section from the Swing tutorial on How to Use Tables for basic information to get you stated. Note, in this cause you will want to use a DefaultTableModel for your table and then you can just use the addRow(...) method to save the "person" information.
When you create the class for the dialog to get the "person" information you will want to pass the DefaultTableModel to this class as a parameter. Then when you click the "Save Data" button you get the information from the two text fields and update the TableModel. The table will be updated automatically.
So your first step is to create the main frame with the JTable with the two columns. Then you create a simple "Add Person" button. This button will then add hard coded data to the table each time it is clicked by using the addRow(...) method. Once you get this working then you change the logic of the button to display the dialog and then you can enter the "person" information on the dialog and save it.
I am using Frame with card layout and a few panels.
In the first panel, there is a textField object that reads name and a button, which on clicking adds the name to the database table. In the second panel, there is a dropdown box which reads the vales from the database which was inserted from the previous panel.
My problem is that, the vales from the db are not added to the dropdown box in the 2nd panel.
This will only work when I close the program and run it again.
Is there a way to refresh the tables and db and the database connection, so that, I will be able to see the values in the dropdown box without having to restart the application ?
Just bind an event to the button to make your dropdown menu to refresh.