<repo_name>vigilantlaynar/Keyword-Search<file_sep>/src/com/searchkeyword/bean/CompanyProfileBean.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.searchkeyword.bean;

/**
 *
 * @author mayukh
 */
public class CompanyProfileBean {
    private String name;
    private String email;
    private String website;
    private String address;
    private String logo;

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getWebsite() {
        return website;
    }

    public void setWebsite(String website) {
        this.website = website;
    }
}
<file_sep>/src/com/searchkeyword/bean/Keywords.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.searchkeyword.bean;

/**
 *
 * @author Euphern_Java
 */
public class Keywords {

    private int keywordid;

    private String keyword=null;

    private int rank;

    private int localrank;

    private int internalRank;
    /**
     * @return the keyword
     */
    public String getKeyword() {
        return keyword;
    }

    /**
     * @param keyword the keyword to set
     */
    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    /**
     * @return the rank
     */
    public int getRank() {
        return rank;
    }

    /**
     * @param rank the rank to set
     */
    public void setRank(int rank) {
        this.rank = rank;
    }

    /**
     * @return the keywordid
     */
    public int getKeywordid() {
        return keywordid;
    }

    /**
     * @param keywordid the keywordid to set
     */
    public void setKeywordid(int keywordid) {
        this.keywordid = keywordid;
    }

    public int getLocalrank() {
        return localrank;
    }

    public void setLocalrank(int localrank) {
        this.localrank = localrank;
    }

    public int getInternalRank() {
        return internalRank;
    }

    public void setInternalRank(int internalRank) {
        this.internalRank = internalRank;
    }

    

}
<file_sep>/src/com/searchkeyword/frame/EnterKeyWord.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EnterKeyWord.java
 *
 * Created on May 9, 2011, 6:04:57 PM
 */

package com.searchkeyword.frame;

import com.searchkeyword.bean.Keywords;
import com.searchkeyword.bean.RankTrackerBean;
import com.searchkeyword.common.CommonHelper;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;

/**
 *
 * @author Euphern_Java
 */
public class EnterKeyWord extends javax.swing.JFrame {

    private RankTrackerBean rankTrackerBean;
    /** Creates new form EnterKeyWord */
    public EnterKeyWord() {
        //initComponents();
    }

