/** * Maps * {@code JInternalFrame.addInternalFrameListener(InternalFrameListener)} * through queue */ public void addInternalFrameListener(final InternalFrameListener internalFrameListener) { runMapping(new MapVoidAction("addInternalFrameListener") { @Override public void map() { ((JInternalFrame) getSource()).addInternalFrameListener(internalFrameListener); } }); }
/** * Maps * {@code JInternalFrame.removeInternalFrameListener(InternalFrameListener)} * through queue */ public void removeInternalFrameListener(final InternalFrameListener internalFrameListener) { runMapping(new MapVoidAction("removeInternalFrameListener") { @Override public void map() { ((JInternalFrame) getSource()).removeInternalFrameListener(internalFrameListener); } }); }
@Override public Component add( Component toadd ) { Component frames[] = getAllFrames(); // we want to stagger the top left corner of the window int topleft = CASCADE_STEPSIZE * ( null == frames ? 0 : frames.length ); Component cmp = super.add( toadd ); if ( toadd instanceof JInternalFrame ) { JInternalFrame jif = JInternalFrame.class.cast( toadd ); for ( InternalFrameListener ifl : framelisteners ) { jif.addInternalFrameListener( ifl ); } if ( null != tblistener ) { jif.addInternalFrameListener( tblistener ); jif.pack(); Dimension paneSize = getSize(); toadd.setSize( paneSize.width - topleft, paneSize.height - topleft ); toadd.setLocation( topleft, topleft ); if ( jif instanceof PlaySheetFrame ) { PlaySheetFrame psf = PlaySheetFrame.class.cast( jif ); psf.addChangeListener( tblistener ); psf.addedToDesktop( this ); } toadd.setVisible( true ); } } return cmp; }
private void backupProperties(JInternalFrame frame) { oldDefaultCloseOperation = frame.getDefaultCloseOperation(); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); oldInternalFrameListeners = frame.getInternalFrameListeners(); for (InternalFrameListener listener : oldInternalFrameListeners) { frame.removeInternalFrameListener(listener); } }
/** * Get a layer's associated palette as an internal window * * @param gui the Component to place in the window * @param ifl the listener to associate with the palette * @return the frame that the palette is in */ public static JInternalFrame getPaletteInternalWindow( Component gui, String windowName, InternalFrameListener ifl) { JInternalFrame paletteWindow; // create the palette's scroll pane JScrollPane scrollPane = new JScrollPane(gui, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT); scrollPane.setAlignmentY(Component.TOP_ALIGNMENT); // create the palette internal window paletteWindow = new JInternalFrame(windowName, true, //resizable true, //closable false, //maximizable true //iconifiable ); // add a window listener that destroys the palette when // the window is closed paletteWindow.addInternalFrameListener(ifl); paletteWindow.getContentPane().add(scrollPane); paletteWindow.setOpaque(true); //layout all the components paletteWindow.pack(); return paletteWindow; }
/** * Fires the internal frame event. * * @param id identifier of the event to fire */ protected void fireInternalFrameEvent(final int id) { Object[] listeners = listenerList.getListenerList(); InternalFrameEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == InternalFrameListener.class) { if (e == null) { e = new InternalFrameEvent(this, id); } InternalFrameListener l = (InternalFrameListener) listeners[i + 1]; switch (id) { case InternalFrameEvent.INTERNAL_FRAME_ACTIVATED: l.internalFrameActivated(e); break; case InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED: l.internalFrameDeactivated(e); break; case InternalFrameEvent.INTERNAL_FRAME_ICONIFIED: l.internalFrameIconified(e); break; case InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED: l.internalFrameDeiconified(e); break; case InternalFrameEvent.INTERNAL_FRAME_CLOSING: l.internalFrameClosing(e); break; case InternalFrameEvent.INTERNAL_FRAME_OPENED: l.internalFrameOpened(e); break; case InternalFrameEvent.INTERNAL_FRAME_CLOSED: l.internalFrameClosed(e); break; } } } }
protected void postClosingEvent(final JInternalFrame frame) { // this method seems to be unused Object[] listeners = frame.getListeners(InternalFrameListener.class); InternalFrameEvent e = null; for (int i = 0; i < listeners.length; i++) { if (e == null) { e = new InternalFrameEvent( frame, InternalFrameEvent.INTERNAL_FRAME_CLOSING); } ((InternalFrameListener)listeners[i]).internalFrameClosing(e); } }
public void testAddRemoveGetInternalFrameListener() { InternalFrameListener l = new MyInternalFrameListener(); frame.addInternalFrameListener(l); InternalFrameListener[] listeners = frame.getInternalFrameListeners(); assertTrue("listener was added", contains(listeners, l)); frame.removeInternalFrameListener(l); listeners = frame.getInternalFrameListeners(); assertFalse("listener was removed", contains(listeners, l)); }
@Override public void addInternalFrameListener(InternalFrameListener l) { super.addInternalFrameListener(l); }
public void addInternalFrameListener(InternalFrameListener l) { list.add(InternalFrameListener.class, l); }
public void removeInternalFrameListener(InternalFrameListener l) { list.remove(InternalFrameListener.class, l); }
public InternalFrameListener[] getInternalFrameListeners() { return list.getListeners(InternalFrameListener.class); }
/** * This method fires an InternalFrameEvent to the listeners. * * @param id The type of event being fired. See InternalFrameEvent. */ protected void fireInternalFrameEvent(int id) { Object[] ifListeners = listenerList.getListenerList(); InternalFrameEvent evt = new InternalFrameEvent(this, id); switch (id) { case InternalFrameEvent.INTERNAL_FRAME_CLOSING: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]) .internalFrameClosing(evt); } break; case InternalFrameEvent.INTERNAL_FRAME_ACTIVATED: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]) .internalFrameActivated(evt); } break; case InternalFrameEvent.INTERNAL_FRAME_CLOSED: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]).internalFrameClosed(evt); } break; case InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]) .internalFrameDeactivated(evt); } break; case InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]) .internalFrameDeiconified(evt); } break; case InternalFrameEvent.INTERNAL_FRAME_ICONIFIED: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]) .internalFrameIconified(evt); } break; case InternalFrameEvent.INTERNAL_FRAME_OPENED: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]).internalFrameOpened(evt); } break; } }
/** * Fires an internal frame event. * * @param id the type of the event being fired; one of the following: * <ul> * <li><code>InternalFrameEvent.INTERNAL_FRAME_OPENED</code> * <li><code>InternalFrameEvent.INTERNAL_FRAME_CLOSING</code> * <li><code>InternalFrameEvent.INTERNAL_FRAME_CLOSED</code> * <li><code>InternalFrameEvent.INTERNAL_FRAME_ICONIFIED</code> * <li><code>InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED</code> * <li><code>InternalFrameEvent.INTERNAL_FRAME_ACTIVATED</code> * <li><code>InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED</code> * </ul> * If the event type is not one of the above, nothing happens. */ protected void fireInternalFrameEvent(int id){ Object[] listeners = listenerList.getListenerList(); InternalFrameEvent e = null; for (int i = listeners.length -2; i >=0; i -= 2){ if (listeners[i] == InternalFrameListener.class){ if (e == null){ e = new InternalFrameEvent(this, id); // System.out.println("InternalFrameEvent: " + e.paramString()); } switch(e.getID()) { case InternalFrameEvent.INTERNAL_FRAME_OPENED: ((InternalFrameListener)listeners[i+1]).internalFrameOpened(e); break; case InternalFrameEvent.INTERNAL_FRAME_CLOSING: ((InternalFrameListener)listeners[i+1]).internalFrameClosing(e); break; case InternalFrameEvent.INTERNAL_FRAME_CLOSED: ((InternalFrameListener)listeners[i+1]).internalFrameClosed(e); break; case InternalFrameEvent.INTERNAL_FRAME_ICONIFIED: ((InternalFrameListener)listeners[i+1]).internalFrameIconified(e); break; case InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED: ((InternalFrameListener)listeners[i+1]).internalFrameDeiconified(e); break; case InternalFrameEvent.INTERNAL_FRAME_ACTIVATED: ((InternalFrameListener)listeners[i+1]).internalFrameActivated(e); break; case InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED: ((InternalFrameListener)listeners[i+1]).internalFrameDeactivated(e); break; default: break; } } } /* we could do it off the event, but at the moment, that's not how I'm implementing it */ // if (id == InternalFrameEvent.INTERNAL_FRAME_CLOSING) { // doDefaultCloseAction(); // } }
/** * Get a layer's associated palette as an internal window * * @param layer the layer to get the palette for * @param ifl the listener to associate with the palette * @return the frame that the palette is in */ public static JInternalFrame getPaletteInternalWindow( Layer layer, InternalFrameListener ifl) { return getPaletteInternalWindow(layer.getGUI(), layer.getName() + " Palette", ifl); }
/** * Adds the specified listener to receive internal * frame events from this internal frame. * * @param l the internal frame listener */ public void addInternalFrameListener(InternalFrameListener l) { // remind: sync ?? listenerList.add(InternalFrameListener.class, l); // remind: needed? enableEvents(0); // turn on the newEventsOnly flag in Component. }
/** * Removes the specified internal frame listener so that it no longer * receives internal frame events from this internal frame. * * @param l the internal frame listener */ public void removeInternalFrameListener(InternalFrameListener l) { // remind: sync?? listenerList.remove(InternalFrameListener.class, l); }
/** * Returns an array of all the <code>InternalFrameListener</code>s added * to this <code>JInternalFrame</code> with * <code>addInternalFrameListener</code>. * * @return all of the <code>InternalFrameListener</code>s added or an empty * array if no listeners have been added * @since 1.4 * * @see #addInternalFrameListener */ public InternalFrameListener[] getInternalFrameListeners() { return listenerList.getListeners(InternalFrameListener.class); }