1 19 package org.lucane.applications.slideshow.gui; 20 21 import java.awt.BorderLayout ; 22 import java.awt.Dimension ; 23 import java.awt.Image ; 24 import java.awt.event.WindowEvent ; 25 import java.awt.event.WindowListener ; 26 27 import javax.swing.JLabel ; 28 import javax.swing.JList ; 29 import javax.swing.JPanel ; 30 import javax.swing.JProgressBar ; 31 import javax.swing.JScrollPane ; 32 import javax.swing.JSplitPane ; 33 import javax.swing.event.ListSelectionEvent ; 34 import javax.swing.event.ListSelectionListener ; 35 36 import org.lucane.applications.slideshow.SlideShow; 37 import org.lucane.client.widgets.ManagedWindow; 38 39 public class StarterWindow extends ManagedWindow 40 implements ListSelectionListener , WindowListener 41 { 42 private SlideShow plugin; 43 private JList thumbnails; 44 private JList users; 45 private ImageComponent image; 46 private JSplitPane split; 47 private JLabel statusLabel; 48 private JProgressBar statusBar; 49 50 public StarterWindow(SlideShow owner) 51 { 52 super(owner, owner.getTitle()); 53 setName("starter"); 54 setExitPluginOnClose(true); 55 addWindowListener(this); 56 57 this.plugin = owner; 58 59 60 thumbnails = new JList (); 61 thumbnails.setCellRenderer(new ImageRenderer()); 62 thumbnails.addListSelectionListener(this); 63 getContentPane().add(new JScrollPane (thumbnails), BorderLayout.WEST); 64 65 image = new ImageComponent(); 66 users = new JList (); 67 split = new JSplitPane (JSplitPane.HORIZONTAL_SPLIT, new JScrollPane (image), new JScrollPane (users)); 68 split.setName("startersplit"); 69 getContentPane().add(split, BorderLayout.CENTER); 70 manageWidget(split); 71 72 statusLabel = new JLabel (); 73 statusLabel.setHorizontalAlignment(JLabel.RIGHT); 74 statusBar = new JProgressBar (); 75 JPanel status = new JPanel (new BorderLayout ()); 76 status.add(statusLabel, BorderLayout.CENTER); 77 status.add(statusBar, BorderLayout.EAST); 78 getContentPane().add(status, BorderLayout.SOUTH); 79 80 81 split.setDividerLocation(300); 82 setPreferredSize(new Dimension (600, 400)); 83 } 84 85 public void setImages(Object [] images) 86 { 87 thumbnails.setListData(images); 88 } 89 90 public void setUsers(Object [] names) 91 { 92 users.setListData(names); 93 94 statusBar.setMaximum((names.length-1)*2); 97 } 98 99 public void initStatus(String msg) 100 { 101 statusLabel.setText(msg); 102 statusBar.setValue(0); 103 } 104 105 public void doProgress() 106 { 107 statusBar.setValue(statusBar.getValue()+1); 108 if(statusBar.getValue() == statusBar.getMaximum()) 109 initStatus(""); 110 } 111 112 114 public void valueChanged(ListSelectionEvent lse) 115 { 116 if(thumbnails.getSelectedIndex() >= 0) 117 { 118 Image picture = (Image )thumbnails.getSelectedValue(); 119 if(image.getImage() != picture) 120 { 121 image.setImage(picture); 122 image.repaint(); 123 plugin.getServer().sendImage(picture); 124 } 125 } 126 } 127 128 public void windowActivated(WindowEvent e) {} 129 public void windowClosed(WindowEvent e) {} 130 public void windowDeactivated(WindowEvent e) {} 131 public void windowDeiconified(WindowEvent e) {} 132 public void windowIconified(WindowEvent e) {} 133 public void windowOpened(WindowEvent e) {} 134 public void windowClosing(WindowEvent e) 135 { 136 plugin.getServer().disconnect(); 137 } 138 } | Popular Tags |