Results 1 to 2 of 2
Thread: Using another form
- 03-23-2012, 02:32 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 11
- Rep Power
- 0
Using another form
Hi, My problem is i have a button that brings up a form. the user then enters two piece of information into this form a barcode and a price what i want is when i click ok of the new from the data is sent to the old form and a method is ran. my only problem is if i put the method right after creating an instant of the new form and makign it visible the method just runs. i only want it to run right after i have clicked the ok button on the new form. here are some snippits of code
and here is the other formJava Code:private void discountBtActionPerformed(java.awt.event.ActionEvent evt) { discountItems discount = new discountItems(); discount.setVisible(true); addItem(discount.getBarcode(), discount.getPrice()); }
Any help you be very well appricated Thank youJava Code:private void okBtActionPerformed(java.awt.event.ActionEvent evt) { if (barcodeTf.getText().length() < 10) { JOptionPane.showMessageDialog(rootPane, "Please Enter 10 Digit Barcode"); } else if (discountPriceTf.getText().length() == 0) { JOptionPane.showMessageDialog(rootPane, "Please Enter a Discount Price"); } else { discountPrice = Double.parseDouble(discountPriceTf.getText()); barcode = barcodeTf.getText(); this.setVisible(false); } }
- 03-23-2012, 02:48 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Using another form
Either you want to be using a JDialog of some sort, or you want to give the second (form) thing a callback method.
So user clicks button on FormA.
FormA creates FormB, supplying itself as a callabck (I'd make it an interface, since that'll make it easier to change if need be). That callback interface will simply have an updateDiscount(barcode, price) method.
FormB will call that method on the stored callback, inside that okBtACtionPErformed method above.
Personally I'd go for the JDialog.Please do not ask for code as refusal often offends.
Similar Threads
-
<html:form> struts form not working if it is inside a jsp under WEB-INF
By dariusaron in forum Web FrameworksReplies: 6Last Post: 04-06-2011, 12:39 PM -
Data wouldnt't read from my form called 'express' in form'ticketing'
By realmadrid_000 in forum AWT / SwingReplies: 8Last Post: 10-03-2010, 09:45 AM -
looking for a form pane or form group panel for the jpanel to complete tutorial
By nadeemshafi9 in forum AWT / SwingReplies: 1Last Post: 03-22-2010, 09:03 AM -
use Servlet submit the form to receive a form for the Chinese but it shows the garble
By dmt198704 in forum Java ServletReplies: 0Last Post: 10-31-2009, 09:24 AM -
want to generate a html form page with dynamic data and submit this form to a url
By vishalkrsrivastava in forum Java AppletsReplies: 10Last Post: 08-12-2009, 04:02 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks