Solved

Plug-in Problem.

Posted on 2002-06-09
10
183 Views
Last Modified: 2010-03-31
I have a web-based java application(Applet based). Its quite big appliation containing lot of classes, the jar file is about 500K.  When i am running it without plug-in, its really running OK, though i am missing certain things on some of components made of Swing Classes.  But when i am using it through java plug-in(i tired all versions)i am getting missed things on those swing properties.  But system is getting hanged whenever it tried to refresh my application's screen which is made of Canvas.   Its happening everytime whenever i use repaint(),drawcell() kinda methods.  Its real-time quotes screen i need to update everytime.   The application is working fine on my Linux PC.  The problem is only on Windows?  

Why is like that? What could be the problem? Is it plug-in problem? or my Application? If its my application why its working fine without plug-in? and on Linux with plug-in? I need to report the problem and finalise the things. Can anyone help me in knowing whas going exactly?

0
Comment
Question by:vinaykn
  • 6
  • 4
10 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 7066278
IMHO your application uses some bad technique for updating screen information.

your applet can be easily fixed, but I cannot help you if you post some snippet of your code - even better - small compilable example that reproduces the problem.
0
 

Author Comment

by:vinaykn
ID: 7066312
Thanks heyhey.  Its a verybig source consists some 100 java files. I am also not permitted to send them all. If you feel OK, then i can send my refereshScreen method(), where always system getting hanged.  You may suggest some, if you find any bad technique.   Can you enlighten me what could be the problem on windows only???
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 7066329
> Can you enlighten me what could be the problem on windows only???

different Java VMs have their own bugs / features / implementation features.

post your code, I may find some problem.
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 16

Expert Comment

by:heyhey_
ID: 7066331
can you give me link to the working app ?
0
 

Author Comment

by:vinaykn
ID: 7066354
This still in my local network, i think i cant give line. I am trying to send some code. Dont know whether its helpful in finding any problem. Its calling other classes, methods.

