?? webshelf.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 + -