Swing application screen becoming gray

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • madhoriya22
    Contributor
    • Jul 2007
    • 251

    Swing application screen becoming gray

    Hi,
    I am having this problem in my swing application. On the screen there is a button catalog, sometimes(not every time) when i press that button the next screen comes is gray and it don't display any data. What can be the possible reason for it ?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by madhoriya22
    Hi,
    I am having this problem in my swing application. On the screen there is a button catalog, sometimes(not every time) when i press that button the next screen comes is gray and it don't display any data. What can be the possible reason for it ?
    Almost anything can be the reason but my guess is a thread problem: most
    likely you're doing all you processing in the AWT dispatch thread so that it
    doesn't have time anymore to do what it was made for: draw your components.
    For starters have a look at the SwingUtilities class that can start small
    threads for you that are not in the way of the dispatch thread.

    kind regards,

    Jos

    Comment

    • madhoriya22
      Contributor
      • Jul 2007
      • 251

      #3
      Originally posted by JosAH
      Almost anything can be the reason but my guess is a thread problem: most
      likely you're doing all you processing in the AWT dispatch thread so that it
      doesn't have time anymore to do what it was made for: draw your components.
      For starters have a look at the SwingUtilities class that can start small
      threads for you that are not in the way of the dispatch thread.

      kind regards,

      Jos
      Hi,
      Thanks ! But this problem is not occuring everytime. It occurs seldom only. My application is vast retail application. Can this be a memory issue or something else apart from coding problem ?

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by madhoriya22
        Hi,
        Thanks ! But this problem is not occuring everytime. It occurs seldom only. My application is vast retail application. Can this be a memory issue or something else apart from coding problem ?
        Are you using Jos' suggestion above already then?
        Threading related problems are like that sometimes. i.e Show up sometimes, because threading is partly platform dependent.

        Comment

        • madhoriya22
          Contributor
          • Jul 2007
          • 251

          #5
          Originally posted by r035198x
          Are you using Jos' suggestion above already then?
          Threading related problems are like that sometimes. i.e Show up sometimes, because threading is partly platform dependent.
          Hi,
          Here is the code snippet of my class.
          This is how I am enabling the button at one place
          Code:
          if (reviewMessagesController.getModel() != null) {
          				SwingUtilities.invokeLater(new Runnable() {
          					public void run() {
          						if (customerVO == null) {
          							InvoiceController.this.fldCustomer.requestFocus();
          						} else if (customerVO != null && customerVO.isAuthorizedBuyersOnly()
          								&& invoicePanel.cbAuthorizedBuyer.getSelectedIndex() < 1) {
          							invoicePanel.cbAuthorizedBuyer.requestFocus();
          						} else {
          							invoicePanel.btnPartsPro.setEnabled(true);//This is the button giving problem
          							invoicePanel.btnRecallSavedInvoice.setEnabled(false);
          							invoicePanel.btnMessage.setEnabled(false);
          							invoiceLineEntryController.setPartNumberEnabled(true);
          							invoicePanel.btnRecallSavedInvoice.dispatchEvent(
          								new KeyEvent(invoicePanel.btnRecallSavedInvoice, KeyEvent.KEY_PRESSED,
          								new Date().getTime(), 0, KeyEvent.VK_TAB, '\t'));
          						}
          					}
          				});
          This is how I am enabling the button at another place
          Code:
          SwingUtilities.invokeLater(new Runnable() {
          			public void run() {
          				if (customerVO == null) {
          					InvoiceController.this.fldCustomer.requestFocus();
          				} else if (customerVO != null && customerVO.isAuthorizedBuyersOnly()
          						&& invoicePanel.cbAuthorizedBuyer.getSelectedIndex() < 1) {
          					invoicePanel.cbAuthorizedBuyer.requestFocus();
          				} else {
          					invoicePanel.btnPartsPro.setEnabled(true);//This is the button givining problem
          					invoicePanel.btnMessage.setEnabled(false);
          					invoicePanel.btnRecallSavedInvoice.setEnabled(false);
          					invoiceLineEntryController.setPartNumberEnabled(true);
          					invoicePanel.btnRecallSavedInvoice.dispatchEvent(
          						new KeyEvent(invoicePanel.btnRecallSavedInvoice, KeyEvent.KEY_PRESSED,
          						new Date().getTime(), 0, KeyEvent.VK_TAB, '\t'));
          				}
          			}
          		});
          and this is how I am performing action on the button
          Code:
          else if (source.getName().equals(InvoicePanel.BTN_PARTS_PRO)) {
          		 if (isPreferencePPSE() && ClientApplicationContext.getClientApplicationContext().getPpseCatalogInUse()) {
          		 logger.debug("actionPerformed: CatalogButton Pushed: isPreferencePPSE/calling openPPSE");
          		 openPPSE();
          		 } else {logger.debug("actionPerformed: CatalogButton: preference is NOT PPSE");
          			 if (!CatalogBL.verifyDVDServices()) {
          				 clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "2208");
          				 return;
          			 }
          			 invoicePanel.setVisible(false);
          			 clientApplicationContext.getPointOfSaleEventDispatcher().fireCatalogingOpened(
          				 new CatalogEvent(this, null));
          		 }
          Can this code give this kind of problem ? Please give ur valuable suggestions .

          Thanks and regards,
          Amit.

          Comment

          Working...