    public EnterKeyWord(RankTrackerBean rankTBean)
    {
        initComponents();
        this.setTitle("Enter Keyword");
        CommonHelper.setScreenInCenter(this);
        CommonHelper.installCloseHandler(this);
        rankTrackerBean=rankTBean;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtaKeyword = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        btnFinish = new javax.swing.JButton();
        btnNext = new javax.swing.JButton();
        btnBack = new javax.swing.JButton();
        btnHelp = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        txtaKeyword.setColumns(20);
        txtaKeyword.setRows(5);
        txtaKeyword.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                handleTabKey(evt);
            }
        });
        jScrollPane2.setViewportView(txtaKeyword);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel1.setText("Enter your keywords (only one entry per line) :");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 817, Short.MAX_VALUE)
                    .addComponent(jLabel1))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                .addContainerGap())
        );

        btnFinish.setText("Finish");
        btnFinish.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                handleFinish(evt);
            }
        });

        btnNext.setText("Next >>");
        btnNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                handleNext(evt);
            }
        });

        btnBack.setText("<< Back");
        btnBack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                handleBack(evt);
            }
        });

        btnHelp.setText("Help");
        btnHelp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHelphandleHelp(evt);
            }
        });

        btnCancel.setText("Cancel");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelhandleCancel(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnHelp, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 397, Short.MAX_VALUE)
                .addComponent(btnBack, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnNext, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnFinish, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(btnFinish)
                .addComponent(btnNext)
                .addComponent(btnBack)
                .addComponent(btnHelp)
                .addComponent(btnCancel))
        );

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/putkeywordMsg.png"))); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 817, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(33, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void handleNext(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleNext
        // TODO add your handling code here:
        if(txtaKeyword.getText()!=null && !txtaKeyword.getText().equals(""))
        {

             String[] keywords = txtaKeyword.getText().split("\\n");
             List  keywordList = new ArrayList();
              int j=0;
             if(rankTrackerBean!=null && rankTrackerBean.getKeywordList()!=null && rankTrackerBean.getKeywordList().size()>0)
             {
                 keywordList=rankTrackerBean.getKeywordList();
                 j=keywordList.size();
             }
            
             for(int i=0;i<keywords.length;i++)
             {
                 j++;
                 Keywords keywords1=new Keywords();
                 keywords1.setKeywordid(j);
                 keywords1.setKeyword(keywords[i]);
                 keywordList.add(keywords1);
                 
             }
             rankTrackerBean.setKeywordList(keywordList);
             CheckKeyword ck=new CheckKeyword(rankTrackerBean);
             ck.setVisible(true);
             this.setVisible(false);
        }
        else{
            JOptionPane.showMessageDialog(rootPane, "The Keyword field is empty! Please enter the Keyword(s). ", "The Keyword field is empty!", 0);
            txtaKeyword.setFocusable(true);
        }
    }//GEN-LAST:event_handleNext

    private void btnHelphandleHelp(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHelphandleHelp
        // TODO add your handling code here:
        CommonHelper.openHelpURL();
}//GEN-LAST:event_btnHelphandleHelp

    private void handleBack(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleBack
        // TODO add your handling code here:
        NewProject newProject=new NewProject(rankTrackerBean);
        newProject.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_handleBack

    private void btnCancelhandleCancel(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelhandleCancel
        // TODO add your handling code here:
        this.setVisible(false);
}//GEN-LAST:event_btnCancelhandleCancel

    private void handleFinish(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleFinish
        // TODO add your handling code here:
        RankTracker rankTracker=new RankTracker(rankTrackerBean);
        rankTracker.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_handleFinish

    private void handleTabKey(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_handleTabKey
        // TODO add your handling code here:
        if(evt.getKeyCode()== KeyEvent.VK_TAB){   
        // your method action to ignore keypress enter  
        System.out.println("Tab pressed");
        evt.consume();
   }
    }//GEN-LAST:event_handleTabKey

    /**
    * @param args the command line arguments
    */
  /*  public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new EnterKeyWord().setVisible(true);
            }
        });
    }
*/
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBack;
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnFinish;
    private javax.swing.JButton btnHelp;
    private javax.swing.JButton btnNext;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea txtaKeyword;
    // End of variables declaration//GEN-END:variables

}
<file_sep>/src/com/searchkeyword/frame/CompanyProfile.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CompanyProfile.java
 *
 * Created on Jun 10, 2011, 5:16:20 PM
 */

package com.searchkeyword.frame;

import com.searchkeyword.bean.CompanyProfileBean;
import com.searchkeyword.bean.RankTrackerBean;
import com.searchkeyword.common.CommonHelper;
import com.searchkeyword.component.ImageFileView;
import com.searchkeyword.component.ImageFilter;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.IOException;

/**
 *
 * @author mayukh
 */
public class CompanyProfile extends javax.swing.JFrame {

     RankTrackerBean rankTrackerBean=new RankTrackerBean();

     CompanyProfileBean cpb=new CompanyProfileBean();
     

    /** Creates new form CompanyProfile */
    public CompanyProfile() {
        initComponents();
        this.setTitle("Edit RankTracker123 Preferences");
        CommonHelper.setScreenInCenter(this);
        CommonHelper.installCloseHandler(this);
        getCompanyProfilePreferences();
    }



    public CompanyProfile(RankTracker rankTracker) {
        initComponents();
        this.setTitle("Edit RankTracker123 Preferences");
        CommonHelper.setScreenInCenter(this);
        CommonHelper.installCloseHandler(this);
//        rankTrackerBean.setRankTracker(rankTracker);
//        if(rankTrackerBean!=null && rankTrackerBean.getWebsiteurl()!=null && !rankTrackerBean.getWebsiteurl().equals(""))
//        {
//            txtURL.setText(rankTrackerBean.getWebsiteurl());
//        }
    }



    public CompanyProfile(RankTrackerBean rankTBean) {
        initComponents();
        this.setTitle("Edit RankTracker123 Preferences");
        CommonHelper.setScreenInCenter(this);
        CommonHelper.installCloseHandler(this);
//        rankTrackerBean=rankTBean;
//        if(rankTrackerBean!=null && rankTrackerBean.getWebsiteurl()!=null && !rankTrackerBean.getWebsiteurl().equals(""))
//        {
//            txtURL.setText(rankTrackerBean.getWebsiteurl());
//        }
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel5 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        nameTextField = new javax.swing.JTextField();
        emailTextField = new javax.swing.JTextField();
        websiteTextField = new javax.swing.JTextField();
        addressTextField = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        logoLabel = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/companyprofileMsg.PNG"))); // NOI18N

        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)));

        jLabel2.setFont(new java.awt.Font("Arial", 0, 11));
        jLabel2.setText("Name :");
        jLabel2.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);

        jLabel3.setFont(new java.awt.Font("Arial", 0, 11));
        jLabel3.setText("Email :");
        jLabel3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel4.setFont(new java.awt.Font("Arial", 0, 11));
        jLabel4.setText("Website :");
        jLabel4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel6.setFont(new java.awt.Font("Arial", 0, 11));
        jLabel6.setText("Logo :");
        jLabel6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel5.setFont(new java.awt.Font("Arial", 0, 11));
        jLabel5.setText("Address :");
        jLabel5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        logoLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        logoLabel.setDebugGraphicsOptions(javax.swing.DebugGraphics.BUFFERED_OPTION);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(logoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 472, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(logoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
                .addContainerGap())
        );

        jButton4.setFont(new java.awt.Font("Arial", 0, 11));
        jButton4.setText("...");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                handleSelectLogo(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(addressTextField)
                        .addComponent(websiteTextField)
                        .addComponent(emailTextField)
                        .addComponent(nameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 495, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(12, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(emailTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(websiteTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(addressTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton4)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jButton1.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jButton1.setText("Help");

        jButton2.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jButton2.setText("OK");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                handlerOK(evt);
            }
        });

        jButton3.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
        jButton3.setText("Cancel");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                handleCancel(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 406, Short.MAX_VALUE)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton1)
                .addComponent(jButton3)
                .addComponent(jButton2))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void handleCancel(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleCancel
        // TODO add your handling code here:
        this.setVisible(false);
    }//GEN-LAST:event_handleCancel

    private void handleSelectLogo(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleSelectLogo
        // TODO add your handling code here:
        //Set up the file chooser.
        if (fc == null) {
            fc = new javax.swing.JFileChooser();

	    //Add a custom file filter and disable the default
	    //(Accept All) file filter.
            fc.addChoosableFileFilter(new ImageFilter());
            fc.setAcceptAllFileFilterUsed(false);

	    //Add custom icons for file types.
            fc.setFileView(new ImageFileView());

	    //Add the preview pane.
//            fc.setAccessory(new ImagePreview(fc));
        }

        //Show it.
        int returnVal = fc.showDialog(CompanyProfile.this, "Open");

        javax.swing.ImageIcon icon;
        //Process the results.
        if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
            java.io.File file = fc.getSelectedFile();
            fileName = file.getName();
            fileExt = fileName.substring(fileName.indexOf(".")+1);
            try {
//                buffImage = javax.imageio.ImageIO.read(file);
                image = javax.imageio.ImageIO.read(file);
            } catch (java.io.IOException ex) {
                java.util.logging.Logger.getLogger(CompanyProfile.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            if(image.getWidth(this)<=460 && image.getHeight(this)<=240) {
                icon=new javax.swing.ImageIcon(image);
            } else {
                icon=new javax.swing.ImageIcon(getScaledImage(image, 430, 240));
            }
            logoLabel.setIcon(icon);
        } 
        
        
        //Reset the file chooser for the next time it's shown.
        fc.setSelectedFile(null);
    }//GEN-LAST:event_handleSelectLogo

    private void handlerOK(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handlerOK
        // TODO add your handling code here:
        saveCompanyProfilePreferences();

        try{
            // Open the file that is the first
            // command line parameter
            java.io.FileInputStream fstream = new java.io.FileInputStream("companyProfileInformation.txt");
            // Get the object of DataInputStream
            java.io.DataInputStream in = new java.io.DataInputStream(fstream);
            java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(in));
            String strLine;
            //Read File Line By Line
            while ((strLine = br.readLine()) != null)   {
            // Print the content on the console
//                System.out.println(strLine);
                if(strLine.contains("Name")) {
                    cpb.setName(strLine.substring(strLine.indexOf(" ")+1));
                }
                else if(strLine.contains("Email")) {
                    cpb.setEmail(strLine.substring(strLine.indexOf(" ")+1));
                }
                else if(strLine.contains("Website")) {
                    cpb.setWebsite(strLine.substring(strLine.indexOf(" ")+1));
                }
                else if(strLine.contains("Address")) {
                    cpb.setAddress(strLine.substring(strLine.indexOf(" ")+1));
                }
                else if(strLine.contains("Logo")) {
                    fileName=strLine.substring(strLine.indexOf(" ")+1);
//                    fileExt = fileName.substring(fileName.indexOf(".")+1);
                }
            }
            //Close the input stream
            in.close();
        }catch (Exception e){//Catch exception if any
            java.util.logging.Logger.getLogger(CompanyProfile.class.getName()).log(java.util.logging.Level.SEVERE, null, e);
        }
        this.setVisible(false);
    }//GEN-LAST:event_handlerOK

    /**
     * Resizes an image using a Graphics2D object backed by a BufferedImage.
     * @param srcImg - source image to scale
     * @param w - desired width
     * @param h - desired height
     * @return - the new resized image
     */
    private Image getScaledImage(Image srcImg, int w, int h){
//        System.out.println("height::"+srcImg.getHeight(this)+" "+"width::"+srcImg.getWidth(this));
        BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);       
        Graphics2D g2 = resizedImg.createGraphics();
        g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g2.drawImage(srcImg, 0, 0, w, h, null);
        g2.dispose();
        return resizedImg;
    }

    public void saveCompanyProfilePreferences() {
        try {
            java.io.Writer output = null;
            java.io.File file = new java.io.File("companyProfileInformation.txt");
            output = new java.io.BufferedWriter(new java.io.FileWriter(file));
            
            output.write("Name"+" "+nameTextField.getText()+"\n");
            output.write("Email"+" "+emailTextField.getText()+"\n");
            output.write("Website"+" "+websiteTextField.getText()+"\n");
            output.write("Address"+" "+addressTextField.getText()+"\n");
            output.write("Logo"+" "+fileName+"\n");
            if(fileName!=null) {
                javax.imageio.ImageIO.write(image, fileExt, new java.io.File(fileName));
            }
            
//            output.write(text);
            output.close();
        } catch (IOException e) {
            java.util.logging.Logger.getLogger(CompanyProfile.class.getName()).log(java.util.logging.Level.SEVERE, null, e);
        }
        
    }

    public void getCompanyProfilePreferences() {
        try{
            // Open the file that is the first
            // command line parameter
            java.io.FileInputStream fstream = new java.io.FileInputStream("companyProfileInformation.txt");
            // Get the object of DataInputStream
            java.io.DataInputStream in = new java.io.DataInputStream(fstream);
            java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(in));
            String strLine;
            //Read File Line By Line
            while ((strLine = br.readLine()) != null)   {
            // Print the content on the console
//                System.out.println(strLine);
                if(strLine.contains("Name")) {                    
                    nameTextField.setText(strLine.substring(strLine.indexOf(" ")+1));
                }
                else if(strLine.contains("Email")) {
                    emailTextField.setText(strLine.substring(strLine.indexOf(" ")+1));
                }
                else if(strLine.contains("Website")) {
                    websiteTextField.setText(strLine.substring(strLine.indexOf(" ")+1));
                }
                else if(strLine.contains("Address")) {
                    addressTextField.setText(strLine.substring(strLine.indexOf(" ")+1));
                }
                else if(strLine.contains("Logo")) {
                    fileName=strLine.substring(strLine.indexOf(" ")+1);
                    fileExt = fileName.substring(fileName.indexOf(".")+1);
                }
            }
            //Close the input stream
            in.close();
        }catch (Exception e){//Catch exception if any
            java.util.logging.Logger.getLogger(CompanyProfile.class.getName()).log(java.util.logging.Level.SEVERE, null, e);
        }

           
        javax.swing.ImageIcon icon;
        if(fileName!=null) {
        try {
            image = javax.imageio.ImageIO.read(new java.io.File(fileName));
        } catch (java.io.IOException ex) {
                java.util.logging.Logger.getLogger(CompanyProfile.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        if(image.getWidth(this)<=460 && image.getHeight(this)<=240) {
            icon=new javax.swing.ImageIcon(image);
        } else {
            icon=new javax.swing.ImageIcon(getScaledImage(image, 430, 240));
        }
        logoLabel.setIcon(icon);
        }
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField addressTextField;
    private javax.swing.JTextField emailTextField;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JLabel logoLabel;
    private javax.swing.JTextField nameTextField;
    private javax.swing.JTextField websiteTextField;
    // End of variables declaration//GEN-END:variables
    private javax.swing.JFileChooser fc;
    private java.awt.image.BufferedImage image;
//    private java.awt.image.BufferedImage buffImage = null;
    private String fileName=null;
    private String fileExt=null;
}
<file_sep>/src/com/searchkeyword/frame/CheckKeyword.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CheckKeyword.java
 *
 * Created on May 9, 2011, 6:09:24 PM
 */

package com.searchkeyword.frame;

import com.searchkeyword.bean.Keywords;
import com.searchkeyword.bean.RankTrackerBean;
import com.searchkeyword.common.CommonHelper;
import com.searchkeyword.test.PageRankService;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;

import java.util.List;
import javax.swing.Timer;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.border.Border;

/**
 *
 * @author Euphern_Java
 */
public class CheckKeyword extends javax.swing.JFrame implements ActionListener{

    private RankTrackerBean rankTrackerBean;



    public final static int ONE_SECOND = 1000;

 // private JProgressBar progressBar;

  private Timer timer;

  //private JButton startButton;

  private LongTask task;

 // private JTextArea taskOutput;

  //private String newline = "\n";

  private int actualRank=0;

    /** Creates new form CheckKeyword */
    public CheckKeyword() {
        initComponents();
        prgMain.setMinimum( 0 );
	prgMain.setMaximum( 300 );
	prgMain.setValue( 0 );
         task = new LongTask();

        // checkURL("http://euphern.com");

//         int rank=getKeywordRank("euphern","www.google.com");

         List keywordList=new ArrayList();
         keywordList.add("euphern");
         keywordList.add("image");
           changePrgStatus(false);
         if(keywordList!=null && keywordList.size()>0)
         {
             int noOfKeyword=keywordList.size();

             for(int i=0;i<noOfKeyword;i++)
             {
                  pnlPrg.add(new JButton("Button"));
                  pnlPrg.getComponent(0).setName("btn1");
                  pnlPrg.getComponent(0).setVisible(true);
                //  System.out.println(pnlPrg.getComponent(0).getName());
                  pnlPrg.revalidate();
                  validate();
             }

             /*
             int i=0;
             JProgressBar prg=new JProgressBar();

             if(noOfKeyword>=1)
             {
                 prg1.setVisible(true);
             }

             if(noOfKeyword>=2)
             {
                 prg2.setVisible(true);
             }

             if(noOfKeyword>=3)
             {
                 prg3.setVisible(true);
             }

             if(noOfKeyword>=4)
             {
                 prg4.setVisible(true);
             }

             if(noOfKeyword>=5)
             {
                 prg5.setVisible(true);
             }

             if(noOfKeyword>=6)
             {
                 prg6.setVisible(true);
             }
*/




         }

    /*
        super(new BorderLayout());
    task = new LongTask();

    //Create the demo's UI.
    startButton = new JButton("Start");
    startButton.setActionCommand("start");
    startButton.addActionListener(this);

    progressBar = new JProgressBar(0, task.getLengthOfTask());
    progressBar.setValue(0);

    //We call setStringPainted, even though we don't want the
    //string to show up until we switch to determinate mode,
    //so that the progress bar height stays the same whether
    //or not the string is shown.
    progressBar.setStringPainted(true); //get space for the string
    progressBar.setString(""); //but don't paint it

    taskOutput = new JTextArea(5, 20);
    taskOutput.setMargin(new Insets(5, 5, 5, 5));
    taskOutput.setEditable(false);

    JPanel panel = new JPanel();
    panel.add(startButton);
    panel.add(progressBar);

    add(panel, BorderLayout.PAGE_START);
    add(new JScrollPane(taskOutput), BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
*/
    //Create a timer.
    timer = new Timer(ONE_SECOND, new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        prgMain.setValue(task.getCurrent());
        String s = task.getMessage();
        if (s != null) {
          if (prgMain.isIndeterminate()) {
            prgMain.setIndeterminate(false);
            prg1.setIndeterminate(false);
            prg1.setVisible(false);
           //  prg2.setIndeterminate(true);
            prgMain.setString(null); //display % string           
          }
           else if (prg2.isIndeterminate()) {
            prg2.setIndeterminate(false);
            prg2.setVisible(false);
            // prg3.setIndeterminate(true);
          }
          else if (prg3.isIndeterminate()) {
            prg3.setIndeterminate(false);
            prg3.setVisible(false);
            // prg4.setIndeterminate(true);
          }
          else if (prg4.isIndeterminate()) {
            prg4.setIndeterminate(false);
            prg4.setVisible(false);
           //  prg6.setIndeterminate(true);
          }
          else if (prg5.isIndeterminate()) {
            prg5.setIndeterminate(false);
            prg5.setVisible(false);
           //  prg6.setIndeterminate(true);
          }
          else if (prg6.isIndeterminate()) {
            prg6.setIndeterminate(false);
            prg6.setVisible(false);
             //prg3.setIndeterminate(true);
          }

        //   System.out.print("test "+ task.getCurrent());
         // taskOutput.append(s + newline);
         // taskOutput.setCaretPosition(taskOutput.getDocument()
         //     .getLength());
        }
        if (prgMain.getValue()==300) {
          //   System.out.print("test12");
          Toolkit.getDefaultToolkit().beep();
          timer.stop();
          changePrgStatus(false);
          btnAction.setEnabled(true);
          prgMain.setValue(prgMain.getMinimum());
          prgMain.setString(""); //hide % string
        }
      }
    });

      
    }




    /*
     *
     * Function Chenge Progress bar Status
     */

    private void changePrgStatus(boolean  status)
    {

          prg1.setIndeterminate(status);
          prg2.setIndeterminate(status);
          prg3.setIndeterminate(status);
          prg4.setIndeterminate(status);
          prg5.setIndeterminate(status);
          prg6.setIndeterminate(status);
          prg1.setVisible(status);
          prg2.setVisible(status);
          prg3.setVisible(status);
          prg4.setVisible(status);
          prg5.setVisible(status);
          prg6.setVisible(status);

    }




    public void actionPerformed(ActionEvent evt) {
    prgMain.setIndeterminate(true);
    btnAction.setEnabled(false);
    task.go();
    timer.start();
  }

    public CheckKeyword(RankTrackerBean rankTBean) {
        initComponents();
        this.setTitle("Check Keyword");
        CommonHelper.setScreenInCenter(this);
        CommonHelper.installCloseHandler(this);
        prgMain.setMinimum( 0 );
	prgMain.setMaximum( 300 );
	prgMain.setValue( 0 );
        rankTrackerBean=rankTBean;

        task = new LongTask();

     
 final long startTime = System.currentTimeMillis();
        //Create a timer.
    timer = new Timer(ONE_SECOND, new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
          
        prgMain.setValue(task.getCurrent());
        String s = task.getMessage();
        if (s != null) {
          if (prgMain.isIndeterminate()) {
            prgMain.setIndeterminate(false);
            prg6.setIndeterminate(false);
            prg6.setVisible(false);
           //  prg2.setIndeterminate(true);
            prgMain.setString(null); //display % string
          }
           else if (prg5.isIndeterminate()) {
            prg5.setIndeterminate(false);
            prg5.setVisible(false);
            // prg3.setIndeterminate(true);
          }
          else if (prg4.isIndeterminate()) {
            prg4.setIndeterminate(false);
            prg4.setVisible(false);
            // prg4.setIndeterminate(true);
          }
          else if (prg3.isIndeterminate()) {
            prg3.setIndeterminate(false);
            prg3.setVisible(false);
           //  prg6.setIndeterminate(true);
          }
          else if (prg2.isIndeterminate()) {
            prg2.setIndeterminate(false);
            prg2.setVisible(false);
           //  prg6.setIndeterminate(true);
          }
          else if (prg1.isIndeterminate()) {
            prg1.setIndeterminate(false);
            prg1.setVisible(false);
             //prg3.setIndeterminate(true);
          }

        //   System.out.print("test "+ task.getCurrent());
         // taskOutput.append(s + newline);
         // taskOutput.setCaretPosition(taskOutput.getDocument()
         //     .getLength());
        }
        if (prgMain.getValue()==300) {
          //   System.out.print("test12");
          Toolkit.getDefaultToolkit().beep();
          timer.stop();
          changePrgStatus(false);
          btnAction.setEnabled(true);
          prgMain.setValue(prgMain.getMinimum());
          prgMain.setString(""); //hide % string
          long endTime = System.currentTimeMillis();
          long totaltime=endTime-startTime;
          // System.out.println(totaltime);
         // double timeelapsed=totaltime/600;
          // System.out.println(timeelapsed);
          DecimalFormat df = new DecimalFormat("#.##");
          String timeelapsed=df.format(totaltime/600);
          if(timeelapsed.length()==1)
          {
              timeelapsed="0:"+timeelapsed+"0";
          }
          else if(timeelapsed.length()==2)
          {
              timeelapsed="0:"+timeelapsed;
          }
         // System.out.println(timeelapsed);
          rankTrackerBean.setTimeelapsed(String.valueOf(timeelapsed));
           SearchResult searchResult=new SearchResult(rankTrackerBean);
            searchResult.setVisible(true);
            setVisible(false);
        }
      }
    });


        changePrgStatus(true);
        btnAction.setEnabled(false);
        task.go();
        timer.start();

        List keywordList=rankTrackerBean.getKeywordList();
        String domain=rankTrackerBean.getWebsiteurl();
        
        List countryList=new ArrayList();
        countryList.add(null);       // creating and setting countryList with null and Denmark value
        countryList.add("in");
        
           for(int j=0;j<keywordList.size();j++)
           {
               Keywords keywords=(Keywords)keywordList.get(j);
               for(int i=0;i<countryList.size();i++) {
                   String countrycode=(String)countryList.get(i);
                   int rank=getKeywordRank(keywords.getKeyword(),domain,countrycode);
                   if(countrycode!=null){
                       keywords.setLocalrank(rank);
                   }
                   else{
                       keywords.setRank(rank);
                   }
                   
               }
            }
        
        
       /* List keywordList1=rankTrackerBean.getKeywordList();
           for(int j=0;j<keywordList1.size();j++)
           {
               Keywords keywords=(Keywords)keywordList1.get(j);
               System.out.println("Keywords "+keywords.getKeyword());
               System.out.println("Rank "+keywords.getRank());
           }
*/
       


        /*checkPR(rankTrackerBean.getWebsiteurl());
        List keywordList=rankTrackerBean.getKeywordList();
        for(int i=0;i<keywordList.size();i++)
        {

                JProgressBar progressBar = new JProgressBar();
                progressBar.setValue(25);
                progressBar.setStringPainted(true);
                Border border = BorderFactory.createTitledBorder("Reading...");
                progressBar.setBorder(border);
                pnlPrg.add(progressBar, BorderLayout.SOUTH);

                


//
//            JProgressBar prg=new JProgressBar();
//             prg.setMinimum( 0 );
//             prg.setMaximum( 200 );
//             prg.setValue( 0 );
//             prg.setVisible(true);
//             jPanel3.add(prg);
        }*/
    }


    private void checkPR(String domain)
    {
       // String [] args=null;
         long start = System.currentTimeMillis();
        PageRankService prService = new PageRankService();
        //String domain = "http://www.gmail.com";
//        if (args.length > 0) {
//            domain = args[0];
//        }
        uploadProgress("test");
        System.out.println("Checking " + domain);
        System.out.println("Google PageRank: " + prService.getPR(domain));
        System.out.println("Took: " + (System.currentTimeMillis() - start) + "ms");
    }


    public void uploadProgress(String filename)
{
for( int iCtr = 1; iCtr < 201; iCtr++ )
			{
				// Do some sort of simulated task
				DoBogusTask( iCtr );
                                   //System.out.print("I "+iCtr);
                                  // if(iCtr==50)
                                  // {
                                       uploadProgress2("Test",prg1);
                                 //  }
                                  // else if(iCtr==100)
                                  // {
                                       uploadProgress2("Test",prg2);
                                 //  }
                                  // else if(iCtr==150)
                                 //  {
                                      // uploadProgress2("Test",lblKeyword2,prgThree);
                                  // }
				// Update the progress indicator and label
				/*lblKeyword.setText(filename);
				Rectangle labelRect = lblKeyword.getBounds();
				labelRect.x = 0;
				labelRect.y = 0;
				lblKeyword.paintImmediately( labelRect );
*/
				prgMain.setValue( iCtr );
				Rectangle progressRect = prgMain.getBounds();
				progressRect.x = 0;
				progressRect.y = 0;
				prgMain.paintImmediately( progressRect );
			}
}



    public void uploadProgress2(String filename,JProgressBar prg)
{
for( int iCtr = 1; iCtr < 21; iCtr++ )
			{
				// Do some sort of simulated task
				DoBogusTask( iCtr );
				// Update the progress indicator and label
//				lbl.setText(filename);
//				Rectangle labelRect = lbl.getBounds();
//				labelRect.x = 0;
//				labelRect.y = 0;
//				lbl.paintImmediately( labelRect );

				prg.setValue( iCtr );
				Rectangle progressRect = prg.getBounds();
				progressRect.x = 0;
				progressRect.y = 0;
				prg.paintImmediately( progressRect );
			}
}

