Solved

Plug-in Problem.

Posted on 2002-06-09
10
180 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_
Comment Utility
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
Comment Utility
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_
Comment Utility
> 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
 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
can you give me link to the working app ?
0
 

Author Comment

by:vinaykn
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 16

Expert Comment

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

Author Comment

by:vinaykn
Comment Utility
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_
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for the help heyhey. I will implement your suggestions. I will try to improve the code.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now