Problem with submit button of jframe

hi all
i am having problems with the submit button. once the submit button is clicked the values should be updated to an array of objects. it is doing this. the problem is i want the current frame to close once i click submit button. i have a GUI at the background and once i click something this frame appears asking for details for th user to input. but i want only the current form to close, not the whole progrmy code is shown below
thanks in advance
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class TextForm extends JPanel {
public JTextField[] fields;
public MainInteractiveMap mainClass;
public TextForm(MainInteractiveMap m)
mainClass= m;
public TextForm(String[] labels, char[] mnemonics, int[] widths, String[] tips)
super(new BorderLayout());
JPanel labelPanel= new JPanel(new GridLayout(labels.length,1));
JPanel fieldPanel= new JPanel(new GridLayout(labels.length,1));
add(labelPanel, BorderLayout.WEST);
add(fieldPanel, BorderLayout.CENTER);
fields= new JTextField[labels.length];
for(int i=0; i< labels.length;i+=1)
fields[i] = new JTextField();
if (i<tips.length)fields.setToolTipText(tips[i]);
if (i<widths.length)fields[i].setColumns(widths[i]);
JLabel lab = new JLabel(labels[i], JLabel.RIGHT);
lab.setLabelFor(fields[i]);
if (i<mnemonics.length)lab.setDisplayedMnemonic(mnemonics[i]);
labelPanel.add(lab);
JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
p.add(fields[i]);
fieldPanel.add(p);
public String getText(int i){
return (fields[i].getText());
public void printForm()
String[] labels = {"Location","No of Bedrooms","No of Bathrooms", "Garage","last selling price","current selling price"};
char[] mnemonics ={'L','B','b','G','L','C'};
int[] widths = {15,1,1,4,9,9};
String[] desc = {"Location","No of Bedrooms","No of Bathrooms", "Garage","last selling price","current selling price"};
final TextForm form = new TextForm(labels,mnemonics,widths,desc);
JButton submit = new JButton("Submit");
submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
String location;
final int sellingPrice;
final int numOfRooms;
final int marketPrice;
final int numOfBathrooms;
final int numOfGarages;
location=form.getText(0);
sellingPrice=Integer.parseInt(form.getText(1));
numOfRooms=Integer.parseInt(form.getText(2));
marketPrice=Integer.parseInt(form.getText(3));
numOfBathrooms=Integer.parseInt(form.getText(4));
numOfGarages=Integer.parseInt(form.getText(5));
mainClass.Testing(location);
System.out.println(numOfGarages);
System.exit(0);
JFrame f = new JFrame("Input details of House");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(form, BorderLayout.NORTH);
JPanel p = new JPanel();
p.add(submit);
f.getContentPane().add(p, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
regards

you just need to change (at end of actionPerformed())
System.exit(0);
to
[whateverFrame].dispose();
easier to show a simple demo
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Testing
  public void buildGUI()
    JButton btn1 = new JButton("Open new Frame");
    final JFrame f1 = new JFrame("#1");
    f1.getContentPane().add(btn1);
    f1.pack();
    f1.setLocationRelativeTo(null);
    f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f1.setVisible(true);
    btn1.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent ae){
        JButton btn2 = new JButton("Close/Return");
        final JFrame f2 = new JFrame("#2");
        f2.getContentPane().add(btn2);
        f2.pack();
        f2.setLocationRelativeTo(null);
        f2.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);//do not want to close with 'X'
        f1.setVisible(false);
        f2.setVisible(true);
        btn2.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            f2.dispose();
            f1.setVisible(true);
  public static void main(String[] args)
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        new Testing().buildGUI();
}

Similar Messages

  • Problem with submit button - Acrobat/Reader

    I have created a simple fillable form with Adobe Acrobat XI Pro with a submit button, form posted to the web. The form/button works fine for me in Google Chrome, IE, and Safari (Windows 8, Outlook email client) but doesn't seem to work for users with only Adobe Reader (9 was tested using an older version of Windsows and Outlook). After completing the form successfully, they are returned the error message: "This operation is not permitted" when they attempt to submit their form using the submit button. I'm not sure what program is causing the problem. How do I fix this?

    You need to Reader-enable the form using Acrobat. Before Reader 11 was introduced, Reader was not able to save a fille-in form unless the document was enabled. Since the changes need to be saved in order to attach it to an email, this is necessary for previous versions. Do enable a form in Acrobat 11, select: File > Save as Other > Reader Extended PDF > Enable More Tools

  • Problem with Submit Button in Adobe Forms Central

    I have a PDF form that I uploaded to Adobe Forms Central.  I created the fillable fields & the submit button in Forms Central.  I have several documents like this.  All have worked in the past.  Today on my latest file, the submit button doesn't always work.  I am getting some submissions, but some people have reported to me that the submit button does not work.  I tested it myself to see.  I had to create a Digital ID for myself, which seemed to work fine.  But when I click on submit, the form says "Submission Failed.  This form can no longer be submitted. Please contact the author."  I'm the author & don't know what the problem is.  Anyone know what the problem could be?

    The form is open. I should have mentioned that I made sure to check that first.  The form was created by uploading an existing PDF file that I created from a MS Word file to Adobe FormsCentral. Once the form was completed, I had a coworker test it & it worked.  We sent the form out & I have received some back, but have also received reports of the form not working.  I downloaded the form to my computer & tested it using Adobe Acrobat 9.0 Standard.  I use a Windows environment on a Dell laptop.  The form does not work for me.

  • Problem with submit button in wweb dynpro abap

    hi all,
                we have problem in submit of our interactive form in web dynpro abap.
    my scenario.
                             on event submit we have to fetch data from database table and display the same.
    On click of the SUBMIT button for the first time it fetches data but when we change the input field and submit again it dsnt trigger the event(We need to double click only then event is triggered).
    Can anyone guide us on how to fetch the data at single click.
    Thanks and Regards
    Vinoth

    The form is open. I should have mentioned that I made sure to check that first.  The form was created by uploading an existing PDF file that I created from a MS Word file to Adobe FormsCentral. Once the form was completed, I had a coworker test it & it worked.  We sent the form out & I have received some back, but have also received reports of the form not working.  I downloaded the form to my computer & tested it using Adobe Acrobat 9.0 Standard.  I use a Windows environment on a Dell laptop.  The form does not work for me.

  • Problems with "Submit" button on simple PDF form.

    Hi there!
    I have searched, but perhaps not searching forums correctly to find my answer as this seems like it should be easy to fix (she said hopefully).
    I have created a simple, offline PDF form for an event registration.
    I have fields all done, set it up to email back a simple FDF from the client with a Combo Box "Submit" button.
    When the client fills in the fields and hits "Submit" button, she gets:
    "The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder."
    I created this in Adobe Acrobat 9.
    Client is filling in using Windows XP.
    I have extended release, no security, etc.
    Is there something simple I am missing?
    Have been able to get this to work before.
    But now, not so much!
    Any help is greatly appreciated!
    Thanks!

    That's not normal. Do you know what version of Acrobat/Reader the other person is using? Can you post the form somewhere? If not, I'd be happy to take a look at it if you are free to email it to me at: acroscript at gmail dot com

  • Problem with submit button

    I have installed Acrobat 9 professional and have created a PDF with field codes embedded.  At the top of the last page, I created a button which sends the form and answers to an email account (mailto: command is used).  The form works beautifully for me but not for anyone else.  There is no protection or other specialized settings enabled.  I can fill it in and submit the form with either Reader or Acrobat Pro.  Any suggestions or ideas to solve this little problem would be greatly appreciated.

    If they are using Reader you must either enable Reader Rights or change the submission to data only (preferred). You did not say if the form was created in Acrobat or Designer. There are significant differences and you need to indicate which you used.

  • Newbee,Having problem with submit button

    Hi All,
    I am very new to servlet.I am trying to delete record from my list which i am loading and showing from same servlet.It is compiling fine but when I press delete button it is not deleting the record.I don't know what's wrong with it? After delete happes i just want to see the list.
    please somebody help me.
    Here is my code:
    public class Delete extends HttpServlet
    private static final String title = "Delete Messages";
    private int load_count = 0; // to verify reloading
    private Exception initial_exception = null;
    private Connection cx = null;
    private ResourceBundle rb = null;
    private String table = null;
    private List messages = null;
    public void init()
    try {
    rb = ResourceBundle.getBundle( "Settings" );
    table = rb.getString("table");
    Common.load_driver( rb );
    catch (Exception x) { initial_exception = x; }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    doGet(request,response);
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    HttpSession session = request.getSession();
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    if (initial_exception != null)
    out.println(initial_exception);
    return;
    messages = (List) session.getAttribute( "messages" );
    try {
    if (cx == null || cx.isClosed())
         cx = Common.get_connection( rb );
    if (messages == null)
         if (Common.DEBUG) System.out.println( "\n=> initial load of table" );
    messages = Common.getTable( cx, table );
    session.setAttribute( "messages", messages );
    catch(Exception x) { out.println("FIRST" + x); return; }
    out.println( "<html>"
              + "<head><title>" + title + "</title></head>"
              + "<body>"
              + Common.debug_display( request, load_count++ )
              + "<h3 align=center>"
              + title
              + "</h3>"
              + "<form action='..'>"
              + "<input type=submit value='top' />"
              + "</form>"
         String selected_index = request.getParameter("index");
         System.out.println("index=" + selected_index);
    if (messages.size() == 0)
    out.println( "<h4 style='color:red'>NO MESSAGES</h4>"
              +"</body></html>" );
    return;
    out.println( "<form>"
         + "<select name=index size=5 onchange='submit()'>\n"
         + Common.selection_list( messages, selected_index )
         + "</select>"
         + "</form>"
    if (selected_index != null)
         Message m = null;
    try {
    m = (Message) messages.get(Integer.parseInt(selected_index));
    catch(Exception x) { out.println("SECOND: " + x); return; }
    out.println( "<table>\n"
    + "<tr valign=top>\n"
    + "<td align=right>Creation:</td>\n"
    + "<td>"
    + "<input type=text onfocus='blur()' size=30 value="
    + Common.sgml_quote(Message.time2str(m.getCreation()))
    + ">"
    + "</td>"
    + "</tr>"
    + "<tr valign=top>\n"
    + "<td align=right>Subject:</td>\n"
    + "<td>"
    + "<input type=text onfocus='blur()' size=50 value="
    + Common.sgml_quote(m.getSubject())
    + ">"
    + "</td>"
    + "</tr>"
    + "<tr valign=top>\n"
    + "<td align=right>Body:</td>\n"
    + "<td>"
    + "<textarea onfocus='blur()' cols=50 rows=10>"
    + m.getBody()
    + "</textarea>"
    + "</td>\n"
    + "</tr>"
    + "</table>\n"
    + "<input type=submit name='action1' value='Delete'>"
    out.println( "</body></html>" );
    if (request.getParameter("action1") != null)
    Message m = null;
    String subject = request.getParameter("subject");
    String body = request.getParameter("body");
    try {
    String date = request.getParameter("creation");
    System.out.println( "\n=> date" + m.getCreation() );
    String sql_delete = "DELETE FROM" + messages + "WHERE creation = "+ Common.mysql_quote(m.getCreation());
    Statement st = cx.createStatement();
    st.executeUpdate( sql_delete );
    messages.remove( selected_index);
    session.setAttribute( "messages", messages );
    catch(Exception x) { out.println("SECOND" + x); return; }
    out.println( "<h4 style='color:red'>Message successfully deleted</h4>" );
    subject = body = null;
    out.println( "<html>"
    + "<head><title>" + title + "</title></head>"
    + "<body>"
    + Common.debug_display( request, load_count++ )
    + "<h3 align=center>"
    + title
    + "</h3>"
    + "<form action='..'>"
    + "<input type=submit value='top' />"
    + "</form>"

    I don't understand very well your code because it has no organization. Try to put all your code between a tag that is the word code inside brackets, and close that tag at the end of your code.
    For the code that I read, you're trying to get the parameters of a form that is in the same servlet. And the forms that you print didn't have an action. So, first of all, put an action on those forms, otherwise they will do noting, at least that you supply some javascript, which isn't the case. Later, don't think that you can call or continue the methods on a servlet just because you press a button which is printed in the same servlet.
    Nevertheless, put that code into brackets and we will try to help you better.
    Regards.

  • Problems with submit button.

    All i have run a report with the following SQL which creates the report and assignes tick box to select if you want to keep the value in the row.
    select HTMLDB_ITEM.CHECKBOX(1,recert,'CHECKED') "Accept",traderid,account,alias,credit,currency,allowtrading,ignorepl,riskon,lastmod,whomod,ipaddress,recert from xtrad.xtrader_recert_accounts where recert = '0'
    When i click submit on the report all values in the database get and recert gets set to 1, even if i untick certain one.
    FOR i in 1..HTMLDB_APPLICATION.G_F01.COUNT LOOP
    UPDATE XTRAD.XTRADER_RECERT_ACCOUNTS SET recert = '1' WHERE recert = HTMLDB_APPLICATION.G_F01(i);
    END LOOP;

    So i have changed the line proc to say
    FOR i in 1..HTMLDB_APPLICATION.G_F01.COUNT LOOP
    UPDATE XTRAD.XTRADER_RECERT_ACCOUNTS SET recert = '1' WHERE ACCID = HTMLDB_APPLICATION.G_F01(i);
    END LOOP;
    When i run it i get
    0.02: Processing point: ON_SUBMIT_BEFORE_COMPUTATION
    0.02: Branch point: BEFORE_COMPUTATION
    0.02: Computation point: AFTER_SUBMIT
    0.02: Perform Branching for Tab Requests
    0.02: Branch point: BEFORE_VALIDATION
    0.02: Perform validations:
    0.02: Branch point: BEFORE_PROCESSING
    0.02: Processing point: AFTER_SUBMIT
    0.02: ...PLSQL (AFTER_SUBMIT) FOR i in 1..HTMLDB_APPLICATION.G_F01.COUNT LOOP UPDATE XTRAD.XTRADER_RECERT_ACCOUNTS SET recert = '1' WHERE ACCID = HTMLDB_APPLICATION.G_F01(i); END LOOP;
    0.02: Show ERROR page...
    0.02: Processing point: AFTER_ERROR_HEADER
    Error Unable to update Trader Accounts.!
    OK
    0.02: Processing point: BEFORE_ERROR_FOOTER
    ORA-01722: invalid number
    So that is the ACCID or the variable (i)

  • Problem with submit button in JEditorPane

    Hi,
    I'm trying to create a browser using JEditorPane. But I have 2 problems.
    1. Refreshing the current page in JEditorPane
    2. My HTML page doesn't submit the request at all.
    Is it a problem in JEditorPane or I should make it submit as we do for hyperlinks.
    If yes, then please send me the code to make a HTML page submit.

    The form is open. I should have mentioned that I made sure to check that first.  The form was created by uploading an existing PDF file that I created from a MS Word file to Adobe FormsCentral. Once the form was completed, I had a coworker test it & it worked.  We sent the form out & I have received some back, but have also received reports of the form not working.  I downloaded the form to my computer & tested it using Adobe Acrobat 9.0 Standard.  I use a Windows environment on a Dell laptop.  The form does not work for me.

  • Problems with home button on iPhone 4

    problems with home button on iphone 4

    If its due to sensitivity issues, these self help guides might help.
    http://www.youtube.com/watch?v=zNwr_mxgs9Q
    http://www.youtube.com/watch?v=lSqPC1V0PPg&feature=related
    By the way, alcohol based hand sanitisers work too.
    Don't overapply it in one go though. You'll have to allow the alcohol to evaporate.
    One final tip, after its dried, I'd recommend you to leave your iPhone's home button facing a laptop's vent just to bake it a little drier.

  • I have an InfoPath with submit button, publish the same to form library.

    Hi All,
    i have an InfoPath with submit button, publish the same to form library.
    Now, i open the form  fill it and attach some files, when i press submit button, that attachments will go to the particular document library.
    Can any one help me out.
    Thanks in Advance!

    Hi Anil,
    According to your description, my understanding is that the attachments attached to the form were submitted to an documents library.
    By default, the attachments should be attached with the InfoPath form and will not be submitted anywhere.
    There may be some customizations on the form that is to submit the attachments to the document library.
    Please check the links below if the customizations are made in the form.
    http://www.bizsupportonline.net/blog/2010/01/upload-document-sharepoint-infopath-form/
    http://www.bizsupportonline.net/blog/2010/04/top-10-questions-infopath-file-attachments/
     Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Associating two events with submit button using  javascript in jsp

    Hi
    How can i Associate two events with submit button using javascript in jsp. Firstly it should insert the data to database and secondly it should close the same pop-up window

    Have something like :
    <input type="submit" name="submitbtn" value="Click me" onClick="function1(); function2(); " />
    You just call both functions sequentially, it's that simple. Although using javascript to work with a database, that seems a bit tricky.

  • Problems with parameter button in Crystal Report Server  2008

    Dear all,
    I have problems with parameter button in Crystal Report Server 2008.
    when I created some parameters and groups in Crystal Report 2008, they showed both parameters in 'Parameter button' and group in 'Group button'  on the left, so I can choose or type without clicking 'Refresh button' But when I added it to Crystal Report Server 2008 and I click parameter button , it doesn't show any parameter. Only click refresh button to choose them. On the other hand, for 'Group Tree' is ok. When go to Default Setting-> Parameter, all parameters are in 'Unused parameter'  First time I think I had problems with my installation, but when I reinstalled it again, it was like before.
    Could any one help me with this?
    I appreciate looking forward to your reply
    Ketya

    Try posting your questionin the correct forum, this is for SAP Business One, not Crystal reports Server

  • Problem with Information button in WAD

    Dear Mates,
    I have a problem with Information button in WAD template.
    I have two queries in web template. those two queries are in two tabs( i used Tabstrip ) respectively.
    if i press first tab it shows query1 and if i press second tab it shows query2 absolutely.
    problem
    when i am in first tab, if i click information it will show information about query1, but when i am in second tab,
    if i click information it will show information about query1 only..
    i need it to show information about second tab.
    Please help. Its urgent. Full Reward points will be given.
    Thanks in advance.
    Regards,
    Ranganath

    check out this link
    http://www.mhprofessional.com/downloads/products/0071640266/0071640266_chap01.pdf

  • I was online earlier this week and liked the forms with submit buttons and the Adobe site directed me to upgrade to Adobe PRO XI in order to use forms so I bought five licenses. Just had it installed today and it is now asking me to sign up for forms Cent

    I was online earlier this week and liked the forms with submit buttons and the Adobe site directed me to upgrade to Adobe PRO XI in order to use forms so I bought five licenses. Just had it installed today and it is now asking me to sign up for forms Central in order to use this feature. What gives? The Adobe site gave me the impression that I would have this feature after purchasing the new upgrade. I would not have purchased the upgrade, let alone five of them had I know this. Am I missing something?

    Acrobat XI comes with the Fromscentral AIR application and the ability to create PDF forms authored in Formscentral. To have more than the free (1 form with 50 responses) level account you need to sign up for a Formscentral subscription.
    Andrew

Maybe you are looking for

  • Web dynpro URL not working in user's UWL

    Hi, I am not sure if this is the right place for this question. I have created a web dynpro application and copied the URL and we put this URL in the UWL of a user using workflow, now the issue is when a user click on that URL on the portal side it's

  • Don't get support  of Apple with NEW MacBook Air !!

    31 july 2012 i have purchase Mountion Lion , only last week i had the time to install it on my IMac 27" Since then i have problems with it. Apple touchpad moving = ok but click on any place = NOK keybord forced quit don't respond only solution was to

  • Fault View CiscoWorks LMS 4.0.1

    Hello I upgraded the LMS 4.0 with LMS 4.0.1 but now the events are removed of Fault View. The equipaments than I am monitoring are: ME-3600, ME-3800 and ASR 9000. This is a configuration problem or I have to update something else?. Thanks.

  • Weblinks work within preview but not once exported to swf

    As the title states really. I've set up button with weblinks and they work fine fromt he preview page, bt once exported to swf they no longer work. Is there a limit to how long they can be? Do I need something like tinyurl?

  • Is it good idea to use style sheet for the bgcolor of a table that is just

    is it good idea to use style sheet for the bgcolor of a table that is just being used for formatting