public void DoBogusTask( int iCtr )
	{
		Random random = new Random( iCtr );

		// Waste some time
		for( int iValue = 0; iValue < random.nextFloat() * 100000; iValue++ )
		{
			//System.out.println("hi   "+iValue);
		}
	}



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        btnFinish = new javax.swing.JButton();
        btnNext = new javax.swing.JButton();
        btnBack = new javax.swing.JButton();
        btnHelp = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        prgMain = new javax.swing.JProgressBar();
        btnAction = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        pnlPrg = new javax.swing.JPanel();
        prg1 = new javax.swing.JProgressBar();
        prg2 = new javax.swing.JProgressBar();
        prg3 = new javax.swing.JProgressBar();
        prg4 = new javax.swing.JProgressBar();
        prg5 = new javax.swing.JProgressBar();
        prg6 = new javax.swing.JProgressBar();
        jPanel4 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        btnFinish.setText("Finish");
        btnFinish.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                handleFinish(evt);
            }
        });

        btnNext.setText("Next >>");
        btnNext.setEnabled(false);

        btnBack.setText("<< Back");
        btnBack.setEnabled(false);

        btnHelp.setText("Help");
        btnHelp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHelphandleHelp(evt);
            }
        });

        btnCancel.setText("Cancel");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelhandleCancel(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnHelp, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 359, Short.MAX_VALUE)
                .addComponent(btnBack, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnNext)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnFinish, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnHelp)
                    .addComponent(btnBack)
                    .addComponent(btnNext)
                    .addComponent(btnFinish)
                    .addComponent(btnCancel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnAction.setText("Start");
        btnAction.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                handleStart(evt);
            }
        });

        prg1.setMaximum(20);

        prg2.setMaximum(20);

        javax.swing.GroupLayout pnlPrgLayout = new javax.swing.GroupLayout(pnlPrg);
        pnlPrg.setLayout(pnlPrgLayout);
        pnlPrgLayout.setHorizontalGroup(
            pnlPrgLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPrgLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlPrgLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(prg6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(prg1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(prg2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(prg3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(prg4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(prg5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(566, Short.MAX_VALUE))
        );
        pnlPrgLayout.setVerticalGroup(
            pnlPrgLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlPrgLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(prg6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(prg1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(prg2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(prg3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(prg4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(prg5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(80, Short.MAX_VALUE))
        );

        jScrollPane1.setViewportView(pnlPrg);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addComponent(prgMain, javax.swing.GroupLayout.PREFERRED_SIZE, 515, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(44, 44, 44)
                .addComponent(btnAction, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap(114, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(21, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 741, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(23, 23, 23))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(prgMain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAction))
                .addGap(35, 35, 35)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(87, Short.MAX_VALUE))
        );

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/searchKeywordMsg.png"))); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 785, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void handleStart(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleStart
        // TODO add your handling code here:
        // uploadProgress("test");
       //  btnAction.setText("Stop");

//        prgMain.setIndeterminate(true);
//        prg1.setIndeterminate(true);
//        prg2.setIndeterminate(true);
//        prg3.setIndeterminate(true);
//        prg4.setIndeterminate(true);
//        prg5.setIndeterminate(true);
//        prg6.setIndeterminate(true);

        changePrgStatus(true);
        btnAction.setEnabled(false);
        task.go();
        timer.start();
    }//GEN-LAST:event_handleStart

    private void handleFinish(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_handleFinish
        // TODO add your handling code here:

        SearchResult sr=new SearchResult(rankTrackerBean);
        sr.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_handleFinish

    private void btnHelphandleHelp(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHelphandleHelp
        // TODO add your handling code here:
       CommonHelper.openHelpURL();
}//GEN-LAST:event_btnHelphandleHelp

    private void btnCancelhandleCancel(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelhandleCancel
        // TODO add your handling code here:
        this.setVisible(false);
}//GEN-LAST:event_btnCancelhandleCancel




    private static void createAndShowGUI() {

      new CheckKeyword().setVisible(true);
       
    //Make sure we have nice window decorations.
//    JFrame.setDefaultLookAndFeelDecorated(true);
//
//    //Create and set up the window.
//    JFrame frame = new JFrame("ProgressBarDemo2");
//    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//
//    //Create and set up the content pane.
//    JComponent newContentPane = new ProgressBarDemo2();
//    newContentPane.setOpaque(true); //content panes must be opaque
//    frame.setContentPane(newContentPane);
//
//    //Display the window.
//    frame.pack();
//    frame.setVisible(true);
  }





/*
 *
 * Function To get All related URL List By a single URL
 */




    private int getKeywordRank(String keyword,String domain,String countrycode)
    {
         int rank=0;
         if(keyword!=null && domain!=null && !keyword.equals("") && !domain.equals(""))
         {
       // System.out.println("keyword  "+keyword);
        String newkeyword=keyword.replaceAll(" ", "_");
       //  System.out.println("keyword  "+keyword);
         String domainName=getdomainName(domain);
        //  System.out.println("domainName  "+domainName);
        boolean pagest=false;
         if(domainName!=null && !domainName.equals("") && domainName.toUpperCase().equals(keyword.toUpperCase()))
         {
              String pagecontent=WebPageStatus.getPageContent(domain);
              String[] strTitle1=pagecontent.split("<title>");
               String[] strTitle2=strTitle1[1].split("</title>");
               String title=strTitle2[0];
               System.out.print("title  "+title);
                System.out.print("keyword  "+keyword);
              //System.out.print("pagecontent  "+pagecontent);
                String s1=title.toUpperCase().trim();
                String s2=keyword.toUpperCase().trim();
              if(s1.equals(s2))
              {
                 rank=1;
//                  rank=actualRank;
                 pagest=true;
              }
         }

             else if(domainName != null && !domainName.equals(""))
         {
       
        String str="\\[";
        String googleBaseUrl=null;
        if(countrycode!=null) {
            googleBaseUrl="http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q="+newkeyword+"&hl=en&safe=off&start=0&rsz=8&sa=N&gl="+countrycode+"";
        } else {
            googleBaseUrl="http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q="+newkeyword+"&hl=en&safe=off&start=0&rsz=8&sa=N";
        }
        
         String pagecontent=WebPageStatus.getPageContent(googleBaseUrl);
         //System.out.println("Page Content  "+pagecontent);

         String[] resultArray1=pagecontent.split("\\[");
        // System.out.println("Page Content2  "+resultArray1[1]);

         String[] resultArray2=resultArray1[1].split("\\]");
       //  System.out.println("Page Content3  "+resultArray2[0]);
         if(resultArray2[0].toUpperCase().indexOf(domainName.toUpperCase())>0)
         {
         String result1=resultArray2[0].replaceAll("\\{", "");
        // System.out.println("result  "+result1);
         String[] result2=result1.split("\\},");
        // System.out.println("result2  "+result2[0]);


         boolean status=false;
         for(int i=0;i<result2.length;i++)
         {
                actualRank++;
              String[] result_T3=result2[i].split("title");
              if(result_T3.length>1)
              {
            // System.out.println("result_T3  "+result_T3[1]);
             String[] result_T4=result_T3[1].split(",");
             if(result_T4.length>0)
             {
             // System.out.println("result_T4  "+result_T4[0]);
              String chkResult=result_T4[0].toUpperCase();
              int indx_T=chkResult.indexOf(keyword.toUpperCase());
             // System.out.println("Indx "+indx_T);
              if(indx_T>0)
              {

             String[] result3=result2[i].split("visibleUrl");
             if(result3.length>1)
             {
            // System.out.println("result3  "+result3[1]);
             String[] result4=result3[1].split(",");
             if(result4.length>0)
             {
             // System.out.println("result4  "+result4[0]);
              String linkedUrl=result4[0].toUpperCase();
            //  System.out.println("linkedUrl  "+linkedUrl);
             // if(domain.indexOf("http")>0)
             // {
              String chekdomain=domain.replaceAll("http://", "");
              chekdomain=chekdomain.replaceAll("www", "");
            //  System.out.println("chekdomain  "+chekdomain);
               int indx1=linkedUrl.indexOf(chekdomain.toUpperCase());
              //System.out.println("Indx "+indx);
              if(indx1>0)
              {
                  rank=1;
//                  rank=actualRank;
                  status=true;
                  break;
              }


              int indx=result4[0].indexOf(".com");
              //System.out.println("Indx "+indx);
              if(indx>0)
              {
                  rank++;
              }
                  }
                // }

                  }
             }
             }
             }

             
         }

          if(!status)
              {
                rank=(10-rank)*3;
              }

         
        }
        }
        }

         // System.out.println("Rank "+rank);
          return rank;
    }






    public String getdomainName(String websiteURL)
        {
            String domainName=null;
            //websiteURL="http://euphern.com";
            //System.out.println("websiteURL  "+websiteURL);
            if(websiteURL!=null && !websiteURL.equals(""))
            {
            if(websiteURL.toUpperCase().indexOf("www".toUpperCase())>0)
            {
                 String[] str=websiteURL.split("\\.");
                 if(str.length>1)
                 domainName=str[1];
            }
            else{
                 String[] str1=websiteURL.split("/");
                  if(str1.length>1)
                  {
                     // System.out.println("str1[2] "+str1[2]);
                    String[] str2=str1[2].split("\\.");
                      if(str2.length>1)
                         domainName=str2[0];
                  }

            }
            }

            return domainName;
        }




    private void checkURL(String websiteurl)
    {

        String pagecontent=WebPageStatus.getPageContent(websiteurl);
			List urllinkList=WebPageStatus.getLink(pagecontent);
			List webpageUrlList=new ArrayList();

			if(urllinkList!=null && urllinkList.size()>0)
			{

				for(int i=0;i<urllinkList.size();i++)
				{
					WebSitePageLink pageLink=new WebSitePageLink();
					pageLink.setPageid(i);
					String pageurl=String.valueOf(urllinkList.get(i));
					if(pageurl.indexOf("http://") != -1)
					pageLink.setPageurl(pageurl);
					else
					{
                                            pageLink.setPageurl(websiteurl+"/"+pageurl);
                                            pageLink.setPagetitle(pageurl.substring(0, pageurl.length()-5).toUpperCase());
					}
					//String pagecontent2=WebPageStatus.getPageContent(String.valueOf(urllinkList.get(i)));
					//String pagetitle=WebPageStatus.getPageTitle(pagecontent2);
					//pageLink.setPagetitle(pagetitle);

					webpageUrlList.add(pageLink);

					//System.out.println("Link "+urllinkList.get(i));
				}
			}
			else
			{
				WebSitePageLink pageLink=new WebSitePageLink();
				pageLink.setPageid(1);
				pageLink.setPageurl("No Page Link Found");
				webpageUrlList.add(pageLink);
			}

                        if(webpageUrlList!=null && webpageUrlList.size()>0)
                        {
                            for(int i=0;i<webpageUrlList.size();i++)
                            {
                                WebSitePageLink pageLink=(WebSitePageLink)webpageUrlList.get(i);
                                System.out.println("URL "+pageLink.getPageurl());
                                System.out.println("Title  "+pageLink.getPagetitle());
                            }
                        }

    }







    /**
    * @param args the command line arguments
    */
   public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new CheckKeyword().setVisible(true);
//            }
//        });

       javax.swing.SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        createAndShowGUI();
      }
    });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAction;
    private javax.swing.JButton btnBack;
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnFinish;
    private javax.swing.JButton btnHelp;
    private javax.swing.JButton btnNext;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPanel pnlPrg;
    private javax.swing.JProgressBar prg1;
    private javax.swing.JProgressBar prg2;
    private javax.swing.JProgressBar prg3;
    private javax.swing.JProgressBar prg4;
    private javax.swing.JProgressBar prg5;
    private javax.swing.JProgressBar prg6;
    private javax.swing.JProgressBar prgMain;
    // End of variables declaration//GEN-END:variables

}





/*
 * Code for Grnerate and run the progress bar
 */



abstract class SwingWorker {
  private Object value; // see getValue(), setValue()

  /**
   * Class to maintain reference to current worker thread under separate
   * synchronization control.
   */
  private static class ThreadVar {
    private Thread thread;

    ThreadVar(Thread t) {
      thread = t;
    }

    synchronized Thread get() {
      return thread;
    }

    synchronized void clear() {
      thread = null;
    }
  }

  private ThreadVar threadVar;

  /**
   * Get the value produced by the worker thread, or null if it hasn't been
   * constructed yet.
   */
  protected synchronized Object getValue() {
    return value;
  }

  /**
   * Set the value produced by worker thread
   */
  private synchronized void setValue(Object x) {
    value = x;
  }

  /**
   * Compute the value to be returned by the <code>get</code> method.
   */
  public abstract Object construct();

  /**
   * Called on the event dispatching thread (not on the worker thread) after
   * the <code>construct</code> method has returned.
   */
  public void finished() {
  }

  /**
   * A new method that interrupts the worker thread. Call this method to force
   * the worker to stop what it's doing.
   */
  public void interrupt() {
    Thread t = threadVar.get();
    if (t != null) {
      t.interrupt();
    }
    threadVar.clear();
  }

  /**
   * Return the value created by the <code>construct</code> method. Returns
   * null if either the constructing thread or the current thread was
   * interrupted before a value was produced.
   *
   * @return the value created by the <code>construct</code> method
   */
  public Object get() {
    while (true) {
      Thread t = threadVar.get();
      if (t == null) {
        return getValue();
      }
      try {
        t.join();
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt(); // propagate
        return null;
      }
    }
  }

  /**
   * Start a thread that will call the <code>construct</code> method and
   * then exit.
   */
  public SwingWorker() {
    final Runnable doFinished = new Runnable() {
      public void run() {
        finished();
      }
    };

    Runnable doConstruct = new Runnable() {
      public void run() {
        try {
          setValue(construct());
        } finally {
          threadVar.clear();
        }

        SwingUtilities.invokeLater(doFinished);
      }
    };

    Thread t = new Thread(doConstruct);
    threadVar = new ThreadVar(t);
  }

  /**
   * Start the worker thread.
   */
  public void start() {
    Thread t = threadVar.get();
    if (t != null) {
      t.start();
    }
  }
}

class LongTask {
  private int lengthOfTask;

  private int current = 0;

  private boolean done = false;

  private boolean canceled = false;

  private String statMessage;

  public LongTask() {
    //Compute length of task...
    //In a real program, this would figure out
    //the number of bytes to read or whatever.
    lengthOfTask = 1000;
  }

  /**
   * Called from ProgressBarDemo to start the task.
   */
  public void go() {
    final SwingWorker worker = new SwingWorker() {
      public Object construct() {
        current = 0;
        done = false;
        canceled = false;
        statMessage = null;
        return new ActualTask();
      }
    };
    worker.start();
  }

  /**
   * Called from ProgressBarDemo to find out how much work needs to be done.
   */
  public int getLengthOfTask() {
    return lengthOfTask;
  }

  /**
   * Called from ProgressBarDemo to find out how much has been done.
   */
  public int getCurrent() {
    return current;
  }

  public void stop() {
    canceled = true;
    statMessage = null;
  }

  /**
   * Called from ProgressBarDemo to find out if the task has completed.
   */
  public boolean isDone() {
    return done;
  }

  /**
   * Returns the most recent status message, or null if there is no current
   * status message.
   */
  public String getMessage() {
    return statMessage;
  }

  /**
   * The actual long running task. This runs in a SwingWorker thread.
   */
  class ActualTask {
    ActualTask() {
      //Fake a long task,
      //making a random amount of progress every second.
      while (!canceled && !done) {
        try {
          Thread.sleep(1000); //sleep for a second
          current += Math.random() * 100; //make some progress
          if (current >= lengthOfTask) {
            done = true;
            current = lengthOfTask;
          }
          statMessage = "Completed " + current + " out of "
              + lengthOfTask + ".";
        } catch (InterruptedException e) {
          System.out.println("ActualTask interrupted");
        }
      }
    }
  }
}


/*
 * End the progress bar code
 */




