⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webshelf.java

📁 这个出色的小程序可以把你的网站上的链接
💻 JAVA
字号:

package ru.sakva.bsh;

 import java.applet.*;
 import java.awt.*;
 import java.awt.event.*;
 import java.awt.image.*;
 import java.net.*;
 import java.io.*;
 import java.util.*;

/** WebShelf extends and substitutes Shelf functions for
   "cooperation" with Browser (open new windows, load links, etc.) */

 public class Webshelf extends Shelf
/* * */ { /* * */
 int n;

 String docFrame = "_parent";
 Button b;

 public void init()
{
icons=new Hashtable();
 String par;
 getParams();
 if((par=getParameter("frame"))!=null)docFrame=new String(par);
 addComponentListener(this);
 addMouseListener(this);
 addMouseMotionListener(this);
 }

 public void start()
{
 refresh();
 }

 public synchronized String getBooksCount()
{ if(books==null)return "0"; return Integer.toString(books.length); }

 public void setDocFrame(String s){ docFrame = new String(s); }

 public void select(int i,int mod)
{
 if(books== null || i < 0 || i >= books.length)return;

 Book book=books[i];

 if(book != null)
   {
    if((book.selected=!book.selected)==true)
      {
       book.selected = true;
       try
         {
          URL url = new URL(getDocumentBase(),((WebBook)book).ref);
          getAppletContext().showDocument(url,docFrame);
          } catch(Exception e){ }
       }
    int j=0; while(j < books.length){ if(j != i)books[j].selected=false; j++; }
    }
 refresh();
 }

 public void reserve(int k)
{ books = new WebBook[k]; int i=0; while(i < k)books[i++]=new WebBook(); }

 public void reserve(String s){ reserve(Integer.parseInt(s)); n=0; }

 public void putBook(String t,String ref)
{ if(n < books.length)books[n++] = new WebBook(t,ref); }


 public void mousePressed(MouseEvent me)
{
//   Will be used in future for editing bookshelf
// if( (me.getModifiers() & InputEvent.BUTTON3_MASK)!=0)
//   {
//    if(taken == null)
//      {
//       msU=me.getX(); msV=me.getY();
//       takenNum = getBookIndex(msU,msV);
//       if(0 <= takenNum && takenNum < books.length)
//         {
//          taken=books[takenNum]; books[takenNum]=null;
//          refresh();
//          }
//       }
//    }
 }

 public void mouseReleased(MouseEvent me)
{
 if( (me.getModifiers() & InputEvent.BUTTON3_MASK)==0)
   {
    int i=getBookIndex(me.getX(),me.getY());
    select(i,me.getModifiers());
    refresh();
    }
// else    //  Will be used in future for editing bookshelf
//   {
//    if(taken != null)
//      {
//       books[takenNum]=taken; taken=null; 
//       refresh();
//       }
//    }
 }

 public void mouseDragged(MouseEvent me)
{
//   Will be used in future for editing bookshelf
// if( (me.getModifiers() & InputEvent.BUTTON3_MASK)!=0)
//   {
//    if(taken != null)
//      {
//       taken.u=me.getX()-taken.b/2; taken.v=me.getY();
//       repaint();
//       }
//    }
 }

/* * */ } /* * */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -