import java.applet.Applet; import java.awt.*; import java.awt.event.*; //**************************************************************** //html Interface; // // // // //****************************************************************/ public class album4 extends Applet implements ActionListener, Runnable,AdjustmentListener { Thread myth; Button btnAon = new Button("自動"); Button btnAoff = new Button("停止"); Scrollbar sb = new Scrollbar(Scrollbar.HORIZONTAL,1,1,0,14); Scrollbar sb1 = new Scrollbar(Scrollbar.HORIZONTAL,1,1,1,10); Label lblTitle; Panel myPanel; GridBagLayout gb = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); Image[] myImg; String[] myComment; double w,h; String s; int crntNo; int maxNo; int t = 1; int f = 0; public void init(){ maxNo = Integer.parseInt(getParameter("no")); myImg = new Image[maxNo]; myComment = new String[maxNo]; crntNo = 0; MediaTracker mt = new MediaTracker(this); for (int count =0; count < maxNo; count++){ s = getParameter("file"+count); myComment[count] = s.substring(0,s.indexOf(',')); myImg[count] = getImage(getDocumentBase(),s.substring(s.indexOf(',')+1,s.length())); mt.addImage(myImg[count], 0); try{mt.waitForAll();} catch (InterruptedException e1){} } sb = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,maxNo); lblTitle = new Label("",Label.CENTER); setLayout(gb); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 20; gb.setConstraints(sb,gbc); gbc.weightx = 1; gb.setConstraints(btnAon,gbc); gbc.weightx = 1; gb.setConstraints(btnAoff,gbc); gbc.weightx = 1; gb.setConstraints(sb1,gbc); myPanel = new Panel(); myPanel.setLayout(gb); myPanel.add(sb); myPanel.add(btnAon); myPanel.add(btnAoff); myPanel.add(sb1); setLayout(new BorderLayout()); add ("North",lblTitle); add ("South",myPanel); sb.setUnitIncrement(1); sb.setBlockIncrement(3); sb1.setUnitIncrement(1); sb1.setBlockIncrement(1); sb.addAdjustmentListener(this); sb1.addAdjustmentListener(this); btnAon.addActionListener(this); btnAoff.addActionListener(this); } public void adjustmentValueChanged(AdjustmentEvent r){ if(r.getSource()==sb){ crntNo = sb.getValue(); repaint(); } if(r.getSource()==sb1){ t = sb1.getValue(); } } public void actionPerformed(ActionEvent e) { if(e.getSource() == btnAon ){f=1;} if(e.getSource() == btnAoff ){f=0;} } public void start(){ if (myth == null){ myth = new Thread(this); myth.start(); } } public void stop() { if (myth != null){ // myth.stop(); myth = null; } } public void destroy() {} public void run(){ while (true) { try{myth.sleep(1000*t);} catch(InterruptedException q){} if (f !=0) { if (crntNo