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; //要生成报表的report
code
try{
reportCode = request.getParameter("reportcode").trim();
}catch(NullPointerException e){
throw new Exception("发给jsp查询参数错误");
FxsReport report; //要生成报表的报表信息
String title; //报表标题
String dateFlag = cfets_fx2001.clearing.common.OurReport.getT0ORT1(reportCode);
try{
report = new FxsReport(reportCode);
title = report.reportName.trim();
}catch(Exception e){
title = "报表打印";
%>
<title>外汇资金清算系统--帐务子系统--<%=title%></title>
<script LANGUAGE="JavaScript">
//发生错误时执行
function sendErrMessage(msg)
middle.location.href="/fxclear/common/fx_clear_error.jsp?Message="+msg;
//在要生成pdf文件前执行
//重新在middle frame调用servlet,以获取刚生成的pdf文件
function beginGenFile()
middle.document.write("正在生成您要的文件,这需要一些时间,请稍侯...");
top.document.close();
//当pdf文件生成成功后执行
//重新在middle frame调用servlet,以获取刚生成的pdf文件
function endGenFile()
middle.location.href="/ReportServlet?reportCode=<%=reportCode%>&dateFlag=<%=dateFlag%>¬refresh=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>此网页使用了框架,但您的浏览器不支持框架。</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. -
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,
PrasannaHello 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 -
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. -
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 KumarHi 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
-
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
-
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
-
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
-
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