home *** CD-ROM | disk | FTP | other *** search
/ Datatid 2000 #1 / Datatid-2000-01.iso / Internet / JAVA_NAVIGATOR / JAVANAVIGATOR.EXE / %MAINDIR% / JavaNavigatorV50.exe / JAVATabR.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-18  |  11.2 KB  |  520 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Dimension;
  6. import java.awt.Event;
  7. import java.awt.Font;
  8. import java.awt.Graphics;
  9. import java.awt.Image;
  10. import java.awt.Label;
  11. import java.awt.LayoutManager;
  12. import java.awt.MediaTracker;
  13. import java.awt.Panel;
  14. import java.net.MalformedURLException;
  15. import java.net.URL;
  16. import java.util.NoSuchElementException;
  17. import java.util.StringTokenizer;
  18.  
  19. public class JAVATabR extends Applet implements Runnable {
  20.    String sDefMO = "1st JAVA Navigator[Tab], (c)1997-1999 AUSCOMP - World Wide (www.auscomp.com)";
  21.    String sCopyright = "AUSCOMP (www.auscomp.com)";
  22.    int xSwitch = 4;
  23.    String sLoading = "1st JAVA Navigator V5.0";
  24.    Thread thJAVATab;
  25.    String[] aHref;
  26.    String[] aFrame;
  27.    String[] aHref2;
  28.    String[] aFrame2;
  29.    String[] aMsg;
  30.    String[] tempString;
  31.    String sText = "";
  32.    String sHref = "";
  33.    String sFrame = "";
  34.    String sHref2 = "";
  35.    String sFrame2 = "";
  36.    String sMsg = "";
  37.    String sMsgOld = "";
  38.    int iLoading;
  39.    int iTabCnt;
  40.    int oldx;
  41.    int iTabDefault = 999;
  42.    int iBGRed = 255;
  43.    int iFGRed;
  44.    int iBHRed;
  45.    int iFHRed = 255;
  46.    int iBGGreen = 255;
  47.    int iFGGreen;
  48.    int iBHGreen;
  49.    int iFHGreen = 255;
  50.    int iBGBlue = 255;
  51.    int iFGBlue;
  52.    int iBHBlue;
  53.    int iFHBlue;
  54.    Font fFont = new Font("Dialog", 0, 12);
  55.    private boolean bCopyright = false;
  56.    private boolean allLoaded = false;
  57.    Image imgBG;
  58.    // $FF: renamed from: g1 java.awt.Graphics
  59.    Graphics field_0;
  60.    boolean fAuscomp = true;
  61.    String sMOUSEOVERSOUND = "none";
  62.    String sMOUSECLICKSOUND = "none";
  63.    int oldTabPanel = -1;
  64.    TabPanel tabPanel1;
  65.    Label label1;
  66.  
  67.    void tabPanel1_MouseMove(Event event) {
  68.       try {
  69.          if (!this.sMOUSEOVERSOUND.equals("none")) {
  70.             ((Applet)this).play(((Applet)this).getCodeBase(), this.sMOUSEOVERSOUND);
  71.          }
  72.       } catch (Exception var3) {
  73.       }
  74.  
  75.       int x = 0;
  76.  
  77.       try {
  78.          x = this.tabPanel1.setTabLabelColor(event);
  79.          if (x == 999 && this.oldx != 999) {
  80.             this.tabPanel1.setMOLabelColor(this.tabPanel1.getMOColor(), x);
  81.             this.sMsg = this.sDefMO;
  82.          } else {
  83.             this.sMsg = this.aMsg[x];
  84.          }
  85.  
  86.          this.oldx = x;
  87.          this.sMsg = this.sMsg.trim();
  88.          if (this.sMsg != this.sMsgOld) {
  89.             if (this.sMsg.toLowerCase().equals("none")) {
  90.                ((Applet)this).showStatus(" ");
  91.             } else {
  92.                ((Applet)this).showStatus(this.sMsg);
  93.             }
  94.  
  95.             this.sMsgOld = this.sMsg;
  96.             return;
  97.          }
  98.       } catch (ArrayIndexOutOfBoundsException var4) {
  99.       }
  100.  
  101.    }
  102.  
  103.    void tabPanel1_MouseUp(Event event) {
  104.       try {
  105.          if (!this.sMOUSECLICKSOUND.equals("none")) {
  106.             ((Applet)this).play(((Applet)this).getCodeBase(), this.sMOUSECLICKSOUND);
  107.          }
  108.       } catch (Exception var6) {
  109.       }
  110.  
  111.       try {
  112.          int iTabIx = this.tabPanel1.getCurrentPanelNdx();
  113.          this.sHref = this.aHref[iTabIx];
  114.          this.sFrame = this.aFrame[iTabIx];
  115.          this.sHref2 = this.aHref2[iTabIx];
  116.          this.sFrame2 = this.aFrame2[iTabIx];
  117.          this.sHref = this.sHref.trim();
  118.          this.sFrame = this.sFrame.trim();
  119.          this.sHref2 = this.sHref2.trim();
  120.          this.sFrame2 = this.sFrame2.trim();
  121.          if (!this.sHref.toLowerCase().equals("none")) {
  122.             try {
  123.                ((Applet)this).getAppletContext().showDocument(new URL(((Applet)this).getCodeBase(), this.sHref), this.sFrame);
  124.             } catch (MalformedURLException var4) {
  125.             }
  126.          }
  127.  
  128.          if (!this.sHref2.toLowerCase().equals("none")) {
  129.             try {
  130.                ((Applet)this).getAppletContext().showDocument(new URL(((Applet)this).getCodeBase(), this.sHref2), this.sFrame2);
  131.                return;
  132.             } catch (MalformedURLException var3) {
  133.                return;
  134.             }
  135.          }
  136.       } catch (Exception var5) {
  137.       }
  138.  
  139.    }
  140.  
  141.    public void start() {
  142.       this.field_0 = ((Component)this).getGraphics();
  143.       this.paint(this.field_0);
  144.       this.thJAVATab = new Thread(this);
  145.       this.thJAVATab.start();
  146.    }
  147.  
  148.    public void stop() {
  149.       this.thJAVATab.stop();
  150.       this.thJAVATab = null;
  151.    }
  152.  
  153.    public void paint(Graphics g) {
  154.       ++this.iLoading;
  155.       g.drawString(this.sLoading, 10, 15);
  156.       g.drawString("Loading resource No." + this.iLoading + " - Please wait", 10, 35);
  157.    }
  158.  
  159.    public void run() {
  160.       if (!this.allLoaded) {
  161.          this.constructTab();
  162.          this.tabPanel1.show(true);
  163.          if (this.iTabDefault < 999) {
  164.             this.tabPanel1.setCurrentPanelNdx(this.iTabDefault);
  165.             this.tabPanel1_MouseUp((Event)null);
  166.             return;
  167.          }
  168.  
  169.          this.tabPanel1.setCurrentPanelNdx(0);
  170.       }
  171.  
  172.    }
  173.  
  174.    public void init() {
  175.       super.init();
  176.       ((Container)this).setLayout((LayoutManager)null);
  177.       ((Panel)this).addNotify();
  178.       this.tabPanel1 = new TabPanel();
  179.       this.tabPanel1.setLayout((LayoutManager)null);
  180.       switch (this.xSwitch) {
  181.          case 0:
  182.             this.sLoading = "1st JAVA Tab - Evaluation Copy";
  183.             return;
  184.          case 1:
  185.             this.sLoading = "1st JAVA Tab - Registered";
  186.             return;
  187.          case 2:
  188.             this.sLoading = "1st JAVA Tab";
  189.             return;
  190.          case 3:
  191.             this.sLoading = "1st JAVA Navigator[Tab] - Evaluation Copy";
  192.             return;
  193.          case 4:
  194.             this.sLoading = "1st JAVA Navigator[Tab] - Registered";
  195.          default:
  196.       }
  197.    }
  198.  
  199.    private void constructTab() {
  200.       String strBG = "";
  201.  
  202.       try {
  203.          strBG = ((Applet)this).getParameter("COPYRIGHT");
  204.          if (strBG.indexOf(this.sCopyright) > 0) {
  205.             this.bCopyright = true;
  206.          } else {
  207.             this.bCopyright = false;
  208.          }
  209.       } catch (Exception var20) {
  210.       }
  211.  
  212.       try {
  213.          this.sMOUSEOVERSOUND = "none";
  214.          strBG = ((Applet)this).getParameter("MOUSEOVERSOUND");
  215.          if (strBG != null) {
  216.             this.sMOUSEOVERSOUND = strBG;
  217.          }
  218.       } catch (Exception var19) {
  219.       }
  220.  
  221.       try {
  222.          this.sMOUSECLICKSOUND = "none";
  223.          strBG = ((Applet)this).getParameter("MOUSECLICKSOUND");
  224.          if (strBG != null) {
  225.             this.sMOUSECLICKSOUND = strBG;
  226.          }
  227.       } catch (Exception var18) {
  228.       }
  229.  
  230.       try {
  231.          strBG = ((Applet)this).getParameter("TAB_BG");
  232.          if (strBG == null) {
  233.             this.iBGRed = 192;
  234.             this.iBGGreen = 192;
  235.             this.iBGBlue = 192;
  236.          } else {
  237.             this.iBGRed = this.getCOLOR(0, "TAB_BG", strBG);
  238.             this.iBGGreen = this.getCOLOR(1, "TAB_BG", strBG);
  239.             this.iBGBlue = this.getCOLOR(2, "TAB_BG", strBG);
  240.          }
  241.       } catch (Exception var17) {
  242.       }
  243.  
  244.       Dimension s = ((Component)this).size();
  245.       this.tabPanel1.reshape(0, 0, s.width, s.height);
  246.       this.tabPanel1.setBackground(new Color(this.iBGRed, this.iBGGreen, this.iBGBlue));
  247.  
  248.       try {
  249.          strBG = ((Applet)this).getParameter("TAB_FG");
  250.          if (strBG == null) {
  251.             this.iBGRed = 0;
  252.             this.iBGGreen = 0;
  253.             this.iBGBlue = 0;
  254.          } else {
  255.             this.iBGRed = this.getCOLOR(0, "TAB_FG", strBG);
  256.             this.iBGGreen = this.getCOLOR(1, "TAB_FG", strBG);
  257.             this.iBGBlue = this.getCOLOR(2, "TAB_FG", strBG);
  258.          }
  259.       } catch (Exception var16) {
  260.       }
  261.  
  262.       this.tabPanel1.setLabelColor(new Color(this.iBGRed, this.iBGGreen, this.iBGBlue));
  263.       ((Component)this).setForeground(new Color(this.iBGRed, this.iBGGreen, this.iBGBlue));
  264.  
  265.       try {
  266.          strBG = ((Applet)this).getParameter("TAB_DEFAULT");
  267.          if (strBG == null) {
  268.             this.iTabDefault = 999;
  269.          } else {
  270.             this.iTabDefault = Integer.parseInt(strBG);
  271.          }
  272.       } catch (Exception var15) {
  273.       }
  274.  
  275.       try {
  276.          strBG = ((Applet)this).getParameter("TABONBOTTOM");
  277.          if (strBG == null) {
  278.             this.tabPanel1.setTabsOnBottom(false);
  279.          } else {
  280.             this.tabPanel1.setTabsOnBottom(true);
  281.             if (strBG.toLowerCase().equals("no")) {
  282.                this.tabPanel1.setTabsOnBottom(false);
  283.             }
  284.          }
  285.       } catch (Exception var14) {
  286.       }
  287.  
  288.       try {
  289.          strBG = ((Applet)this).getParameter("TAB_FONT");
  290.          String fName = "";
  291.          String fStyle = "";
  292.          String fSize = "";
  293.          int iStyle = 0;
  294.          if (strBG != null) {
  295.             StringTokenizer parser = new StringTokenizer(strBG, ";");
  296.  
  297.             try {
  298.                fName = parser.nextToken();
  299.                fStyle = parser.nextToken();
  300.                fSize = parser.nextToken();
  301.                if (fStyle.trim().toLowerCase().equals("bold")) {
  302.                   iStyle = 1;
  303.                }
  304.  
  305.                if (fStyle.trim().toLowerCase().equals("italic")) {
  306.                   iStyle = 2;
  307.                }
  308.  
  309.                this.fFont = new Font(fName, iStyle, Integer.parseInt(fSize.trim()));
  310.             } catch (NoSuchElementException var11) {
  311.                System.out.println(strBG + " Parameter Error(1)");
  312.             } catch (Exception var12) {
  313.                System.out.println(strBG + " Parameter Error(2)");
  314.             }
  315.          }
  316.  
  317.          this.tabPanel1.setFont(this.fFont);
  318.       } catch (Exception var13) {
  319.       }
  320.  
  321.       try {
  322.          strBG = ((Applet)this).getParameter("TAB_MOUSEOVER");
  323.          if (strBG == null) {
  324.             this.iBGRed = 255;
  325.             this.iBGGreen = 0;
  326.             this.iBGBlue = 0;
  327.          } else {
  328.             this.iBGRed = this.getCOLOR(0, "TAB_MOUSEOVER", strBG);
  329.             this.iBGGreen = this.getCOLOR(1, "TAB_MOUSEOVER", strBG);
  330.             this.iBGBlue = this.getCOLOR(2, "TAB_MOUSEOVER", strBG);
  331.          }
  332.  
  333.          this.tabPanel1.setMOColor(new Color(this.iBGRed, this.iBGGreen, this.iBGBlue));
  334.       } catch (Exception var10) {
  335.       }
  336.  
  337.       try {
  338.          this.imgBG = null;
  339.          strBG = ((Applet)this).getParameter("TAB_BG_IMAGE");
  340.          if (strBG != null) {
  341.             this.imgBG = ((Applet)this).getImage(((Applet)this).getCodeBase(), strBG);
  342.             MediaTracker m = new MediaTracker(this);
  343.  
  344.             try {
  345.                m.addImage(this.imgBG, 0);
  346.                m.waitForAll();
  347.             } catch (InterruptedException var8) {
  348.                return;
  349.             }
  350.  
  351.             if (this.imgBG.getHeight(this) > 0) {
  352.                this.tabPanel1.setBGImage(this.imgBG);
  353.             }
  354.          }
  355.       } catch (Exception var9) {
  356.       }
  357.  
  358.       ((Container)this).add(this.tabPanel1);
  359.       this.tabPanel1.show(false);
  360.  
  361.       int i;
  362.       for(i = 0; ((Applet)this).getParameter("TAB" + i) != null; ++i) {
  363.       }
  364.  
  365.       this.iTabCnt = i + 1;
  366.       this.tempString = new String[this.iTabCnt];
  367.       this.aHref = new String[this.iTabCnt];
  368.       this.aFrame = new String[this.iTabCnt];
  369.       this.aHref2 = new String[this.iTabCnt];
  370.       this.aFrame2 = new String[this.iTabCnt];
  371.       this.aMsg = new String[this.iTabCnt];
  372.  
  373.       for(int var34 = 0; ((Applet)this).getParameter("TAB" + var34) != null; ++var34) {
  374.          this.workParam(((Applet)this).getParameter("TAB" + var34), var34);
  375.          this.tabPanel1.add(this.label1);
  376.          if (var34 == 0 && (this.xSwitch == 0 || this.xSwitch == 3)) {
  377.             this.tabPanel1.add(this.label1);
  378.          }
  379.       }
  380.  
  381.       if (!this.bCopyright) {
  382.          this.tempString[0] = "Copyright parameter missing";
  383.          this.aMsg[0] = "Copyright applet parameter missing in the HTML code.";
  384.       }
  385.  
  386.       this.tabPanel1.setPanelLabels(this.tempString);
  387.       this.tabPanel1.show();
  388.       this.allLoaded = true;
  389.    }
  390.  
  391.    public boolean handleEvent(Event event) {
  392.       if (event.target == this.tabPanel1 && event.id == 502) {
  393.          this.tabPanel1_MouseUp(event);
  394.          return true;
  395.       } else if (this.oldTabPanel != this.tabPanel1.getCurrentPanelNdx() && event.target == this.tabPanel1 && event.id == 503) {
  396.          this.tabPanel1_MouseMove(event);
  397.          this.oldTabPanel = this.tabPanel1.getCurrentPanelNdx();
  398.          return true;
  399.       } else {
  400.          return super.handleEvent(event);
  401.       }
  402.    }
  403.  
  404.    private int getCOLOR(int iColor, String sWhat, String sPBG) {
  405.       int iRed = 255;
  406.       int iBlue = 255;
  407.       int iGreen = 255;
  408.       StringTokenizer parser = new StringTokenizer(sPBG, ",");
  409.  
  410.       try {
  411.          String sRed = parser.nextToken();
  412.          String sGreen = parser.nextToken();
  413.          String sBlue = parser.nextToken();
  414.          iRed = Integer.parseInt(sRed);
  415.          iGreen = Integer.parseInt(sGreen);
  416.          iBlue = Integer.parseInt(sBlue);
  417.       } catch (NoSuchElementException var11) {
  418.          System.out.println(sWhat + " Parameter Error(1)");
  419.       } catch (Exception var12) {
  420.          System.out.println(sWhat + " Parameter Error(2)");
  421.       }
  422.  
  423.       switch (iColor) {
  424.          case 0:
  425.             return iRed;
  426.          case 1:
  427.             return iGreen;
  428.          case 2:
  429.             return iBlue;
  430.          default:
  431.             return 255;
  432.       }
  433.    }
  434.  
  435.    private void workParam(String sItem, int iTCnt) {
  436.       this.sHref = "None";
  437.       this.sFrame = "None";
  438.       this.sHref2 = "None";
  439.       this.sFrame2 = "None";
  440.       this.sMsg = "None";
  441.       if (sItem.substring(0, 3).equals("***")) {
  442.          this.sHref = "None";
  443.          this.sFrame = "None";
  444.          this.sHref2 = "None";
  445.          this.sFrame2 = "None";
  446.          this.sMsg = "None";
  447.       } else {
  448.          StringTokenizer parser = new StringTokenizer(sItem, ";");
  449.          int iCnt = parser.countTokens() - 4;
  450.          if (iCnt != 0 && iCnt != 2) {
  451.             System.out.println("*** Warning in parameter '" + sItem + "' - Item count is ( " + parser.countTokens() + " ) instead of ( 6 ) *** ");
  452.          }
  453.  
  454.          try {
  455.             this.sText = parser.nextToken();
  456.             this.sHref = parser.nextToken();
  457.             this.sFrame = parser.nextToken();
  458.             this.sMsg = parser.nextToken();
  459.             this.sHref2 = parser.nextToken();
  460.             this.sFrame2 = parser.nextToken();
  461.          } catch (NoSuchElementException var6) {
  462.          } catch (Exception var7) {
  463.             System.out.println(sItem + " Parameter Error(3)");
  464.          }
  465.  
  466.          if (iTCnt == 0 && (this.xSwitch == 0 || this.xSwitch == 3)) {
  467.             this.tempString[iTCnt] = "Evaluation Copy";
  468.             this.aHref[iTCnt] = "http://www.auscomp.com";
  469.             this.aFrame[iTCnt] = "_blank";
  470.             this.aHref2[iTCnt] = "None";
  471.             this.aFrame2[iTCnt] = "None";
  472.             this.aMsg[iTCnt] = this.sDefMO;
  473.          }
  474.  
  475.          if (iTCnt == 0 && this.xSwitch == 2) {
  476.             try {
  477.                this.fAuscomp = false;
  478.                if (((Applet)this).getCodeBase().equals(new URL("http://10.0.0.2/JTab/"))) {
  479.                   this.fAuscomp = true;
  480.                } else {
  481.                   if (((Applet)this).getCodeBase().equals(new URL("http://www.auscomp.com/JTab/"))) {
  482.                      this.fAuscomp = true;
  483.                   }
  484.  
  485.                   if (((Applet)this).getCodeBase().equals(new URL("http://www.auscomp.com.au/JTab/"))) {
  486.                      this.fAuscomp = true;
  487.                   }
  488.                }
  489.             } catch (MalformedURLException var5) {
  490.             }
  491.  
  492.             if (!this.fAuscomp) {
  493.                this.tempString[iTCnt] = "Illegal copy of 1st JAVA Tab";
  494.                this.aHref[iTCnt] = "http://www.auscomp.com";
  495.                this.aFrame[iTCnt] = "_blank";
  496.                this.aHref2[iTCnt] = "None";
  497.                this.aFrame2[iTCnt] = "None";
  498.                this.aMsg[iTCnt] = "Non registered copy of 1st JAVA Tab (c) 1998 Auscomp (www.auscomp.com)";
  499.                this.tabPanel1.add(this.label1);
  500.             }
  501.          }
  502.  
  503.          if (this.xSwitch == 0 || this.xSwitch == 3) {
  504.             ++iTCnt;
  505.          }
  506.  
  507.          if (this.xSwitch == 2 && !this.fAuscomp) {
  508.             ++iTCnt;
  509.          }
  510.  
  511.          this.tempString[iTCnt] = this.sText;
  512.          this.aHref[iTCnt] = this.sHref;
  513.          this.aFrame[iTCnt] = this.sFrame;
  514.          this.aHref2[iTCnt] = this.sHref2;
  515.          this.aFrame2[iTCnt] = this.sFrame2;
  516.          this.aMsg[iTCnt] = this.sMsg;
  517.       }
  518.    }
  519. }
  520.