Plug-in Problem.

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?

vinayknAsked:
Who is Participating?
 
heyhey_Connect With a Mentor Commented:
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
 
heyhey_Commented:
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
 
vinayknAuthor Commented:
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
heyhey_Commented:
> 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
 
heyhey_Commented:
can you give me link to the working app ?
0
 
vinayknAuthor Commented:
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
 
heyhey_Commented:
1. what is g ? Do you create this graphics object ?
2. why refreshScreen() is synchronized ?
3. who calls refreshScreen() ?
0
 
vinayknAuthor Commented:
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
 
heyhey_Commented:
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
 
vinayknAuthor Commented:
Thanks for the help heyhey. I will implement your suggestions. I will try to improve the code.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.