synchronized public void refreshScreen(){

{
        String s = " ";
        try{
            if (!shouldRefresh && col != BLANK ){
                if (row == 0 || row%2 == 0)
                    g.setColor(AppColor.displayBackground);
                else
                    g.setColor(AppColor.displayAlternateBackground);
               
                g.fillRect(colPosition[col]+1,
                           rowPosition[row]+1,
                           colPosition[col+1] - colPosition[col]-2,
                           rowPosition[1]-1);
            }

            if(stockInfo == null){
                return;
            }

            switch(col){
                case Quote.NEWS:
                    g.setColor(AppColor.getStockForeColor(stockInfo,col)); //AppData.getStockForeColor(stockInfo,col)); 29/12/1999
                    if(stockInfo.sNewsInd.compareTo("1") == 0){
                        s = "*";
                    }
                    break;
                case Quote.NAME:
                    if(showName){
                        g.setColor(AppColor.getStockBackColor(stockInfo, row)); //AppData.getStockBackColor(stockInfo, row)); 29/12/1999

                        g.fillRect(colPosition[col]+1,
                                   rowPosition[row]+1,
                                   colPosition[col+1]- colPosition[col]-2,
                                   rowPosition[1]-1);
                        g.setColor(AppColor.getStockForeColor(stockInfo,col)); //AppData.getStockForeColor(stockInfo,col)); 29/12/1999
                        s = stockInfo.sName;
                    }
                    else {
                        g.setColor(AppColor.getStockBackColor(stockInfo, row)); //AppData.getStockBackColor(stockInfo, row)); // 29/12/1999

                        g.fillRect(colPosition[col]+1,
                                   rowPosition[row]+1,
                                   colPosition[col+1]- colPosition[col]-2,
                                   rowPosition[1]-1);//Clearing off the display.
                        g.setColor(AppColor.getStockForeColor(stockInfo,Quote.CODE)); //AppData.getStockForeColor(stockInfo,Quote.CODE));//Setting the foreground color 29/12/1999
                        if(stockInfo.sType.length() > 0 &&
                           stockInfo.sType.charAt(0) != 'O' &&
                           stockInfo.sType.charAt(0) != 'F' &&
                           stockInfo.sType.charAt(0) != 'U'){
                            s = AppData.fillUpSpace(stockInfo.sCode,7)+stockInfo.sName;
                            if(s.length() > NAME_LEN){
                                s = s.substring(0,NAME_LEN);
                            }
                        }
                        else {
                            s = stockInfo.sCode;
                        }
                    }
                    break;

                case Quote.VOL:
              case Quote.PREV:
                    if(showPrev == 1){
                    g.setColor(AppColor.getStockForeColor(stockInfo,col));
                        s = AppData.justRight(stockInfo.sPrev,Quote.COL_SIZE[col+1]);
                    }
                    else if (showPrev == 0){
                        g.setColor(AppColor.getStockForeColor(stockInfo,col));
                        if (shouldRefresh == false && hLight == true) {
                            g.setColor(AppColor.displayUpdate);

                            g.fillRect(colPosition[col]+1,
                                       rowPosition[row]+1,
                                       colPosition[col+1] - colPosition[col]-2,
                                       rowPosition[1]-1);
                            hilite[3][row] = counter + 2;

                            g.setColor(AppColor.displayBackground);
                        }
                        else {
                            if (row == 0 || row%2 == 0)
                                g.setColor(AppColor.displayBackground);
                            else
                                g.setColor(AppColor.displayAlternateBackground);

                            g.fillRect(colPosition[col]+1,
                                       rowPosition[row]+1,
                                       colPosition[col+1] - colPosition[col]-2,
                                       rowPosition[1]-1);
                            hilite[3][row] = 0;
                            g.setColor(AppColor.displayForeground);
                        }
                        s = AppData.justRight(stockInfo.sVol, Quote.COL_SIZE[col+1]); // 17/8/1999 , show volume
                    }
                else {
                    g.setColor(AppColor.getStockForeColor(stockInfo,col)); //AppData.getStockForeColor(stockInfo,col)); 29/12/1999
                        s = AppData.justRight(AppData.getInter(StockInfo.CURRENCY_NAME_PREFIX+stockInfo.sCurrency),Quote.COL_SIZE[col+1]); // 28/10/1999
                }
                    break;
                case Quote.HIGH:
                    g.setColor(AppColor.getStockForeColor(stockInfo,col)); //AppData.getStockForeColor(stockInfo,col)); 29/12/1999
                    s = AppData.justRight(stockInfo.sHigh,Quote.COL_SIZE[col+1]);
                    break;
                case Quote.LOW:
                    g.setColor(AppColor.getStockForeColor(stockInfo,col)); //AppData.getStockForeColor(stockInfo,col)); 29/12/1999
                    s = AppData.justRight(stockInfo.sLow,Quote.COL_SIZE[col+1]);
                    break;
                case Quote.LAST:
                    g.setColor(AppColor.getStockForeColor(stockInfo,col)); //AppData.getStockForeColor(stockInfo,col)); 29/12/1999
                    s = AppData.justRight(stockInfo.sLast,Quote.COL_SIZE[col+1]);
                    break;
                case Quote.CHANGE:
                    if(showChange){
                        g.setColor(AppColor.getStockForeColor(stockInfo,col)); //AppData.getStockForeColor(stockInfo,col)); 29/12/1999
                        s = AppData.justRight(stockInfo.sChg,Quote.COL_SIZE[col+1]);
                    }
                    else {
                        g.setColor(AppColor.getFontColor(Float.valueOf(stockInfo.sChgPCent).floatValue(), Float.toString(0))); //AppData.getFontColor(Float.valueOf(stockInfo.sChgPCent).floatValue(), Float.toString(0))); 29/12/1999
                        s = AppData.justRight(stockInfo.sChgPCent+"%",Quote.COL_SIZE[col+1]);
                    }
                    break;
                case Quote.BUY:
                    g.setColor(AppColor.getStockForeColor(stockInfo,col));
                    if(stockInfo.sType.length() > 0 && stockInfo.sType.charAt(0) != 'I'){
                        s = AppData.justRight(stockInfo.sBuy,Quote.COL_SIZE[col+1]);
                    }
                    break;
                case Quote.SELL:
                    g.setColor(AppColor.getStockForeColor(stockInfo,col));
                    if(stockInfo.sType.length() > 0 && stockInfo.sType.charAt(0) != 'I'){
                       s = AppData.justRight(stockInfo.sSell,Quote.COL_SIZE[col+1]);
                    }
                    break;
                case Quote.BUYQTY:
                    g.setColor(AppColor.getStockForeColor(stockInfo,col));
                    if (shouldRefresh == false && hLight == true) {
                        g.setColor(AppColor.displayUpdate);

                        g.fillRect(colPosition[col]+1,
                                   rowPosition[row]+1,
                                   colPosition[col+1] - colPosition[col]-2,
                                   rowPosition[1]-1);
                        hilite[0][row] = counter + 2;
                        g.setColor(AppColor.displayBackground);
                      }
                    else {
                        if (row == 0 || row%2 == 0)
                            g.setColor(AppColor.displayBackground);
                        else
                            g.setColor(AppColor.displayAlternateBackground);
   
                        g.fillRect(colPosition[col]+1,
                                   rowPosition[row]+1,
                                   colPosition[col+1] - colPosition[col]-2,
                                   rowPosition[1]-1);
                        hilite[0][row] = 0;
                        g.setColor(AppColor.displayForeground);
                    }
                    if(stockInfo.sType.length() > 0 && stockInfo.sType.charAt(0) != 'I'){
                        s = AppData.justRight(stockInfo.sBuyQty,Quote.COL_SIZE[col+1]);
                    }
                    break;
                case Quote.SELLQTY:
                    g.setColor(AppColor.getStockForeColor(stockInfo,col));
                    if (shouldRefresh == false && hLight == true) {
                        g.setColor(AppColor.displayUpdate);

                        g.fillRect(colPosition[col]+1,
                                   rowPosition[row]+1,
                                   colPosition[col+1]-colPosition[col]-2,
                                   rowPosition[1]-1);
                        hilite[1][row] = counter + 2;
                        g.setColor(AppColor.displayBackground);
                    }
                    else {
                        if (row == 0 || row%2 == 0)
                            g.setColor(AppColor.displayBackground);
                        else
                            g.setColor(AppColor.displayAlternateBackground);
                       
                        g.fillRect(colPosition[col]+1,
                                   rowPosition[row]+1,
                                   colPosition[col+1]-colPosition[col]-2,
                                   rowPosition[1]-1);
                        hilite[1][row] = 0;
                        g.setColor(AppColor.displayForeground);
                    }
                    if(stockInfo.sType.length() > 0 && stockInfo.sType.charAt(0) != 'I'){
                        s = AppData.justRight(stockInfo.sSellQty,Quote.COL_SIZE[col+1]);
                    }
                    break;
                case Quote.VALUE:
                case Quote.LOTSIZE:
                    g.setColor(AppColor.getStockForeColor(stockInfo,col));
                    if(showVal){
                        if (shouldRefresh ==  false && hLight == true) {
                            g.setColor(AppColor.displayUpdate);

                            g.fillRect(colPosition[col]+1,
                                       rowPosition[row]+1,
                                       colPosition[col+1]-colPosition[col]-2,
                                       rowPosition[1]-1);
                            hilite[2][row] = counter + 2;
                            g.setColor(AppColor.displayBackground);
                        }
                        else {
                                                if (row == 0 || row%2 == 0)
                                g.setColor(AppColor.displayBackground);
                            else
                                g.setColor(AppColor.displayAlternateBackground);
                           

                            g.fillRect(colPosition[col]+1,
                                       rowPosition[row]+1,
                                       colPosition[col+1]-colPosition[col]-2,
                                       rowPosition[1]-1);
                            hilite[2][row] = 0;
                            if(showVal){ //show Value
                                g.setColor(AppColor.displayValue);
                            }
                            else {
                                g.setColor(AppColor.displayForeground);
                            }
                        }
                        s = AppData.justRight(stockInfo.sValue, Quote.COL_SIZE[col+1]);
                    }
                    else {
                        s = AppData.justRight(stockInfo.sLot,Quote.COL_SIZE[col+1]); // show lotSize
                    }
                    break;
                default:
                    return;
            }
            g.drawString(s,colPosition[col]+2,rowPosition[row+1]-5);//18/4/200 -3);
        }
        catch(Exception e){
            System.out.println("Quote.drawCell:"+e.toString()+" col = "+col+" row = "+row);
        }
    }
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 7066362
1. what is g ? Do you create this graphics object ?
2. why refreshScreen() is synchronized ?
3. who calls refreshScreen() ?
0
 

Author Comment

by:vinaykn
ID: 7066404
I found these following two methods are calling refreshScreen(); But i didnt find anywhere "g" is globally declared(i am not getting any compiling error).  The applet is connected to back-end server which always pushes real-time data.  Depends on the data it received, it will process the data and repaint() will be called.  "Synchronized" is user for the reason--there is possibility of immediate updatation, before some data is being processed.


public void update(Graphics g) {
        refreshScreen();
    }

    public void paint(Graphics g) {
        refreshScreen();
    }
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 7066411
1. synchronizing paint() method is terrible idea. if some other worker Thread blocks inside some synchronized block, your whole UI will stop responding.

2. globally defined Graphics object is very bed idea too.
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 300 total points
ID: 7066413
a very quick example on how to implement similar system

group all data needed for rendering into one object
class RendererData
{
   ....
}

in you main rendering class you following code

// contains all information needed for rendering packed in a single object
private RendererData currentData;

// called by the communication Thread when new data is available
public void setData(RendererData newData)
{
  currentData = newData;
  repaint();
}


public void update(Graphics g)
{
  paint(g);
}

public void paint(Graphics g)
{
  paintComponent(g, currentData);
}


private void paintComponent(Graphics g, RendererData theData)
{
   // renders data from 'theData' object on current Graphics object

   // ...  
   
   // you can pu all the code from refreshScreen method here
   // but try using only local varibales, i.e. only data form theData object
}
0
 

Author Comment

by:vinaykn
ID: 7066433
Thanks for the help heyhey. I will implement your suggestions. I will try to improve the code.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question