By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,704 Members | 1,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,704 IT Pros & Developers. It's quick & easy.

Swing application screen becoming gray

madhoriya22
100+
P: 252
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 ?
Jun 24 '08 #1
Share this Question
Share on Google+
4 Replies


Expert 10K+
P: 11,448
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
Jun 24 '08 #2

madhoriya22
100+
P: 252
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 ?
Jun 24 '08 #3

10K+
P: 13,264
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.
Jun 24 '08 #4

madhoriya22
100+
P: 252
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
Expand|Select|Wrap|Line Numbers
  1. if (reviewMessagesController.getModel() != null) {
  2.                 SwingUtilities.invokeLater(new Runnable() {
  3.                     public void run() {
  4.                         if (customerVO == null) {
  5.                             InvoiceController.this.fldCustomer.requestFocus();
  6.                         } else if (customerVO != null && customerVO.isAuthorizedBuyersOnly()
  7.                                 && invoicePanel.cbAuthorizedBuyer.getSelectedIndex() < 1) {
  8.                             invoicePanel.cbAuthorizedBuyer.requestFocus();
  9.                         } else {
  10.                             invoicePanel.btnPartsPro.setEnabled(true);//This is the button giving problem
  11.                             invoicePanel.btnRecallSavedInvoice.setEnabled(false);
  12.                             invoicePanel.btnMessage.setEnabled(false);
  13.                             invoiceLineEntryController.setPartNumberEnabled(true);
  14.                             invoicePanel.btnRecallSavedInvoice.dispatchEvent(
  15.                                 new KeyEvent(invoicePanel.btnRecallSavedInvoice, KeyEvent.KEY_PRESSED,
  16.                                 new Date().getTime(), 0, KeyEvent.VK_TAB, '\t'));
  17.                         }
  18.                     }
  19.                 });
  20.  
This is how I am enabling the button at another place
Expand|Select|Wrap|Line Numbers
  1. SwingUtilities.invokeLater(new Runnable() {
  2.             public void run() {
  3.                 if (customerVO == null) {
  4.                     InvoiceController.this.fldCustomer.requestFocus();
  5.                 } else if (customerVO != null && customerVO.isAuthorizedBuyersOnly()
  6.                         && invoicePanel.cbAuthorizedBuyer.getSelectedIndex() < 1) {
  7.                     invoicePanel.cbAuthorizedBuyer.requestFocus();
  8.                 } else {
  9.                     invoicePanel.btnPartsPro.setEnabled(true);//This is the button givining problem
  10.                     invoicePanel.btnMessage.setEnabled(false);
  11.                     invoicePanel.btnRecallSavedInvoice.setEnabled(false);
  12.                     invoiceLineEntryController.setPartNumberEnabled(true);
  13.                     invoicePanel.btnRecallSavedInvoice.dispatchEvent(
  14.                         new KeyEvent(invoicePanel.btnRecallSavedInvoice, KeyEvent.KEY_PRESSED,
  15.                         new Date().getTime(), 0, KeyEvent.VK_TAB, '\t'));
  16.                 }
  17.             }
  18.         });
  19.  
and this is how I am performing action on the button
Expand|Select|Wrap|Line Numbers
  1. else if (source.getName().equals(InvoicePanel.BTN_PARTS_PRO)) {
  2.          if (isPreferencePPSE() && ClientApplicationContext.getClientApplicationContext().getPpseCatalogInUse()) {
  3.          logger.debug("actionPerformed: CatalogButton Pushed: isPreferencePPSE/calling openPPSE");
  4.          openPPSE();
  5.          } else {logger.debug("actionPerformed: CatalogButton: preference is NOT PPSE");
  6.              if (!CatalogBL.verifyDVDServices()) {
  7.                  clientApplicationContext.getMessageMgr().showMessage(invoicePanel, "2208");
  8.                  return;
  9.              }
  10.              invoicePanel.setVisible(false);
  11.              clientApplicationContext.getPointOfSaleEventDispatcher().fireCatalogingOpened(
  12.                  new CatalogEvent(this, null));
  13.          }
  14.  
Can this code give this kind of problem ? Please give ur valuable suggestions .

Thanks and regards,
Amit.
Jun 24 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.