Why windowClosing is called two times?

Hi,
I'm saving my project in JFrame windowClosing event. But it is called two times...
How to prevent it?
this.addWindowListener(new java.awt.event.WindowAdapter() {
     public void windowClosing(java.awt.event.WindowEvent e) {
     saveCurrentProject();
Thanks,
Andr�

Thanks, problem solved.
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
saveCurrentProject();
System.exit(0); // <-- new line
Andre

Similar Messages

  • Why servlet be called many times?

              I call servlet in jsp by the following way,
              /ReportServlet?reportCode='1234'.
              Servlet execute normally at first,but I find it had been called again before first
              servlet finished.
              I want to know why it be called two times.
              

              Yes,I used two frames in a signle page like this,
              <%@page contentType="text/html;charset=gb2312 "%>
              <%@page errorPage="/fxclear/common/fx_error.jsp"%>
              <%@page session="true" import="cfets_fx2001.clearing.common.record.FxsReport"%>
              <html>
              <head>
              <%
              String reportCode = null;     //&#35201;&#29983;&#25104;&#25253;&#34920;&#30340;report
              code
              try{
                   reportCode = request.getParameter("reportcode").trim();
              }catch(NullPointerException e){
                   throw new Exception("&#21457;&#32473;jsp&#26597;&#35810;&#21442;&#25968;&#38169;&#35823;");
              FxsReport report;          //&#35201;&#29983;&#25104;&#25253;&#34920;&#30340;&#25253;&#34920;&#20449;&#24687;
              String title;               //&#25253;&#34920;&#26631;&#39064;
              String dateFlag = cfets_fx2001.clearing.common.OurReport.getT0ORT1(reportCode);
              try{
                   report = new FxsReport(reportCode);
                   title = report.reportName.trim();
              }catch(Exception e){
                   title = "&#25253;&#34920;&#25171;&#21360;";
              %>
              <title>&#22806;&#27719;&#36164;&#37329;&#28165;&#31639;&#31995;&#32479;&#65293;&#65293;&#24080;&#21153;&#23376;&#31995;&#32479;&#65293;&#65293;<%=title%></title>
              <script LANGUAGE="JavaScript">
              //&#21457;&#29983;&#38169;&#35823;&#26102;&#25191;&#34892;
              function sendErrMessage(msg)
                   middle.location.href="/fxclear/common/fx_clear_error.jsp?Message="+msg;
              //&#22312;&#35201;&#29983;&#25104;pdf&#25991;&#20214;&#21069;&#25191;&#34892;
              //&#37325;&#26032;&#22312;middle frame&#35843;&#29992;servlet,&#20197;&#33719;&#21462;&#21018;&#29983;&#25104;&#30340;pdf&#25991;&#20214;
              function beginGenFile()
                   middle.document.write("&#27491;&#22312;&#29983;&#25104;&#24744;&#35201;&#30340;&#25991;&#20214;&#65292;&#36825;&#38656;&#35201;&#19968;&#20123;&#26102;&#38388;&#65292;&#35831;&#31245;&#20399;...");
                   top.document.close();
              //&#24403;pdf&#25991;&#20214;&#29983;&#25104;&#25104;&#21151;&#21518;&#25191;&#34892;
              //&#37325;&#26032;&#22312;middle frame&#35843;&#29992;servlet,&#20197;&#33719;&#21462;&#21018;&#29983;&#25104;&#30340;pdf&#25991;&#20214;
              function endGenFile()
                   middle.location.href="/ReportServlet?reportCode=<%=reportCode%>&dateFlag=<%=dateFlag%>&notrefresh=Y";
              </script>
              </head>
              <!-- <script LANGUAGE="JavaScript">
              self.moveTo(50,50);
              </script>
              -->
              <frameset framespacing="0" border="0" rows="50,101%" frameborder="0">
              <frame name="top" scrolling="no" noresize src="commonprinttitle.jsp?reportcode=<%=reportCode%>&dateFlag=<%=dateFlag%>"
              >
              <frame name="middle" src="/ReportServlet?reportCode=<%=reportCode%>&dateFlag=<%=dateFlag%>"
              scrolling="auto" >
              <noframes>
              <body background="image/fx_cfets.gif" bgproperties="fixed">
              <p>&#27492;&#32593;&#39029;&#20351;&#29992;&#20102;&#26694;&#26550;&#65292;&#20294;&#24744;&#30340;&#27983;&#35272;&#22120;&#19981;&#25903;&#25345;&#26694;&#26550;&#12290;</p>
              </body>
              </noframes>
              </frameset>
              </html>
              And I want to use frames,how to sovle it?
              

  • Why is the call history time on the printout different than the phone?

    Why is the call history time on the printout different than the phone?

    How much different is it? A minute or two??
    Calls are triggered the minute you hit send, not answered. And the same when ending a call. So if off a minute or two for a call that is why.

  • ListSelectionListener is always called two times...

    Hello,
    Icreated a JTable and added a ListSelectionListener to this table. I want an action being performed each time the selection within the table changes. If I change the selection via mouse this works quite fine, but if I do so with the mouse the method in the Listener is alwas called two times...why ?
    Here's a little bit of source-code, perhaps you'll get what I mean:
    ListSelectionModel lsm = (ListSelectionModel)e.getSource();
         if (lsm.isSelectionEmpty()) {}
         else { // always called 2 times...
              int selectedRow = lsm.getMinSelectionIndex();
         System.out.println("Test");
         Kunde temp = (Kunde)ShowKunde.kunden.elementAt(selectedRow);
         System.out.println(temp.getName());
              try {
                   kontoTemp = new KontoTemp(temp);
                   kontoTemp.setBuchungenTemp();
                   tableTemp.setModel(kontoTemp);
                   kontoBestand = new KontoBestand(temp);
                   kontoBestand.setBuchungenBestand();
                   tableBestand.setModel(kontoBestand);
                   frame.repaint();
              } // try
              catch (Exception ex) {
                   System.err.println(ex.getMessage());
              } // catch
              }});

    Hi
    you could check is the value is adjusting:
    if (e.getValueIsAdjusting()) {
        return;
    // your code hereviel erfolg
    Phil

  • MouseClicked method was called two times

    Hi all!
    I 've written a program containing a GUI component, and I added a MouseAdapter for it and overided the mouseClicked() method.
    But as I run the program and click the mouse on that component, the mouseClicked() was called two time ( I just made an single click)
    Anyone can tell me why?
    Thanks!

    Is it true that if we add the same MouseListener
    twice, we will receive two times call to mouseXXXX()
    method?I assume there would be some kind of check like this:
    if (!listenerList.contains(candidateListener)) listenerList.add(candidateListener);to ensure that it isn't added twice, because there should never really be a situation where it would be legitimate or useful to have the same instance added as a listener more than once.

  • Why JRC executes query two times? (reports.queryengine(?:?) - Executing query: ...)

    Hello! Using JRC. While creating the report for viewing, I noticed one interesting thing. Why JRC executes query two times AND first time is executed with default parameters AND if default parameters are NULL the query can be invalid (even if it is marked to convert all database NULLs to defaults in Report Options).
    <!break>
    1. Why do you need to execute query the first time with these default parameters, which are later set to the others? We need to make some valid default parameters to make everything work. Also it is not efficient to execute unnecessary query.
    2. If I'm wrong could you explain please? If I'm right, is it a bug and when do you fix it?
    Waiting for answer,
    Anton Stalnuhhin
    Java-developer, Webmedia AS

    .

  • Why my JInternalFrame show two times?

    /* I want to Draw a cycle on JPanel in JInternalFrame, but it Draw two times, and when I klick the JInternalFrame, it will show right.
    There are two Class, one ist TestDrawingJPanel, another ist DrawingJPanel.
    import java.awt.*;
    public class TestDrawingJPanel extends javax.swing.JFrame {
    /** Creates new form TestDrawingJPanel */
    public TestDrawingJPanel() {
    initComponents();
    DrawingJPanel drawingJPanel=new DrawingJPanel();
    jInternalFrame1.getContentPane().add(drawingJPanel,java.awt.BorderLayout.CENTER);
    drawingJPanel.start();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    private void initComponents() {
    jInternalFrame1 = new javax.swing.JInternalFrame();
    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent evt) {
    exitForm(evt);
    jInternalFrame1.setBackground(java.awt.Color.white);
    jInternalFrame1.setPreferredSize(new java.awt.Dimension(300, 260));
    try {
    jInternalFrame1.setSelected(true);
    } catch (java.beans.PropertyVetoException e1) {
    e1.printStackTrace();
    jInternalFrame1.setVisible(true);
    getContentPane().add(jInternalFrame1, java.awt.BorderLayout.CENTER);
    pack();
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {
    System.exit(0);
    * @param args the command line arguments
    public static void main(String args[]) {
    new TestDrawingJPanel().show();
    // Variables declaration - do not modify
    private javax.swing.JInternalFrame jInternalFrame1;
    // End of variables declaration
    import java.awt.*;
    public class DrawingJPanel extends javax.swing.JPanel implements Runnable {
    /** Creates a new instance of DrawingJPanel */
    Graphics g;
    Thread thisThread;
    public void start(){
    thisThread=new Thread(this);
    thisThread.start();
    public void paint(Graphics g){
    g.setColor(Color.black);
    g.drawArc((this.getWidth()/2)-100,(this.getHeight()/2)-100,200,200,0,360);
    public void run() {
    try{
    thisThread.sleep(100);
    }catch(Exception e){};
    repaint();

    Q1
    2 internalframes
    ANS
    remove any one of these
    jInternalFrame1.setVisible(true);
    new TestDrawingJPanel().show();

  • Why weneed to call two BAPIs to create a notification in SAP

    HI Experts,
               There are two BAPIS namely BAPI_ALM_NOTIF_CREATE and BAPI_ALM_NOTIF_SAVE for creating a notification.
    We have to call the first one with proper data and it returns a dummy number which we need to send to the second bapi to save it.
    Why SAP has provided two BAPIS? is there any strong reason for this.
    Good answers will be rewarded.
    Thanks,
    Prasanna

    Hello Roli,
    If your requirement is to launch Transaction IW52 after clicking apply button then you can use Transaction Launcher tool in CRM to integrate to CRM WebClient UI.
    Calling Transaction Launcher on user action
    BOR object or ITS based Transaction Launcher
    Regards,
    Ashik

  • Why do I have two time zones in my calendar?

    With a recent move to a new time zone I now have two time zone in my calendar.  My area code is in a central time zone but have moved to the east coast.
    I have checked my icloud calendar, iPhone settings and each is set to eastern time.

    Hi beachbouy,
    If you need to change the time zone for your calendars in iCloud, use the steps in this article -
    iCloud: Change your calendar’s time zone
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • Why the data inserted two times into the DB?

    Hai all,
    When I press the submit button in my form the data will be inserted two timesinto DB. Please help me.
    import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import com.vguss.bean.RegisterInfoBean; import com.vguss.helper.Out; public class InsertRegInfo { public static Connection connection = DBConnection.getDBConnection(); public static void insertRegData(RegisterInfoBean bean) { Connection connection = DBConnection.getDBConnection(); String loginID = bean.getLoginId(); try { PreparedStatement pst = connection .prepareStatement("SELECT login_id FROM login_details WHERE login_id = ?"); pst.setString(1, loginID); ResultSet set = pst.executeQuery(); if (!set.next()) { insertData(bean); } } catch (SQLException e1) { e1.printStackTrace(); } } private static void insertData(RegisterInfoBean bean) { try { PreparedStatement ps = connection .prepareStatement("INSERT INTO login_details (login_id, password, profile_created_by, security_question, answer, full_name, receive_sms, show_details, agree_terms, register_on) VALUES (?,?,?,?,?,?,?,?,?,now())"); ps.setString(1, bean.getLoginId()); ps.setString(2, bean.getPassword()); ps.setString(3, bean.getProf_created_by()); ps.setString(4, bean.getSecurity_Question()); ps.setString(5, bean.getAnswer()); ps.setString(6, bean.getFullName()); ps.setString(7, bean.getLikeSMS()); ps.setString(8, bean.getShowDetails()); ps.setString(9, bean.getAgreeToTerms()); ps.executeUpdate(); PreparedStatement pstmt = connection .prepareStatement("INSERT INTO user_profile (login_id, gender, email, date_of_birth) VALUES (?, ?, ?, ?)"); pstmt.setString(1, bean.getLoginId()); pstmt.setString(2, bean.getGender()); pstmt.setString(3, bean.getEmailID()); pstmt.setString(4, bean.getDateOfBirth()); pstmt.executeUpdate(); /* insert login id to preferred_partner table */ PreparedStatement pStmt = connection .prepareStatement("INSERT INTO preferred_partner (login_id) VALUES(?)"); pStmt.setString(1, bean.getLoginId()); pStmt.executeUpdate(); } catch (SQLException e) { Out.err(e); } } }

    The most obvious thought is that you have a duplicate login id.
    You're trying, but I would not consider this to be well written code, for these reasons:
    1. You don't close any JDBC resources in finally blocks - no connections, no statements, no result sets. Search the forum for people with "max open cursors exceeded" to see why this is a bad idea.
    2. You create a static Connection in this class, but nobody closes it. Classes that execute SQL should not be responsible for obtaining connections; a Connection should be provided to them. Transactions are the reason: a class executing SQL can't know if it's involved in a unit of work with other classes. Somebody who knows the use case and the transaction boundaries ought to be getting the Connection, handling commit/rollback, and closing the Connection.
    3. Refactor that INSERT into three methods. You'll be glad you did someday.
    4. Your INSERT method looks like it's doing a security check, too. Isn't it a little late for that? If you must, move that code into a separate method that returns a boolean. A well-designed method does one thing well. Yours is doing two.
    5. The common JDBC idiom isn't "if (!set.next())", it's "while (set.next())". It's good to use common idioms, because it makes it easier for other people to understand your code.
    But see if you have a repeated login ID.
    And step through in a debugger to see what's going on.
    %

  • Why "TWO_TASK" is called two tasks?

    which two tasks do it refer to?

    A definition from Oracle documentation :
    Two-Task Common (TTC)
    A presentation layer type that is used in a typical Oracle Net connection to provide character set and data type conversion between different character sets or formats on the client and server.
    See http://download-uk.oracle.com/docs/cd/B19306_01/network.102/b14212/connect.htm#sthref1476

  • Does anybody know why I can see two times on my lock screen? The right time then a wrong one in the background behind it?

    Can anyone help please?

    The only thing behind my lock screen clock is my lock screen wall-paper. Do you have a different wall-paper set for your lock screen than what you have set for your home screen?

  • JTextField.focusLost is called multiple times. Why?

    I have a JTextField component called projectNum.
    On focusLost I'm trying to prevent user to leave an empty field.
    But I have a problem, because focusLost is called two times.
    Here is a code snippet:
    projectNum.addFocusListener(new FocusAdapter() {
                   public void focusGained(FocusEvent e) {}
                   public void focusLost(java.awt.event.FocusEvent e) {
                        if(!e.isTemporary()){ //only for permanent lost of focus          
                             if (validProjectNum()){
    newProject.setProjectNum(Integer.valueOf(projectNum.getText().trim()).intValue());
                           }else{
                                if(!projectNum.hasFocus()){
                                     projectNum.requestFocus();
              });Method "validProjectNum()" simply checks if JTextField is empty and
    if so, shows JOptionPane message and returns false.
    Problem is that I'm geting that message twice
    (four times if I exclude: if(!e.isTemporary()) ).
    I can't figure out who is calling focusLost the second time.
    How can I prevent it to be called only once.
    I appreciate any help or hint.
    Thanks.

    OK, but where to show a message to a user?if the textfield is empty, this line executes
    if(tf.getText().equals("")) return false;
    perhaps you could add your message as part of the
    'block' of this if statementWell, I've tried that allready (see my second post, method validProjectNum()
    does exactly that).
    Anyway, I solved the problem using focusLost and a little trick:jTextField.requestFocus();                
           jTextField.setFocusable(false);          
           JOptionPane.showMessageDialog(null, "error message");
           jTextField.setFocusable(true);  
           jTextField.requestFocus();        So as you can see, key thing is to temporary disable focus on component
    and than enable it back after JOptionPane.showMessageDialog().
    It looks like JOptionPane.showMessageDialog()
    triggers focusLost() event.
    Thanks everyone.

  • When i type the https URL in my FireFox browser version 3.6 to 5.0, i get login pop up window two times. But in IE browser i get only once. Please tell me why FireFox is showing pop up screen two times to enter my uid/pwd. Thanks!

    We have our company internal application which is protected by SiteMinder. When we type https://appname.domain.com in IE i get popup window asking me to enter uid/pwd and works fine. However same URL when i login in FireFox, i get pop up window two times. So i wonder why FF is asking two times instead of just only once.
    Thanks for your help.

    Do you have that problem when running in the Firefox SafeMode?
    [http://support.mozilla.com/en-US/kb/Safe+Mode]
    ''Don't select anything right now, just use "Continue in SafeMode."''
    If not, see this:
    [http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes]

  • Data inserting two times in a table  when i click submit button

    Hi Experts,
    I had a problem, when i am inserting data in a table from a form at the first time when i click button it adds two times, afterwards it is adding one time only, the form and table are from same value node (table is collection cardinality : 1..n and selection cardinality is 0..n) i don't understand why it  is happening here?
    Regards,
    Pradeep Kumar

    Hi Pradeep,
    Please check the method for inserting data in a table. May be method is called two times.
    Post your code here to look into it.
    Best Regards,
    Arun Jaiswal

Maybe you are looking for

  • Converting invoices to excel

    My goal here is to get my paperwork organized digitally. Invoices from multiple vendors and converting them into spreadsheets to have all my information for one sale easily assessable down the road if I need to look back. First I purchased one of tho

  • Router for my macbook

    Hi, I have bought 2 days ago for the first time MacBook Pro 15,4" 2,4GHz and i have some question for you: 1) I must buy a router because at home i have another computer and i want the best performance on internet with my macbook, can you tell me som

  • Order as Direct material Tab activation

    Hi Guys, I select some materials from catalog and transfer them to SRM system and some materials I find a tab with ORDER AS DIRECT material. where as for some material I do not find, when I click on the Order as direct material this goes into a stock

  • Get URL for WDJ application

    Hi guys! Deployed an application (ear file) on server. URL is: http://<server ip>:50000/webdynpro/dispatcher/sap.com/jaswd/JCaptcha?SAPtestId=2&answer=init&guid=4C19CB2279C6019DE10080000A0FF2AC Is there any class (like CL_WD_UTILITIES=>CONSTRUCT_WD_U

  • Too many nodes in each states

    I'm trying to use JavaFX Composer in Netbeans 6.9 to make a blogging client that is both an editing software and a feed reader. The problem is that I want to be able to switch between different phases/screens, such as one for reading feeds and one fo