Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package grafeditor.actions;
- import java.awt.datatransfer.Transferable;
- import java.util.EventObject;
- public class ClipboardEvent extends EventObject{
- protected Transferable newContent;
- //clipboar je source za cl.event
- public ClipboardEvent(Object source) {
- super(source);
- // TODO Auto-generated constructor stub
- }
- public Transferable getNewContent() {
- return newContent;
- }
- public void setNewContent(Transferable newContent) {
- this.newContent = newContent;
- }
- }
- --------------------
- package grafeditor.actions;
- import java.util.EventListener;
- public interface ClipboardListener extends EventListener{
- public void clipboardContentChange(ClipboardEvent c_event);
- }
- --------------------------
- package grafeditor.actions;
- import grafeditor.event.UpdateEvent;
- import grafeditor.event.UpdateListener;
- import java.awt.datatransfer.Clipboard;
- import java.awt.datatransfer.ClipboardOwner;
- import java.awt.datatransfer.Transferable;
- import javax.swing.event.EventListenerList;
- public class IspaljivacDogadjaja extends Clipboard{
- transient EventListenerList listenerList = new EventListenerList();
- public IspaljivacDogadjaja(String name) {
- super(name);
- // TODO Auto-generated constructor stub
- }
- public void addUpdateListener(ClipboardListener l) {
- listenerList.add(ClipboardListener.class, l);
- }
- public void removeUpdateListener(ClipboardListener l) {
- listenerList.remove(ClipboardListener.class, l);
- }
- /**
- * Javljamo svim listenerima da se događaj desio
- */
- protected void fireUpdatePerformed(ClipboardEvent e) {
- Object[] listeners = listenerList.getListenerList();
- for (int i = listeners.length-2; i>=0; i-=2) {
- if (listeners[i]==ClipboardListener.class) {
- ((ClipboardListener)listeners[i+1]).clipboardContentChange(e);
- }
- }
- }
- @Override
- public synchronized void setContents(Transferable contents,ClipboardOwner owner) {
- // TODO Auto-generated method stub
- super.setContents(contents, owner);
- ClipboardEvent e = new ClipboardEvent(this);
- e.setNewContent(contents);
- fireUpdatePerformed(e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement