feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,104 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
/**
* An event reported to a child component that originated from an
* ancestor in the component hierarchy.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Dave Moore
*/
@SuppressWarnings("serial")
public class AncestorEvent extends AWTEvent {
/**
* An ancestor-component was added to the hierarchy of
* visible objects (made visible), and is currently being displayed.
*/
public static final int ANCESTOR_ADDED = 1;
/**
* An ancestor-component was removed from the hierarchy
* of visible objects (hidden) and is no longer being displayed.
*/
public static final int ANCESTOR_REMOVED = 2;
/** An ancestor-component changed its position on the screen. */
public static final int ANCESTOR_MOVED = 3;
Container ancestor;
Container ancestorParent;
/**
* Constructs an AncestorEvent object to identify a change
* in an ancestor-component's display-status.
*
* @param source the JComponent that originated the event
* (typically <code>this</code>)
* @param id an int specifying {@link #ANCESTOR_ADDED},
* {@link #ANCESTOR_REMOVED} or {@link #ANCESTOR_MOVED}
* @param ancestor a Container object specifying the ancestor-component
* whose display-status changed
* @param ancestorParent a Container object specifying the ancestor's parent
*/
public AncestorEvent(JComponent source, int id, Container ancestor, Container ancestorParent) {
super(source, id);
this.ancestor = ancestor;
this.ancestorParent = ancestorParent;
}
/**
* Returns the ancestor that the event actually occurred on.
*/
public Container getAncestor() {
return ancestor;
}
/**
* Returns the parent of the ancestor the event actually occurred on.
* This is most interesting in an ANCESTOR_REMOVED event, as
* the ancestor may no longer be in the component hierarchy.
*/
public Container getAncestorParent() {
return ancestorParent;
}
/**
* Returns the component that the listener was added to.
*/
public JComponent getComponent() {
return (JComponent)getSource();
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;
/**
* AncestorListener
*
* Interface to support notification when changes occur to a JComponent or one
* of its ancestors. These include movement and when the component becomes
* visible or invisible, either by the setVisible() method or by being added
* or removed from the component hierarchy.
*
* @author Dave Moore
*/
public interface AncestorListener extends EventListener {
/**
* Called when the source or one of its ancestors is made visible
* either by setVisible(true) being called or by its being
* added to the component hierarchy. The method is only called
* if the source has actually become visible. For this to be true
* all its parents must be visible and it must be in a hierarchy
* rooted at a Window
*/
public void ancestorAdded(AncestorEvent event);
/**
* Called when the source or one of its ancestors is made invisible
* either by setVisible(false) being called or by its being
* remove from the component hierarchy. The method is only called
* if the source has actually become invisible. For this to be true
* at least one of its parents must by invisible or it is not in
* a hierarchy rooted at a Window
*/
public void ancestorRemoved(AncestorEvent event);
/**
* Called when either the source or one of its ancestors is moved.
*/
public void ancestorMoved(AncestorEvent event);
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventObject;
/**
* CaretEvent is used to notify interested parties that
* the text caret has changed in the event source.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Timothy Prinzing
*/
public abstract class CaretEvent extends EventObject {
/**
* Creates a new CaretEvent object.
*
* @param source the object responsible for the event
*/
public CaretEvent(Object source) {
super(source);
}
/**
* Fetches the location of the caret.
*
* @return the dot &gt;= 0
*/
public abstract int getDot();
/**
* Fetches the location of other end of a logical
* selection. If there is no selection, this
* will be the same as dot.
*
* @return the mark &gt;= 0
*/
public abstract int getMark();
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* Listener for changes in the caret position of a text
* component.
*
* @author Timothy Prinzing
*/
public interface CaretListener extends EventListener {
/**
* Called when the caret position is updated.
*
* @param e the caret event
*/
void caretUpdate(CaretEvent e);
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import javax.swing.event.ChangeEvent;
import java.util.EventListener;
/**
* CellEditorListener defines the interface for an object that listens
* to changes in a CellEditor
*
* @author Alan Chung
*/
public interface CellEditorListener extends java.util.EventListener {
/** This tells the listeners the editor has ended editing */
public void editingStopped(ChangeEvent e);
/** This tells the listeners the editor has canceled editing */
public void editingCanceled(ChangeEvent e);
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventObject;
/**
* ChangeEvent is used to notify interested parties that
* state has changed in the event source.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Jeff Dinkins
*/
@SuppressWarnings("serial")
public class ChangeEvent extends EventObject {
/**
* Constructs a ChangeEvent object.
*
* @param source the Object that is the source of the event
* (typically <code>this</code>)
*/
public ChangeEvent(Object source) {
super(source);
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* Defines an object which listens for ChangeEvents.
*
* @author Jeff Dinkins
*/
public interface ChangeListener extends EventListener {
/**
* Invoked when the target of the listener has changed its state.
*
* @param e a ChangeEvent object
*/
void stateChanged(ChangeEvent e);
}

View File

@@ -0,0 +1,183 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import javax.swing.undo.*;
import javax.swing.text.*;
/**
* Interface for document change notifications. This provides
* detailed information to Document observers about how the
* Document changed. It provides high level information such
* as type of change and where it occurred, as well as the more
* detailed structural changes (What Elements were inserted and
* removed).
*
* @author Timothy Prinzing
* @see javax.swing.text.Document
* @see DocumentListener
*/
public interface DocumentEvent {
/**
* Returns the offset within the document of the start
* of the change.
*
* @return the offset &gt;= 0
*/
public int getOffset();
/**
* Returns the length of the change.
*
* @return the length &gt;= 0
*/
public int getLength();
/**
* Gets the document that sourced the change event.
*
* @return the document
*/
public Document getDocument();
/**
* Gets the type of event.
*
* @return the type
*/
public EventType getType();
/**
* Gets the change information for the given element.
* The change information describes what elements were
* added and removed and the location. If there were
* no changes, null is returned.
* <p>
* This method is for observers to discover the structural
* changes that were made. This means that only elements
* that existed prior to the mutation (and still exist after
* the mutation) need to have ElementChange records.
* The changes made available need not be recursive.
* <p>
* For example, if the an element is removed from it's
* parent, this method should report that the parent
* changed and provide an ElementChange implementation
* that describes the change to the parent. If the
* child element removed had children, these elements
* do not need to be reported as removed.
* <p>
* If an child element is insert into a parent element,
* the parent element should report a change. If the
* child element also had elements inserted into it
* (grandchildren to the parent) these elements need
* not report change.
*
* @param elem the element
* @return the change information, or null if the
* element was not modified
*/
public ElementChange getChange(Element elem);
/**
* Enumeration for document event types
*/
public static final class EventType {
private EventType(String s) {
typeString = s;
}
/**
* Insert type.
*/
public static final EventType INSERT = new EventType("INSERT");
/**
* Remove type.
*/
public static final EventType REMOVE = new EventType("REMOVE");
/**
* Change type.
*/
public static final EventType CHANGE = new EventType("CHANGE");
/**
* Converts the type to a string.
*
* @return the string
*/
public String toString() {
return typeString;
}
private String typeString;
}
/**
* Describes changes made to a specific element.
*/
public interface ElementChange {
/**
* Returns the element represented. This is the element
* that was changed.
*
* @return the element
*/
public Element getElement();
/**
* Fetches the index within the element represented.
* This is the location that children were added
* and/or removed.
*
* @return the index &gt;= 0
*/
public int getIndex();
/**
* Gets the child elements that were removed from the
* given parent element. The element array returned is
* sorted in the order that the elements used to lie in
* the document, and must be contiguous.
*
* @return the child elements
*/
public Element[] getChildrenRemoved();
/**
* Gets the child elements that were added to the given
* parent element. The element array returned is in the
* order that the elements lie in the document, and must
* be contiguous.
*
* @return the child elements
*/
public Element[] getChildrenAdded();
}
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* Interface for an observer to register to receive notifications
* of changes to a text document.
* <p>
* The default implementation of
* the Document interface (AbstractDocument) supports asynchronous
* mutations. If this feature is used (i.e. mutations are made
* from a thread other than the Swing event thread), the listeners
* will be notified via the mutating thread. <em>This means that
* if asynchronous updates are made, the implementation of this
* interface must be threadsafe</em>!
* <p>
* The DocumentEvent notification is based upon the JavaBeans
* event model. There is no guarantee about the order of delivery
* to listeners, and all listeners must be notified prior to making
* further mutations to the Document. <em>This means implementations
* of the DocumentListener may not mutate the source of the event
* (i.e. the associated Document)</em>.
*
* @author Timothy Prinzing
* @see javax.swing.text.Document
* @see javax.swing.text.StyledDocument
* @see DocumentEvent
*/
public interface DocumentListener extends EventListener {
/**
* Gives notification that there was an insert into the document. The
* range given by the DocumentEvent bounds the freshly inserted region.
*
* @param e the document event
*/
public void insertUpdate(DocumentEvent e);
/**
* Gives notification that a portion of the document has been
* removed. The range is given in terms of what the view last
* saw (that is, before updating sticky positions).
*
* @param e the document event
*/
public void removeUpdate(DocumentEvent e);
/**
* Gives notification that an attribute or set of attributes changed.
*
* @param e the document event
*/
public void changedUpdate(DocumentEvent e);
}

View File

@@ -0,0 +1,294 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.io.*;
import java.util.*;
import java.lang.reflect.Array;
import sun.reflect.misc.ReflectUtil;
/**
* A class that holds a list of EventListeners. A single instance
* can be used to hold all listeners (of all types) for the instance
* using the list. It is the responsiblity of the class using the
* EventListenerList to provide type-safe API (preferably conforming
* to the JavaBeans spec) and methods which dispatch event notification
* methods to appropriate Event Listeners on the list.
*
* The main benefits that this class provides are that it is relatively
* cheap in the case of no listeners, and it provides serialization for
* event-listener lists in a single place, as well as a degree of MT safety
* (when used correctly).
*
* Usage example:
* Say one is defining a class that sends out FooEvents, and one wants
* to allow users of the class to register FooListeners and receive
* notification when FooEvents occur. The following should be added
* to the class definition:
* <pre>
* EventListenerList listenerList = new EventListenerList();
* FooEvent fooEvent = null;
*
* public void addFooListener(FooListener l) {
* listenerList.add(FooListener.class, l);
* }
*
* public void removeFooListener(FooListener l) {
* listenerList.remove(FooListener.class, l);
* }
*
*
* // Notify all listeners that have registered interest for
* // notification on this event type. The event instance
* // is lazily created using the parameters passed into
* // the fire method.
*
* protected void fireFooXXX() {
* // Guaranteed to return a non-null array
* Object[] listeners = listenerList.getListenerList();
* // Process the listeners last to first, notifying
* // those that are interested in this event
* for (int i = listeners.length-2; i&gt;=0; i-=2) {
* if (listeners[i]==FooListener.class) {
* // Lazily create the event:
* if (fooEvent == null)
* fooEvent = new FooEvent(this);
* ((FooListener)listeners[i+1]).fooXXX(fooEvent);
* }
* }
* }
* </pre>
* foo should be changed to the appropriate name, and fireFooXxx to the
* appropriate method name. One fire method should exist for each
* notification method in the FooListener interface.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Georges Saab
* @author Hans Muller
* @author James Gosling
*/
@SuppressWarnings("serial")
public class EventListenerList implements Serializable {
/* A null array to be shared by all empty listener lists*/
private final static Object[] NULL_ARRAY = new Object[0];
/* The list of ListenerType - Listener pairs */
protected transient Object[] listenerList = NULL_ARRAY;
/**
* Passes back the event listener list as an array
* of ListenerType-listener pairs. Note that for
* performance reasons, this implementation passes back
* the actual data structure in which the listener data
* is stored internally!
* This method is guaranteed to pass back a non-null
* array, so that no null-checking is required in
* fire methods. A zero-length array of Object should
* be returned if there are currently no listeners.
*
* WARNING!!! Absolutely NO modification of
* the data contained in this array should be made -- if
* any such manipulation is necessary, it should be done
* on a copy of the array returned rather than the array
* itself.
*/
public Object[] getListenerList() {
return listenerList;
}
/**
* Return an array of all the listeners of the given type.
* @return all of the listeners of the specified type.
* @exception ClassCastException if the supplied class
* is not assignable to EventListener
*
* @since 1.3
*/
public <T extends EventListener> T[] getListeners(Class<T> t) {
Object[] lList = listenerList;
int n = getListenerCount(lList, t);
T[] result = (T[])Array.newInstance(t, n);
int j = 0;
for (int i = lList.length-2; i>=0; i-=2) {
if (lList[i] == t) {
result[j++] = (T)lList[i+1];
}
}
return result;
}
/**
* Returns the total number of listeners for this listener list.
*/
public int getListenerCount() {
return listenerList.length/2;
}
/**
* Returns the total number of listeners of the supplied type
* for this listener list.
*/
public int getListenerCount(Class<?> t) {
Object[] lList = listenerList;
return getListenerCount(lList, t);
}
private int getListenerCount(Object[] list, Class t) {
int count = 0;
for (int i = 0; i < list.length; i+=2) {
if (t == (Class)list[i])
count++;
}
return count;
}
/**
* Adds the listener as a listener of the specified type.
* @param t the type of the listener to be added
* @param l the listener to be added
*/
public synchronized <T extends EventListener> void add(Class<T> t, T l) {
if (l==null) {
// In an ideal world, we would do an assertion here
// to help developers know they are probably doing
// something wrong
return;
}
if (!t.isInstance(l)) {
throw new IllegalArgumentException("Listener " + l +
" is not of type " + t);
}
if (listenerList == NULL_ARRAY) {
// if this is the first listener added,
// initialize the lists
listenerList = new Object[] { t, l };
} else {
// Otherwise copy the array and add the new listener
int i = listenerList.length;
Object[] tmp = new Object[i+2];
System.arraycopy(listenerList, 0, tmp, 0, i);
tmp[i] = t;
tmp[i+1] = l;
listenerList = tmp;
}
}
/**
* Removes the listener as a listener of the specified type.
* @param t the type of the listener to be removed
* @param l the listener to be removed
*/
public synchronized <T extends EventListener> void remove(Class<T> t, T l) {
if (l ==null) {
// In an ideal world, we would do an assertion here
// to help developers know they are probably doing
// something wrong
return;
}
if (!t.isInstance(l)) {
throw new IllegalArgumentException("Listener " + l +
" is not of type " + t);
}
// Is l on the list?
int index = -1;
for (int i = listenerList.length-2; i>=0; i-=2) {
if ((listenerList[i]==t) && (listenerList[i+1].equals(l) == true)) {
index = i;
break;
}
}
// If so, remove it
if (index != -1) {
Object[] tmp = new Object[listenerList.length-2];
// Copy the list up to index
System.arraycopy(listenerList, 0, tmp, 0, index);
// Copy from two past the index, up to
// the end of tmp (which is two elements
// shorter than the old list)
if (index < tmp.length)
System.arraycopy(listenerList, index+2, tmp, index,
tmp.length - index);
// set the listener array to the new array or null
listenerList = (tmp.length == 0) ? NULL_ARRAY : tmp;
}
}
// Serialization support.
private void writeObject(ObjectOutputStream s) throws IOException {
Object[] lList = listenerList;
s.defaultWriteObject();
// Save the non-null event listeners:
for (int i = 0; i < lList.length; i+=2) {
Class<?> t = (Class)lList[i];
EventListener l = (EventListener)lList[i+1];
if ((l!=null) && (l instanceof Serializable)) {
s.writeObject(t.getName());
s.writeObject(l);
}
}
s.writeObject(null);
}
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
listenerList = NULL_ARRAY;
s.defaultReadObject();
Object listenerTypeOrNull;
while (null != (listenerTypeOrNull = s.readObject())) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
EventListener l = (EventListener)s.readObject();
String name = (String) listenerTypeOrNull;
ReflectUtil.checkPackageAccess(name);
add((Class<EventListener>)Class.forName(name, true, cl), l);
}
}
/**
* Returns a string representation of the EventListenerList.
*/
public String toString() {
Object[] lList = listenerList;
String s = "EventListenerList: ";
s += lList.length/2 + " listeners: ";
for (int i = 0 ; i <= lList.length-2 ; i+=2) {
s += " type " + ((Class)lList[i]).getName();
s += " listener " + lList[i+1];
}
return s;
}
}

View File

@@ -0,0 +1,228 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.awt.event.InputEvent;
import java.util.EventObject;
import java.net.URL;
import javax.swing.text.Element;
/**
* HyperlinkEvent is used to notify interested parties that
* something has happened with respect to a hypertext link.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Timothy Prinzing
*/
public class HyperlinkEvent extends EventObject {
/**
* Creates a new object representing a hypertext link event.
* The other constructor is preferred, as it provides more
* information if a URL could not be formed. This constructor
* is primarily for backward compatibility.
*
* @param source the object responsible for the event
* @param type the event type
* @param u the affected URL
*/
public HyperlinkEvent(Object source, EventType type, URL u) {
this(source, type, u, null);
}
/**
* Creates a new object representing a hypertext link event.
*
* @param source the object responsible for the event
* @param type the event type
* @param u the affected URL. This may be null if a valid URL
* could not be created.
* @param desc the description of the link. This may be useful
* when attempting to form a URL resulted in a MalformedURLException.
* The description provides the text used when attempting to form the
* URL.
*/
public HyperlinkEvent(Object source, EventType type, URL u, String desc) {
this(source, type, u, desc, null);
}
/**
* Creates a new object representing a hypertext link event.
*
* @param source the object responsible for the event
* @param type the event type
* @param u the affected URL. This may be null if a valid URL
* could not be created.
* @param desc the description of the link. This may be useful
* when attempting to form a URL resulted in a MalformedURLException.
* The description provides the text used when attempting to form the
* URL.
* @param sourceElement Element in the Document representing the
* anchor
* @since 1.4
*/
public HyperlinkEvent(Object source, EventType type, URL u, String desc,
Element sourceElement) {
super(source);
this.type = type;
this.u = u;
this.desc = desc;
this.sourceElement = sourceElement;
}
/**
* Creates a new object representing a hypertext link event.
*
* @param source the object responsible for the event
* @param type the event type
* @param u the affected URL. This may be null if a valid URL
* could not be created.
* @param desc the description of the link. This may be useful
* when attempting to form a URL resulted in a MalformedURLException.
* The description provides the text used when attempting to form the
* URL.
* @param sourceElement Element in the Document representing the
* anchor
* @param inputEvent InputEvent that triggered the hyperlink event
* @since 1.7
*/
public HyperlinkEvent(Object source, EventType type, URL u, String desc,
Element sourceElement, InputEvent inputEvent) {
super(source);
this.type = type;
this.u = u;
this.desc = desc;
this.sourceElement = sourceElement;
this.inputEvent = inputEvent;
}
/**
* Gets the type of event.
*
* @return the type
*/
public EventType getEventType() {
return type;
}
/**
* Get the description of the link as a string.
* This may be useful if a URL can't be formed
* from the description, in which case the associated
* URL would be null.
*/
public String getDescription() {
return desc;
}
/**
* Gets the URL that the link refers to.
*
* @return the URL
*/
public URL getURL() {
return u;
}
/**
* Returns the <code>Element</code> that corresponds to the source of the
* event. This will typically be an <code>Element</code> representing
* an anchor. If a constructor that is used that does not specify a source
* <code>Element</code>, or null was specified as the source
* <code>Element</code>, this will return null.
*
* @return Element indicating source of event, or null
* @since 1.4
*/
public Element getSourceElement() {
return sourceElement;
}
/**
* Returns the {@code InputEvent} that triggered the hyperlink event.
* This will typically be a {@code MouseEvent}. If a constructor is used
* that does not specify an {@code InputEvent}, or @{code null}
* was specified as the {@code InputEvent}, this returns {@code null}.
*
* @return InputEvent that triggered the hyperlink event, or null
* @since 1.7
*/
public InputEvent getInputEvent() {
return inputEvent;
}
private EventType type;
private URL u;
private String desc;
private Element sourceElement;
private InputEvent inputEvent;
/**
* Defines the ENTERED, EXITED, and ACTIVATED event types, along
* with their string representations, returned by toString().
*/
public static final class EventType {
private EventType(String s) {
typeString = s;
}
/**
* Entered type.
*/
public static final EventType ENTERED = new EventType("ENTERED");
/**
* Exited type.
*/
public static final EventType EXITED = new EventType("EXITED");
/**
* Activated type.
*/
public static final EventType ACTIVATED = new EventType("ACTIVATED");
/**
* Converts the type to a string.
*
* @return the string
*/
public String toString() {
return typeString;
}
private String typeString;
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* HyperlinkListener
*
* @author Timothy Prinzing
*/
public interface HyperlinkListener extends EventListener {
/**
* Called when a hypertext link is updated.
*
* @param e the event responsible for the update
*/
void hyperlinkUpdate(HyperlinkEvent e);
}

View File

@@ -0,0 +1,79 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
/**
* An abstract adapter class for receiving internal frame events.
* The methods in this class are empty. This class exists as
* convenience for creating listener objects, and is functionally
* equivalent to the WindowAdapter class in the AWT.
* <p>
* See <a href="https://docs.oracle.com/javase/tutorial/uiswing/events/internalframelistener.html">How to Write an Internal Frame Listener</a>
* in <em>The Java Tutorial</em>
*
* @see InternalFrameEvent
* @see InternalFrameListener
* @see java.awt.event.WindowListener
*
* @author Thomas Ball
*/
public abstract class InternalFrameAdapter implements InternalFrameListener {
/**
* Invoked when an internal frame has been opened.
*/
public void internalFrameOpened(InternalFrameEvent e) {}
/**
* Invoked when an internal frame is in the process of being closed.
* The close operation can be overridden at this point.
*/
public void internalFrameClosing(InternalFrameEvent e) {}
/**
* Invoked when an internal frame has been closed.
*/
public void internalFrameClosed(InternalFrameEvent e) {}
/**
* Invoked when an internal frame is iconified.
*/
public void internalFrameIconified(InternalFrameEvent e) {}
/**
* Invoked when an internal frame is de-iconified.
*/
public void internalFrameDeiconified(InternalFrameEvent e) {}
/**
* Invoked when an internal frame is activated.
*/
public void internalFrameActivated(InternalFrameEvent e) {}
/**
* Invoked when an internal frame is de-activated.
*/
public void internalFrameDeactivated(InternalFrameEvent e) {}
}

View File

@@ -0,0 +1,192 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.awt.AWTEvent;
import javax.swing.JInternalFrame;
/**
* An <code>AWTEvent</code> that adds support for
* <code>JInternalFrame</code> objects as the event source. This class has the
* same event types as <code>WindowEvent</code>,
* although different IDs are used.
* Help on handling internal frame events
* is in
* <a href="https://docs.oracle.com/javase/tutorial/uiswing/events/internalframelistener.html" target="_top">How to Write an Internal Frame Listener</a>,
* a section in <em>The Java Tutorial</em>.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see java.awt.event.WindowEvent
* @see java.awt.event.WindowListener
* @see JInternalFrame
* @see InternalFrameListener
*
* @author Thomas Ball
*/
public class InternalFrameEvent extends AWTEvent {
/**
* The first number in the range of IDs used for internal frame events.
*/
public static final int INTERNAL_FRAME_FIRST = 25549;
/**
* The last number in the range of IDs used for internal frame events.
*/
public static final int INTERNAL_FRAME_LAST = 25555;
/**
* The "window opened" event. This event is delivered only
* the first time the internal frame is made visible.
*
* @see JInternalFrame#show
*/
public static final int INTERNAL_FRAME_OPENED = INTERNAL_FRAME_FIRST;
/**
* The "window is closing" event. This event is delivered when
* the user attempts to close the internal frame, such as by
* clicking the internal frame's close button,
* or when a program attempts to close the internal frame
* by invoking the <code>setClosed</code> method.
*
* @see JInternalFrame#setDefaultCloseOperation
* @see JInternalFrame#doDefaultCloseAction
* @see JInternalFrame#setClosed
*/
public static final int INTERNAL_FRAME_CLOSING = 1 + INTERNAL_FRAME_FIRST;
/**
* The "window closed" event. This event is delivered after
* the internal frame has been closed as the result of a call to
* the <code>setClosed</code> or
* <code>dispose</code> method.
*
* @see JInternalFrame#setClosed
* @see JInternalFrame#dispose
*/
public static final int INTERNAL_FRAME_CLOSED = 2 + INTERNAL_FRAME_FIRST;
/**
* The "window iconified" event.
* This event indicates that the internal frame
* was shrunk down to a small icon.
*
* @see JInternalFrame#setIcon
*/
public static final int INTERNAL_FRAME_ICONIFIED = 3 + INTERNAL_FRAME_FIRST;
/**
* The "window deiconified" event type. This event indicates that the
* internal frame has been restored to its normal size.
*
* @see JInternalFrame#setIcon
*/
public static final int INTERNAL_FRAME_DEICONIFIED = 4 + INTERNAL_FRAME_FIRST;
/**
* The "window activated" event type. This event indicates that keystrokes
* and mouse clicks are directed towards this internal frame.
*
* @see JInternalFrame#show
* @see JInternalFrame#setSelected
*/
public static final int INTERNAL_FRAME_ACTIVATED = 5 + INTERNAL_FRAME_FIRST;
/**
* The "window deactivated" event type. This event indicates that keystrokes
* and mouse clicks are no longer directed to the internal frame.
*
* @see JInternalFrame#setSelected
*/
public static final int INTERNAL_FRAME_DEACTIVATED = 6 + INTERNAL_FRAME_FIRST;
/**
* Constructs an <code>InternalFrameEvent</code> object.
* @param source the <code>JInternalFrame</code> object that originated the event
* @param id an integer indicating the type of event
*/
public InternalFrameEvent(JInternalFrame source, int id) {
super(source, id);
}
/**
* Returns a parameter string identifying this event.
* This method is useful for event logging and for debugging.
*
* @return a string identifying the event and its attributes
*/
public String paramString() {
String typeStr;
switch(id) {
case INTERNAL_FRAME_OPENED:
typeStr = "INTERNAL_FRAME_OPENED";
break;
case INTERNAL_FRAME_CLOSING:
typeStr = "INTERNAL_FRAME_CLOSING";
break;
case INTERNAL_FRAME_CLOSED:
typeStr = "INTERNAL_FRAME_CLOSED";
break;
case INTERNAL_FRAME_ICONIFIED:
typeStr = "INTERNAL_FRAME_ICONIFIED";
break;
case INTERNAL_FRAME_DEICONIFIED:
typeStr = "INTERNAL_FRAME_DEICONIFIED";
break;
case INTERNAL_FRAME_ACTIVATED:
typeStr = "INTERNAL_FRAME_ACTIVATED";
break;
case INTERNAL_FRAME_DEACTIVATED:
typeStr = "INTERNAL_FRAME_DEACTIVATED";
break;
default:
typeStr = "unknown type";
}
return typeStr;
}
/**
* Returns the originator of the event.
*
* @return the <code>JInternalFrame</code> object that originated the event
* @since 1.3
*/
public JInternalFrame getInternalFrame () {
return (source instanceof JInternalFrame)? (JInternalFrame)source : null;
}
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* The listener interface for receiving internal frame events.
* This class is functionally equivalent to the WindowListener class
* in the AWT.
* <p>
* See <a href="https://docs.oracle.com/javase/tutorial/uiswing/events/internalframelistener.html">How to Write an Internal Frame Listener</a>
* in <em>The Java Tutorial</em> for further documentation.
*
* @see java.awt.event.WindowListener
*
* @author Thomas Ball
*/
public interface InternalFrameListener extends EventListener {
/**
* Invoked when a internal frame has been opened.
* @see javax.swing.JInternalFrame#show
*/
public void internalFrameOpened(InternalFrameEvent e);
/**
* Invoked when an internal frame is in the process of being closed.
* The close operation can be overridden at this point.
* @see javax.swing.JInternalFrame#setDefaultCloseOperation
*/
public void internalFrameClosing(InternalFrameEvent e);
/**
* Invoked when an internal frame has been closed.
* @see javax.swing.JInternalFrame#setClosed
*/
public void internalFrameClosed(InternalFrameEvent e);
/**
* Invoked when an internal frame is iconified.
* @see javax.swing.JInternalFrame#setIcon
*/
public void internalFrameIconified(InternalFrameEvent e);
/**
* Invoked when an internal frame is de-iconified.
* @see javax.swing.JInternalFrame#setIcon
*/
public void internalFrameDeiconified(InternalFrameEvent e);
/**
* Invoked when an internal frame is activated.
* @see javax.swing.JInternalFrame#setSelected
*/
public void internalFrameActivated(InternalFrameEvent e);
/**
* Invoked when an internal frame is de-activated.
* @see javax.swing.JInternalFrame#setSelected
*/
public void internalFrameDeactivated(InternalFrameEvent e);
}

View File

@@ -0,0 +1,121 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventObject;
/**
* Defines an event that encapsulates changes to a list.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Hans Muller
*/
@SuppressWarnings("serial")
public class ListDataEvent extends EventObject
{
/** Identifies one or more changes in the lists contents. */
public static final int CONTENTS_CHANGED = 0;
/** Identifies the addition of one or more contiguous items to the list */
public static final int INTERVAL_ADDED = 1;
/** Identifies the removal of one or more contiguous items from the list */
public static final int INTERVAL_REMOVED = 2;
private int type;
private int index0;
private int index1;
/**
* Returns the event type. The possible values are:
* <ul>
* <li> {@link #CONTENTS_CHANGED}
* <li> {@link #INTERVAL_ADDED}
* <li> {@link #INTERVAL_REMOVED}
* </ul>
*
* @return an int representing the type value
*/
public int getType() { return type; }
/**
* Returns the lower index of the range. For a single
* element, this value is the same as that returned by {@link #getIndex1}.
*
* @return an int representing the lower index value
*/
public int getIndex0() { return index0; }
/**
* Returns the upper index of the range. For a single
* element, this value is the same as that returned by {@link #getIndex0}.
*
* @return an int representing the upper index value
*/
public int getIndex1() { return index1; }
/**
* Constructs a ListDataEvent object. If index0 is &gt;
* index1, index0 and index1 will be swapped such that
* index0 will always be &lt;= index1.
*
* @param source the source Object (typically <code>this</code>)
* @param type an int specifying {@link #CONTENTS_CHANGED},
* {@link #INTERVAL_ADDED}, or {@link #INTERVAL_REMOVED}
* @param index0 one end of the new interval
* @param index1 the other end of the new interval
*/
public ListDataEvent(Object source, int type, int index0, int index1) {
super(source);
this.type = type;
this.index0 = Math.min(index0, index1);
this.index1 = Math.max(index0, index1);
}
/**
* Returns a string representation of this ListDataEvent. This method
* is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not
* be <code>null</code>.
*
* @since 1.4
* @return a string representation of this ListDataEvent.
*/
public String toString() {
return getClass().getName() +
"[type=" + type +
",index0=" + index0 +
",index1=" + index1 + "]";
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* ListDataListener
*
* @author Hans Muller
*/
public interface ListDataListener extends EventListener {
/**
* Sent after the indices in the index0,index1
* interval have been inserted in the data model.
* The new interval includes both index0 and index1.
*
* @param e a <code>ListDataEvent</code> encapsulating the
* event information
*/
void intervalAdded(ListDataEvent e);
/**
* Sent after the indices in the index0,index1 interval
* have been removed from the data model. The interval
* includes both index0 and index1.
*
* @param e a <code>ListDataEvent</code> encapsulating the
* event information
*/
void intervalRemoved(ListDataEvent e);
/**
* Sent when the contents of the list has changed in a way
* that's too complex to characterize with the previous
* methods. For example, this is sent when an item has been
* replaced. Index0 and index1 bracket the change.
*
* @param e a <code>ListDataEvent</code> encapsulating the
* event information
*/
void contentsChanged(ListDataEvent e);
}

View File

@@ -0,0 +1,123 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventObject;
import javax.swing.*;
/**
* An event that characterizes a change in selection. The change is limited to a
* a single inclusive interval. The selection of at least one index within the
* range will have changed. A decent {@code ListSelectionModel} implementation
* will keep the range as small as possible. {@code ListSelectionListeners} will
* generally query the source of the event for the new selected status of each
* potentially changed row.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Hans Muller
* @author Ray Ryan
* @see ListSelectionModel
*/
public class ListSelectionEvent extends EventObject
{
private int firstIndex;
private int lastIndex;
private boolean isAdjusting;
/**
* Represents a change in selection status between {@code firstIndex} and
* {@code lastIndex}, inclusive. {@code firstIndex} is less than or equal to
* {@code lastIndex}. The selection of at least one index within the range will
* have changed.
*
* @param firstIndex the first index in the range, &lt;= lastIndex
* @param lastIndex the last index in the range, &gt;= firstIndex
* @param isAdjusting whether or not this is one in a series of
* multiple events, where changes are still being made
*/
public ListSelectionEvent(Object source, int firstIndex, int lastIndex,
boolean isAdjusting)
{
super(source);
this.firstIndex = firstIndex;
this.lastIndex = lastIndex;
this.isAdjusting = isAdjusting;
}
/**
* Returns the index of the first row whose selection may have changed.
* {@code getFirstIndex() <= getLastIndex()}
*
* @return the first row whose selection value may have changed,
* where zero is the first row
*/
public int getFirstIndex() { return firstIndex; }
/**
* Returns the index of the last row whose selection may have changed.
* {@code getLastIndex() >= getFirstIndex()}
*
* @return the last row whose selection value may have changed,
* where zero is the first row
*/
public int getLastIndex() { return lastIndex; }
/**
* Returns whether or not this is one in a series of multiple events,
* where changes are still being made. See the documentation for
* {@link javax.swing.ListSelectionModel#setValueIsAdjusting} for
* more details on how this is used.
*
* @return {@code true} if this is one in a series of multiple events,
* where changes are still being made
*/
public boolean getValueIsAdjusting() { return isAdjusting; }
/**
* Returns a {@code String} that displays and identifies this
* object's properties.
*
* @return a String representation of this object
*/
public String toString() {
String properties =
" source=" + getSource() +
" firstIndex= " + firstIndex +
" lastIndex= " + lastIndex +
" isAdjusting= " + isAdjusting +
" ";
return getClass().getName() + "[" + properties + "]";
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* The listener that's notified when a lists selection value
* changes.
*
* @see javax.swing.ListSelectionModel
*
* @author Hans Muller
*/
public interface ListSelectionListener extends EventListener
{
/**
* Called whenever the value of the selection changes.
* @param e the event that characterizes the change.
*/
void valueChanged(ListSelectionEvent e);
}

View File

@@ -0,0 +1,145 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import java.util.EventObject;
import java.awt.event.MouseEvent;
import java.awt.Component;
/**
* MenuDragMouseEvent is used to notify interested parties that
* the menu element has received a MouseEvent forwarded to it
* under drag conditions.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Georges Saab
*/
@SuppressWarnings("serial")
public class MenuDragMouseEvent extends MouseEvent {
private MenuElement path[];
private MenuSelectionManager manager;
/**
* Constructs a MenuDragMouseEvent object.
* <p>Absolute coordinates xAbs and yAbs are set to source's location on screen plus
* relative coordinates x and y. xAbs and yAbs are set to zero if the source is not showing.
*
* @param source the Component that originated the event
* (typically <code>this</code>)
* @param id an int specifying the type of event, as defined
* in {@link java.awt.event.MouseEvent}
* @param when a long identifying the time the event occurred
* @param modifiers an int specifying any modifier keys held down,
* as specified in {@link java.awt.event.InputEvent}
* @param x an int specifying the horizontal position at which
* the event occurred, in pixels
* @param y an int specifying the vertical position at which
* the event occurred, in pixels
* @param clickCount an int specifying the number of mouse-clicks
* @param popupTrigger a boolean -- true if the event {should?/did?}
* trigger a popup
* @param p an array of MenuElement objects specifying a path
* to a menu item affected by the drag
* @param m a MenuSelectionManager object that handles selections
* @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
*/
public MenuDragMouseEvent(Component source, int id, long when,
int modifiers, int x, int y, int clickCount,
boolean popupTrigger, MenuElement p[],
MenuSelectionManager m) {
super(source, id, when, modifiers, x, y, clickCount, popupTrigger);
path = p;
manager = m;
}
/**
* Constructs a MenuDragMouseEvent object.
* <p>Even if inconsistent values for relative and absolute coordinates are
* passed to the constructor, the MenuDragMouseEvent instance is still
* created.
* @param source the Component that originated the event
* (typically <code>this</code>)
* @param id an int specifying the type of event, as defined
* in {@link java.awt.event.MouseEvent}
* @param when a long identifying the time the event occurred
* @param modifiers an int specifying any modifier keys held down,
* as specified in {@link java.awt.event.InputEvent}
* @param x an int specifying the horizontal position at which
* the event occurred, in pixels
* @param y an int specifying the vertical position at which
* the event occurred, in pixels
* @param xAbs an int specifying the horizontal absolute position at which
* the event occurred, in pixels
* @param yAbs an int specifying the vertical absolute position at which
* the event occurred, in pixels
* @param clickCount an int specifying the number of mouse-clicks
* @param popupTrigger a boolean -- true if the event {should?/did?}
* trigger a popup
* @param p an array of MenuElement objects specifying a path
* to a menu item affected by the drag
* @param m a MenuSelectionManager object that handles selections
* @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
* @since 1.6
*/
public MenuDragMouseEvent(Component source, int id, long when,
int modifiers, int x, int y, int xAbs,
int yAbs, int clickCount,
boolean popupTrigger, MenuElement p[],
MenuSelectionManager m) {
super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount,
popupTrigger, MouseEvent.NOBUTTON);
path = p;
manager = m;
}
/**
* Returns the path to the selected menu item.
*
* @return an array of MenuElement objects representing the path value
*/
public MenuElement[] getPath() {
return path;
}
/**
* Returns the current menu selection manager.
*
* @return a MenuSelectionManager object
*/
public MenuSelectionManager getMenuSelectionManager() {
return manager;
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* Defines a menu mouse-drag listener.
*
* @author Georges Saab
*/
public interface MenuDragMouseListener extends EventListener {
/**
* Invoked when the dragged mouse has entered a menu component's
* display area.
*
* @param e a MenuDragMouseEvent object
*/
void menuDragMouseEntered(MenuDragMouseEvent e);
/**
* Invoked when the dragged mouse has left a menu component's
* display area.
*
* @param e a MenuDragMouseEvent object
*/
void menuDragMouseExited(MenuDragMouseEvent e);
/**
* Invoked when the mouse is being dragged in a menu component's
* display area.
*
* @param e a MenuDragMouseEvent object
*/
void menuDragMouseDragged(MenuDragMouseEvent e);
/**
* Invoked when a dragged mouse is release in a menu component's
* display area.
*
* @param e a MenuDragMouseEvent object
*/
void menuDragMouseReleased(MenuDragMouseEvent e);
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventObject;
/**
* MenuEvent is used to notify interested parties that
* the menu which is the event source has been posted,
* selected, or canceled.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Georges Saab
* @author David Karlton
*/
@SuppressWarnings("serial")
public class MenuEvent extends EventObject {
/**
* Constructs a MenuEvent object.
*
* @param source the Object that originated the event
* (typically <code>this</code>)
*/
public MenuEvent(Object source) {
super(source);
}
}

View File

@@ -0,0 +1,97 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import java.util.EventObject;
import java.awt.event.KeyEvent;
import java.awt.Component;
/**
* MenuKeyEvent is used to notify interested parties that
* the menu element has received a KeyEvent forwarded to it
* in a menu tree.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Georges Saab
*/
@SuppressWarnings("serial")
public class MenuKeyEvent extends KeyEvent {
private MenuElement path[];
private MenuSelectionManager manager;
/**
* Constructs a MenuKeyEvent object.
*
* @param source the Component that originated the event
* (typically <code>this</code>)
* @param id an int specifying the type of event, as defined
* in {@link java.awt.event.KeyEvent}
* @param when a long identifying the time the event occurred
* @param modifiers an int specifying any modifier keys held down,
* as specified in {@link java.awt.event.InputEvent}
* @param keyCode an int specifying the specific key that was pressed
* @param keyChar a char specifying the key's character value, if any
* -- null if the key has no character value
* @param p an array of MenuElement objects specifying a path
* to a menu item affected by the drag
* @param m a MenuSelectionManager object that handles selections
*/
public MenuKeyEvent(Component source, int id, long when, int modifiers,
int keyCode, char keyChar,
MenuElement p[], MenuSelectionManager m) {
super(source, id, when, modifiers, keyCode, keyChar);
path = p;
manager = m;
}
/**
* Returns the path to the menu item referenced by this event.
*
* @return an array of MenuElement objects representing the path value
*/
public MenuElement[] getPath() {
return path;
}
/**
* Returns the current menu selection manager.
*
* @return a MenuSelectionManager object
*/
public MenuSelectionManager getMenuSelectionManager() {
return manager;
}
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* MenuKeyListener
*
* @author Georges Saab
*/
public interface MenuKeyListener extends EventListener {
/**
* Invoked when a key has been typed.
* This event occurs when a key press is followed by a key release.
*/
void menuKeyTyped(MenuKeyEvent e);
/**
* Invoked when a key has been pressed.
*/
void menuKeyPressed(MenuKeyEvent e);
/**
* Invoked when a key has been released.
*/
void menuKeyReleased(MenuKeyEvent e);
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* Defines a listener for menu events.
*
* @author Georges Saab
*/
public interface MenuListener extends EventListener {
/**
* Invoked when a menu is selected.
*
* @param e a MenuEvent object
*/
void menuSelected(MenuEvent e);
/**
* Invoked when the menu is deselected.
*
* @param e a MenuEvent object
*/
void menuDeselected(MenuEvent e);
/**
* Invoked when the menu is canceled.
*
* @param e a MenuEvent object
*/
void menuCanceled(MenuEvent e);
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.awt.event.MouseAdapter;
/**
* An empty implementation of the {@code MouseInputListener} interface, provided
* as a convenience to simplify the task of creating listeners, by extending
* and implementing only the methods of interest. This class also provides an
* empty implementation of the {@code MouseWheelListener} interface, through
* its extension from AWT's {@code MouseAdapter}.
*
* @author Philip Milne
* @author Shannon Hickey
*/
public abstract class MouseInputAdapter extends MouseAdapter
implements MouseInputListener {
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
/**
* A listener implementing all the methods in both the {@code MouseListener} and
* {@code MouseMotionListener} interfaces.
*
* @see MouseInputAdapter
* @author Philip Milne
*/
public interface MouseInputListener extends MouseListener, MouseMotionListener {
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventObject;
/**
* PopupMenuEvent only contains the source of the event which is the JPoupMenu
* sending the event
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Arnaud Weber
*/
@SuppressWarnings("serial")
public class PopupMenuEvent extends EventObject {
/**
* Constructs a PopupMenuEvent object.
*
* @param source the Object that originated the event
* (typically <code>this</code>)
*/
public PopupMenuEvent(Object source) {
super(source);
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* A popup menu listener
*
* @author Arnaud Weber
*/
public interface PopupMenuListener extends EventListener {
/**
* This method is called before the popup menu becomes visible
*/
void popupMenuWillBecomeVisible(PopupMenuEvent e);
/**
* This method is called before the popup menu becomes invisible
* Note that a JPopupMenu can become invisible any time
*/
void popupMenuWillBecomeInvisible(PopupMenuEvent e);
/**
* This method is called when the popup menu is canceled
*/
void popupMenuCanceled(PopupMenuEvent e);
}

View File

@@ -0,0 +1,144 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import javax.swing.RowSorter;
/**
* <code>RowSorterEvent</code> provides notification of changes to
* a <code>RowSorter</code>. Two types of notification are possible:
* <ul>
* <li><code>Type.SORT_ORDER_CHANGED</code>: indicates the sort order has
* changed. This is typically followed by a notification of:
* <li><code>Type.SORTED</code>: indicates the contents of the model have
* been transformed in some way. For example, the contents may have
* been sorted or filtered.
* </ul>
*
* @see javax.swing.RowSorter
* @since 1.6
*/
public class RowSorterEvent extends java.util.EventObject {
private Type type;
private int[] oldViewToModel;
/**
* Enumeration of the types of <code>RowSorterEvent</code>s.
*
* @since 1.6
*/
public enum Type {
/**
* Indicates the sort order has changed.
*/
SORT_ORDER_CHANGED,
/**
* Indicates the contents have been newly sorted or
* transformed in some way.
*/
SORTED
}
/**
* Creates a <code>RowSorterEvent</code> of type
* <code>SORT_ORDER_CHANGED</code>.
*
* @param source the source of the change
* @throws IllegalArgumentException if <code>source</code> is
* <code>null</code>
*/
public RowSorterEvent(RowSorter source) {
this(source, Type.SORT_ORDER_CHANGED, null);
}
/**
* Creates a <code>RowSorterEvent</code>.
*
* @param source the source of the change
* @param type the type of event
* @param previousRowIndexToModel the mapping from model indices to
* view indices prior to the sort, may be <code>null</code>
* @throws IllegalArgumentException if source or <code>type</code> is
* <code>null</code>
*/
public RowSorterEvent(RowSorter source, Type type,
int[] previousRowIndexToModel) {
super(source);
if (type == null) {
throw new IllegalArgumentException("type must be non-null");
}
this.type = type;
this.oldViewToModel = previousRowIndexToModel;
}
/**
* Returns the source of the event as a <code>RowSorter</code>.
*
* @return the source of the event as a <code>RowSorter</code>
*/
public RowSorter getSource() {
return (RowSorter)super.getSource();
}
/**
* Returns the type of event.
*
* @return the type of event
*/
public Type getType() {
return type;
}
/**
* Returns the location of <code>index</code> in terms of the
* model prior to the sort. This method is only useful for events
* of type <code>SORTED</code>. This method will return -1 if the
* index is not valid, or the locations prior to the sort have not
* been provided.
*
* @param index the index in terms of the view
* @return the index in terms of the model prior to the sort, or -1 if
* the location is not valid or the mapping was not provided.
*/
public int convertPreviousRowIndexToModel(int index) {
if (oldViewToModel != null && index >= 0 &&
index < oldViewToModel.length) {
return oldViewToModel[index];
}
return -1;
}
/**
* Returns the number of rows before the sort. This method is only
* useful for events of type <code>SORTED</code> and if the
* last locations have not been provided will return 0.
*
* @return the number of rows in terms of the view prior to the sort
*/
public int getPreviousRowCount() {
return (oldViewToModel == null) ? 0 : oldViewToModel.length;
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
/**
* <code>RowSorterListener</code>s are notified of changes to a
* <code>RowSorter</code>.
*
* @see javax.swing.RowSorter
* @since 1.6
*/
public interface RowSorterListener extends java.util.EventListener {
/**
* Notification that the <code>RowSorter</code> has changed. The event
* describes the scope of the change.
*
* @param e the event, will not be null
*/
public void sorterChanged(RowSorterEvent e);
}

View File

@@ -0,0 +1,124 @@
/*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeEvent;
import javax.swing.SwingUtilities;
/**
* This subclass of {@code java.beans.PropertyChangeSupport} is almost
* identical in functionality. The only difference is if constructed with
* {@code SwingPropertyChangeSupport(sourceBean, true)} it ensures
* listeners are only ever notified on the <i>Event Dispatch Thread</i>.
*
* @author Igor Kushnirskiy
*/
public final class SwingPropertyChangeSupport extends PropertyChangeSupport {
/**
* Constructs a SwingPropertyChangeSupport object.
*
* @param sourceBean The bean to be given as the source for any
* events.
* @throws NullPointerException if {@code sourceBean} is
* {@code null}
*/
public SwingPropertyChangeSupport(Object sourceBean) {
this(sourceBean, false);
}
/**
* Constructs a SwingPropertyChangeSupport object.
*
* @param sourceBean the bean to be given as the source for any events
* @param notifyOnEDT whether to notify listeners on the <i>Event
* Dispatch Thread</i> only
*
* @throws NullPointerException if {@code sourceBean} is
* {@code null}
* @since 1.6
*/
public SwingPropertyChangeSupport(Object sourceBean, boolean notifyOnEDT) {
super(sourceBean);
this.notifyOnEDT = notifyOnEDT;
}
/**
* {@inheritDoc}
*
* <p>
* If {@link #isNotifyOnEDT} is {@code true} and called off the
* <i>Event Dispatch Thread</i> this implementation uses
* {@code SwingUtilities.invokeLater} to send out the notification
* on the <i>Event Dispatch Thread</i>. This ensures listeners
* are only ever notified on the <i>Event Dispatch Thread</i>.
*
* @throws NullPointerException if {@code evt} is
* {@code null}
* @since 1.6
*/
public void firePropertyChange(final PropertyChangeEvent evt) {
if (evt == null) {
throw new NullPointerException();
}
if (! isNotifyOnEDT()
|| SwingUtilities.isEventDispatchThread()) {
super.firePropertyChange(evt);
} else {
SwingUtilities.invokeLater(
new Runnable() {
public void run() {
firePropertyChange(evt);
}
});
}
}
/**
* Returns {@code notifyOnEDT} property.
*
* @return {@code notifyOnEDT} property
* @see #SwingPropertyChangeSupport(Object sourceBean, boolean notifyOnEDT)
* @since 1.6
*/
public final boolean isNotifyOnEDT() {
return notifyOnEDT;
}
// Serialization version ID
static final long serialVersionUID = 7162625831330845068L;
/**
* whether to notify listeners on EDT
*
* @serial
* @since 1.6
*/
private final boolean notifyOnEDT;
}

View File

@@ -0,0 +1,90 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventObject;
import javax.swing.table.*;
/**
* <B>TableColumnModelEvent</B> is used to notify listeners that a table
* column model has changed, such as a column was added, removed, or
* moved.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Alan Chung
* @see TableColumnModelListener
*/
public class TableColumnModelEvent extends java.util.EventObject
{
//
// Instance Variables
//
/** The index of the column from where it was moved or removed */
protected int fromIndex;
/** The index of the column to where it was moved or added */
protected int toIndex;
//
// Constructors
//
/**
* Constructs a {@code TableColumnModelEvent} object.
*
* @param source the {@code TableColumnModel} that originated the event
* @param from an int specifying the index from where the column was
* moved or removed
* @param to an int specifying the index to where the column was
* moved or added
* @see #getFromIndex
* @see #getToIndex
*/
public TableColumnModelEvent(TableColumnModel source, int from, int to) {
super(source);
fromIndex = from;
toIndex = to;
}
//
// Querying Methods
//
/** Returns the fromIndex. Valid for removed or moved events */
public int getFromIndex() { return fromIndex; };
/** Returns the toIndex. Valid for add and moved events */
public int getToIndex() { return toIndex; };
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ChangeEvent;
import java.util.EventListener;
/**
* TableColumnModelListener defines the interface for an object that listens
* to changes in a TableColumnModel.
*
* @author Alan Chung
* @see TableColumnModelEvent
*/
public interface TableColumnModelListener extends java.util.EventListener
{
/** Tells listeners that a column was added to the model. */
public void columnAdded(TableColumnModelEvent e);
/** Tells listeners that a column was removed from the model. */
public void columnRemoved(TableColumnModelEvent e);
/** Tells listeners that a column was repositioned. */
public void columnMoved(TableColumnModelEvent e);
/** Tells listeners that a column was moved due to a margin change. */
public void columnMarginChanged(ChangeEvent e);
/**
* Tells listeners that the selection model of the
* TableColumnModel changed.
*/
public void columnSelectionChanged(ListSelectionEvent e);
}

View File

@@ -0,0 +1,178 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventObject;
import javax.swing.table.*;
/**
* TableModelEvent is used to notify listeners that a table model
* has changed. The model event describes changes to a TableModel
* and all references to rows and columns are in the co-ordinate
* system of the model.
* Depending on the parameters used in the constructors, the TableModelevent
* can be used to specify the following types of changes:
*
* <pre>
* TableModelEvent(source); // The data, ie. all rows changed
* TableModelEvent(source, HEADER_ROW); // Structure change, reallocate TableColumns
* TableModelEvent(source, 1); // Row 1 changed
* TableModelEvent(source, 3, 6); // Rows 3 to 6 inclusive changed
* TableModelEvent(source, 2, 2, 6); // Cell at (2, 6) changed
* TableModelEvent(source, 3, 6, ALL_COLUMNS, INSERT); // Rows (3, 6) were inserted
* TableModelEvent(source, 3, 6, ALL_COLUMNS, DELETE); // Rows (3, 6) were deleted
* </pre>
*
* It is possible to use other combinations of the parameters, not all of them
* are meaningful. By subclassing, you can add other information, for example:
* whether the event WILL happen or DID happen. This makes the specification
* of rows in DELETE events more useful but has not been included in
* the swing package as the JTable only needs post-event notification.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Alan Chung
* @author Philip Milne
* @see TableModel
*/
public class TableModelEvent extends java.util.EventObject
{
/** Identifies the addition of new rows or columns. */
public static final int INSERT = 1;
/** Identifies a change to existing data. */
public static final int UPDATE = 0;
/** Identifies the removal of rows or columns. */
public static final int DELETE = -1;
/** Identifies the header row. */
public static final int HEADER_ROW = -1;
/** Specifies all columns in a row or rows. */
public static final int ALL_COLUMNS = -1;
//
// Instance Variables
//
protected int type;
protected int firstRow;
protected int lastRow;
protected int column;
//
// Constructors
//
/**
* All row data in the table has changed, listeners should discard any state
* that was based on the rows and requery the <code>TableModel</code>
* to get the new row count and all the appropriate values.
* The <code>JTable</code> will repaint the entire visible region on
* receiving this event, querying the model for the cell values that are visible.
* The structure of the table ie, the column names, types and order
* have not changed.
*/
public TableModelEvent(TableModel source) {
// Use Integer.MAX_VALUE instead of getRowCount() in case rows were deleted.
this(source, 0, Integer.MAX_VALUE, ALL_COLUMNS, UPDATE);
}
/**
* This row of data has been updated.
* To denote the arrival of a completely new table with a different structure
* use <code>HEADER_ROW</code> as the value for the <code>row</code>.
* When the <code>JTable</code> receives this event and its
* <code>autoCreateColumnsFromModel</code>
* flag is set it discards any TableColumns that it had and reallocates
* default ones in the order they appear in the model. This is the
* same as calling <code>setModel(TableModel)</code> on the <code>JTable</code>.
*/
public TableModelEvent(TableModel source, int row) {
this(source, row, row, ALL_COLUMNS, UPDATE);
}
/**
* The data in rows [<I>firstRow</I>, <I>lastRow</I>] have been updated.
*/
public TableModelEvent(TableModel source, int firstRow, int lastRow) {
this(source, firstRow, lastRow, ALL_COLUMNS, UPDATE);
}
/**
* The cells in column <I>column</I> in the range
* [<I>firstRow</I>, <I>lastRow</I>] have been updated.
*/
public TableModelEvent(TableModel source, int firstRow, int lastRow, int column) {
this(source, firstRow, lastRow, column, UPDATE);
}
/**
* The cells from (firstRow, column) to (lastRow, column) have been changed.
* The <I>column</I> refers to the column index of the cell in the model's
* co-ordinate system. When <I>column</I> is ALL_COLUMNS, all cells in the
* specified range of rows are considered changed.
* <p>
* The <I>type</I> should be one of: INSERT, UPDATE and DELETE.
*/
public TableModelEvent(TableModel source, int firstRow, int lastRow, int column, int type) {
super(source);
this.firstRow = firstRow;
this.lastRow = lastRow;
this.column = column;
this.type = type;
}
//
// Querying Methods
//
/** Returns the first row that changed. HEADER_ROW means the meta data,
* ie. names, types and order of the columns.
*/
public int getFirstRow() { return firstRow; };
/** Returns the last row that changed. */
public int getLastRow() { return lastRow; };
/**
* Returns the column for the event. If the return
* value is ALL_COLUMNS; it means every column in the specified
* rows changed.
*/
public int getColumn() { return column; };
/**
* Returns the type of event - one of: INSERT, UPDATE and DELETE.
*/
public int getType() { return type; }
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* TableModelListener defines the interface for an object that listens
* to changes in a TableModel.
*
* @author Alan Chung
* @see javax.swing.table.TableModel
*/
public interface TableModelListener extends java.util.EventListener
{
/**
* This fine grain notification tells listeners the exact range
* of cells, rows, or columns that changed.
*/
public void tableChanged(TableModelEvent e);
}

View File

@@ -0,0 +1,75 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventObject;
import javax.swing.tree.TreePath;
/**
* An event used to identify a single path in a tree. The source
* returned by <b>getSource</b> will be an instance of JTree.
* <p>
* For further documentation and examples see
* the following sections in <em>The Java Tutorial</em>:
* <a href="https://docs.oracle.com/javase/tutorial/uiswing/events/treeexpansionlistener.html">How to Write a Tree Expansion Listener</a> and
* <a href="https://docs.oracle.com/javase/tutorial/uiswing/events/treewillexpandlistener.html">How to Write a Tree-Will-Expand Listener</a>.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Scott Violet
*/
public class TreeExpansionEvent extends EventObject
{
/**
* Path to the value this event represents.
*/
protected TreePath path;
/**
* Constructs a TreeExpansionEvent object.
*
* @param source the Object that originated the event
* (typically <code>this</code>)
* @param path a TreePath object identifying the newly expanded
* node
*/
public TreeExpansionEvent(Object source, TreePath path) {
super(source);
this.path = path;
}
/**
* Returns the path to the value that has been expanded/collapsed.
*/
public TreePath getPath() { return path; }
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* The listener that's notified when a tree expands or collapses
* a node.
* For further documentation and examples see
* <a
href="https://docs.oracle.com/javase/tutorial/uiswing/events/treeexpansionlistener.html">How to Write a Tree Expansion Listener</a>,
* a section in <em>The Java Tutorial.</em>
*
* @author Scott Violet
*/
public interface TreeExpansionListener extends EventListener
{
/**
* Called whenever an item in the tree has been expanded.
*/
public void treeExpanded(TreeExpansionEvent event);
/**
* Called whenever an item in the tree has been collapsed.
*/
public void treeCollapsed(TreeExpansionEvent event);
}

View File

@@ -0,0 +1,314 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventObject;
import javax.swing.tree.TreePath;
/**
* Encapsulates information describing changes to a tree model, and
* used to notify tree model listeners of the change.
* For more information and examples see
* <a
href="https://docs.oracle.com/javase/tutorial/uiswing/events/treemodellistener.html">How to Write a Tree Model Listener</a>,
* a section in <em>The Java Tutorial.</em>
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Rob Davis
* @author Ray Ryan
* @author Scott Violet
*/
public class TreeModelEvent extends EventObject {
/** Path to the parent of the nodes that have changed. */
protected TreePath path;
/** Indices identifying the position of where the children were. */
protected int[] childIndices;
/** Children that have been removed. */
protected Object[] children;
/**
* Used to create an event when nodes have been changed, inserted, or
* removed, identifying the path to the parent of the modified items as
* an array of Objects. All of the modified objects are siblings which are
* direct descendents (not grandchildren) of the specified parent.
* The positions at which the inserts, deletes, or changes occurred are
* specified by an array of <code>int</code>. The indexes in that array
* must be in order, from lowest to highest.
* <p>
* For changes, the indexes in the model correspond exactly to the indexes
* of items currently displayed in the UI. As a result, it is not really
* critical if the indexes are not in their exact order. But after multiple
* inserts or deletes, the items currently in the UI no longer correspond
* to the items in the model. It is therefore critical to specify the
* indexes properly for inserts and deletes.
* <p>
* For inserts, the indexes represent the <i>final</i> state of the tree,
* after the inserts have occurred. Since the indexes must be specified in
* order, the most natural processing methodology is to do the inserts
* starting at the lowest index and working towards the highest. Accumulate
* a Vector of <code>Integer</code> objects that specify the
* insert-locations as you go, then convert the Vector to an
* array of <code>int</code> to create the event. When the postition-index
* equals zero, the node is inserted at the beginning of the list. When the
* position index equals the size of the list, the node is "inserted" at
* (appended to) the end of the list.
* <p>
* For deletes, the indexes represent the <i>initial</i> state of the tree,
* before the deletes have occurred. Since the indexes must be specified in
* order, the most natural processing methodology is to use a delete-counter.
* Start by initializing the counter to zero and start work through the
* list from lowest to highest. Every time you do a delete, add the current
* value of the delete-counter to the index-position where the delete occurred,
* and append the result to a Vector of delete-locations, using
* <code>addElement()</code>. Then increment the delete-counter. The index
* positions stored in the Vector therefore reflect the effects of all previous
* deletes, so they represent each object's position in the initial tree.
* (You could also start at the highest index and working back towards the
* lowest, accumulating a Vector of delete-locations as you go using the
* <code>insertElementAt(Integer, 0)</code>.) However you produce the Vector
* of initial-positions, you then need to convert the Vector of <code>Integer</code>
* objects to an array of <code>int</code> to create the event.
* <p>
* <b>Notes:</b><ul style="list-style-type:none">
* <li>Like the <code>insertNodeInto</code> method in the
* <code>DefaultTreeModel</code> class, <code>insertElementAt</code>
* appends to the <code>Vector</code> when the index matches the size
* of the vector. So you can use <code>insertElementAt(Integer, 0)</code>
* even when the vector is empty.</li>
* <li>To create a node changed event for the root node, specify the parent
* and the child indices as <code>null</code>.</li>
* </ul>
*
* @param source the Object responsible for generating the event (typically
* the creator of the event object passes <code>this</code>
* for its value)
* @param path an array of Object identifying the path to the
* parent of the modified item(s), where the first element
* of the array is the Object stored at the root node and
* the last element is the Object stored at the parent node
* @param childIndices an array of <code>int</code> that specifies the
* index values of the removed items. The indices must be
* in sorted order, from lowest to highest
* @param children an array of Object containing the inserted, removed, or
* changed objects
* @see TreePath
*/
public TreeModelEvent(Object source, Object[] path, int[] childIndices,
Object[] children)
{
this(source, (path == null) ? null : new TreePath(path), childIndices, children);
}
/**
* Used to create an event when nodes have been changed, inserted, or
* removed, identifying the path to the parent of the modified items as
* a TreePath object. For more information on how to specify the indexes
* and objects, see
* <code>TreeModelEvent(Object,Object[],int[],Object[])</code>.
*
* @param source the Object responsible for generating the event (typically
* the creator of the event object passes <code>this</code>
* for its value)
* @param path a TreePath object that identifies the path to the
* parent of the modified item(s)
* @param childIndices an array of <code>int</code> that specifies the
* index values of the modified items
* @param children an array of Object containing the inserted, removed, or
* changed objects
*
* @see #TreeModelEvent(Object,Object[],int[],Object[])
*/
public TreeModelEvent(Object source, TreePath path, int[] childIndices,
Object[] children)
{
super(source);
this.path = path;
this.childIndices = childIndices;
this.children = children;
}
/**
* Used to create an event when the node structure has changed in some way,
* identifying the path to the root of a modified subtree as an array of
* Objects. A structure change event might involve nodes swapping position,
* for example, or it might encapsulate multiple inserts and deletes in the
* subtree stemming from the node, where the changes may have taken place at
* different levels of the subtree.
* <blockquote>
* <b>Note:</b><br>
* JTree collapses all nodes under the specified node, so that only its
* immediate children are visible.
* </blockquote>
*
* @param source the Object responsible for generating the event (typically
* the creator of the event object passes <code>this</code>
* for its value)
* @param path an array of Object identifying the path to the root of the
* modified subtree, where the first element of the array is
* the object stored at the root node and the last element
* is the object stored at the changed node
* @see TreePath
*/
public TreeModelEvent(Object source, Object[] path)
{
this(source, (path == null) ? null : new TreePath(path));
}
/**
* Used to create an event when the node structure has changed in some way,
* identifying the path to the root of the modified subtree as a TreePath
* object. For more information on this event specification, see
* <code>TreeModelEvent(Object,Object[])</code>.
*
* @param source the Object responsible for generating the event (typically
* the creator of the event object passes <code>this</code>
* for its value)
* @param path a TreePath object that identifies the path to the
* change. In the DefaultTreeModel,
* this object contains an array of user-data objects,
* but a subclass of TreePath could use some totally
* different mechanism -- for example, a node ID number
*
* @see #TreeModelEvent(Object,Object[])
*/
public TreeModelEvent(Object source, TreePath path)
{
super(source);
this.path = path;
this.childIndices = new int[0];
}
/**
* For all events, except treeStructureChanged,
* returns the parent of the changed nodes.
* For treeStructureChanged events, returns the ancestor of the
* structure that has changed. This and
* <code>getChildIndices</code> are used to get a list of the effected
* nodes.
* <p>
* The one exception to this is a treeNodesChanged event that is to
* identify the root, in which case this will return the root
* and <code>getChildIndices</code> will return null.
*
* @return the TreePath used in identifying the changed nodes.
* @see TreePath#getLastPathComponent
*/
public TreePath getTreePath() { return path; }
/**
* Convenience method to get the array of objects from the TreePath
* instance that this event wraps.
*
* @return an array of Objects, where the first Object is the one
* stored at the root and the last object is the one
* stored at the node identified by the path
*/
public Object[] getPath() {
if(path != null)
return path.getPath();
return null;
}
/**
* Returns the objects that are children of the node identified by
* <code>getPath</code> at the locations specified by
* <code>getChildIndices</code>. If this is a removal event the
* returned objects are no longer children of the parent node.
*
* @return an array of Object containing the children specified by
* the event
* @see #getPath
* @see #getChildIndices
*/
public Object[] getChildren() {
if(children != null) {
int cCount = children.length;
Object[] retChildren = new Object[cCount];
System.arraycopy(children, 0, retChildren, 0, cCount);
return retChildren;
}
return null;
}
/**
* Returns the values of the child indexes. If this is a removal event
* the indexes point to locations in the initial list where items
* were removed. If it is an insert, the indices point to locations
* in the final list where the items were added. For node changes,
* the indices point to the locations of the modified nodes.
*
* @return an array of <code>int</code> containing index locations for
* the children specified by the event
*/
public int[] getChildIndices() {
if(childIndices != null) {
int cCount = childIndices.length;
int[] retArray = new int[cCount];
System.arraycopy(childIndices, 0, retArray, 0, cCount);
return retArray;
}
return null;
}
/**
* Returns a string that displays and identifies this object's
* properties.
*
* @return a String representation of this object
*/
public String toString() {
StringBuffer retBuffer = new StringBuffer();
retBuffer.append(getClass().getName() + " " +
Integer.toString(hashCode()));
if(path != null)
retBuffer.append(" path " + path);
if(childIndices != null) {
retBuffer.append(" indices [ ");
for(int counter = 0; counter < childIndices.length; counter++)
retBuffer.append(Integer.toString(childIndices[counter])+ " ");
retBuffer.append("]");
}
if(children != null) {
retBuffer.append(" children [ ");
for(int counter = 0; counter < children.length; counter++)
retBuffer.append(children[counter] + " ");
retBuffer.append("]");
}
return retBuffer.toString();
}
}

View File

@@ -0,0 +1,98 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* Defines the interface for an object that listens
* to changes in a TreeModel.
* For further information and examples see
* <a
href="https://docs.oracle.com/javase/tutorial/uiswing/events/treemodellistener.html">How to Write a Tree Model Listener</a>,
* a section in <em>The Java Tutorial.</em>
*
* @author Rob Davis
* @author Ray Ryan
*/
public interface TreeModelListener extends EventListener {
/**
* <p>Invoked after a node (or a set of siblings) has changed in some
* way. The node(s) have not changed locations in the tree or
* altered their children arrays, but other attributes have
* changed and may affect presentation. Example: the name of a
* file has changed, but it is in the same location in the file
* system.</p>
* <p>To indicate the root has changed, childIndices and children
* will be null. </p>
*
* <p>Use <code>e.getPath()</code>
* to get the parent of the changed node(s).
* <code>e.getChildIndices()</code>
* returns the index(es) of the changed node(s).</p>
*/
void treeNodesChanged(TreeModelEvent e);
/**
* <p>Invoked after nodes have been inserted into the tree.</p>
*
* <p>Use <code>e.getPath()</code>
* to get the parent of the new node(s).
* <code>e.getChildIndices()</code>
* returns the index(es) of the new node(s)
* in ascending order.</p>
*/
void treeNodesInserted(TreeModelEvent e);
/**
* <p>Invoked after nodes have been removed from the tree. Note that
* if a subtree is removed from the tree, this method may only be
* invoked once for the root of the removed subtree, not once for
* each individual set of siblings removed.</p>
*
* <p>Use <code>e.getPath()</code>
* to get the former parent of the deleted node(s).
* <code>e.getChildIndices()</code>
* returns, in ascending order, the index(es)
* the node(s) had before being deleted.</p>
*/
void treeNodesRemoved(TreeModelEvent e);
/**
* <p>Invoked after the tree has drastically changed structure from a
* given node down. If the path returned by e.getPath() is of length
* one and the first element does not identify the current root node
* the first element should become the new root of the tree.
*
* <p>Use <code>e.getPath()</code>
* to get the path to the node.
* <code>e.getChildIndices()</code>
* returns null.</p>
*/
void treeStructureChanged(TreeModelEvent e);
}

View File

@@ -0,0 +1,210 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventObject;
import javax.swing.tree.TreePath;
/**
* An event that characterizes a change in the current
* selection. The change is based on any number of paths.
* TreeSelectionListeners will generally query the source of
* the event for the new selected status of each potentially
* changed row.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see TreeSelectionListener
* @see javax.swing.tree.TreeSelectionModel
*
* @author Scott Violet
*/
public class TreeSelectionEvent extends EventObject
{
/** Paths this event represents. */
protected TreePath[] paths;
/** For each path identifies if that path is in fact new. */
protected boolean[] areNew;
/** leadSelectionPath before the paths changed, may be null. */
protected TreePath oldLeadSelectionPath;
/** leadSelectionPath after the paths changed, may be null. */
protected TreePath newLeadSelectionPath;
/**
* Represents a change in the selection of a TreeSelectionModel.
* paths identifies the paths that have been either added or
* removed from the selection.
*
* @param source source of event
* @param paths the paths that have changed in the selection
*/
public TreeSelectionEvent(Object source, TreePath[] paths,
boolean[] areNew, TreePath oldLeadSelectionPath,
TreePath newLeadSelectionPath)
{
super(source);
this.paths = paths;
this.areNew = areNew;
this.oldLeadSelectionPath = oldLeadSelectionPath;
this.newLeadSelectionPath = newLeadSelectionPath;
}
/**
* Represents a change in the selection of a TreeSelectionModel.
* path identifies the path that have been either added or
* removed from the selection.
*
* @param source source of event
* @param path the path that has changed in the selection
* @param isNew whether or not the path is new to the selection, false
* means path was removed from the selection.
*/
public TreeSelectionEvent(Object source, TreePath path, boolean isNew,
TreePath oldLeadSelectionPath,
TreePath newLeadSelectionPath)
{
super(source);
paths = new TreePath[1];
paths[0] = path;
areNew = new boolean[1];
areNew[0] = isNew;
this.oldLeadSelectionPath = oldLeadSelectionPath;
this.newLeadSelectionPath = newLeadSelectionPath;
}
/**
* Returns the paths that have been added or removed from the
* selection.
*/
public TreePath[] getPaths()
{
int numPaths;
TreePath[] retPaths;
numPaths = paths.length;
retPaths = new TreePath[numPaths];
System.arraycopy(paths, 0, retPaths, 0, numPaths);
return retPaths;
}
/**
* Returns the first path element.
*/
public TreePath getPath()
{
return paths[0];
}
/**
* Returns whether the path identified by {@code getPath} was
* added to the selection. A return value of {@code true}
* indicates the path identified by {@code getPath} was added to
* the selection. A return value of {@code false} indicates {@code
* getPath} was selected, but is no longer selected.
*
* @return {@code true} if {@code getPath} was added to the selection,
* {@code false} otherwise
*/
public boolean isAddedPath() {
return areNew[0];
}
/**
* Returns whether the specified path was added to the selection.
* A return value of {@code true} indicates the path identified by
* {@code path} was added to the selection. A return value of
* {@code false} indicates {@code path} is no longer selected. This method
* is only valid for the paths returned from {@code getPaths()}; invoking
* with a path not included in {@code getPaths()} throws an
* {@code IllegalArgumentException}.
*
* @param path the path to test
* @return {@code true} if {@code path} was added to the selection,
* {@code false} otherwise
* @throws IllegalArgumentException if {@code path} is not contained
* in {@code getPaths}
* @see #getPaths
*/
public boolean isAddedPath(TreePath path) {
for(int counter = paths.length - 1; counter >= 0; counter--)
if(paths[counter].equals(path))
return areNew[counter];
throw new IllegalArgumentException("path is not a path identified by the TreeSelectionEvent");
}
/**
* Returns whether the path at {@code getPaths()[index]} was added
* to the selection. A return value of {@code true} indicates the
* path was added to the selection. A return value of {@code false}
* indicates the path is no longer selected.
*
* @param index the index of the path to test
* @return {@code true} if the path was added to the selection,
* {@code false} otherwise
* @throws IllegalArgumentException if index is outside the range of
* {@code getPaths}
* @see #getPaths
*
* @since 1.3
*/
public boolean isAddedPath(int index) {
if (paths == null || index < 0 || index >= paths.length) {
throw new IllegalArgumentException("index is beyond range of added paths identified by TreeSelectionEvent");
}
return areNew[index];
}
/**
* Returns the path that was previously the lead path.
*/
public TreePath getOldLeadSelectionPath() {
return oldLeadSelectionPath;
}
/**
* Returns the current lead path.
*/
public TreePath getNewLeadSelectionPath() {
return newLeadSelectionPath;
}
/**
* Returns a copy of the receiver, but with the source being newSource.
*/
public Object cloneWithSource(Object newSource) {
// Fix for IE bug - crashing
return new TreeSelectionEvent(newSource, paths,areNew,
oldLeadSelectionPath,
newLeadSelectionPath);
}
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
/**
* The listener that's notified when the selection in a TreeSelectionModel
* changes.
* For more information and examples see
* <a
href="https://docs.oracle.com/javase/tutorial/uiswing/events/treeselectionlistener.html">How to Write a Tree Selection Listener</a>,
* a section in <em>The Java Tutorial.</em>
*
* @see javax.swing.tree.TreeSelectionModel
* @see javax.swing.JTree
*
* @author Scott Violet
*/
public interface TreeSelectionListener extends EventListener
{
/**
* Called whenever the value of the selection changes.
* @param e the event that characterizes the change.
*/
void valueChanged(TreeSelectionEvent e);
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import java.util.EventListener;
import javax.swing.tree.ExpandVetoException;
/**
* The listener that's notified when a tree expands or collapses
* a node.
* For further information and examples see
* <a href="https://docs.oracle.com/javase/tutorial/uiswing/events/treewillexpandlistener.html">How to Write a Tree-Will-Expand Listener</a>,
* a section in <em>The Java Tutorial.</em>
*
* @author Scott Violet
*/
public interface TreeWillExpandListener extends EventListener {
/**
* Invoked whenever a node in the tree is about to be expanded.
*/
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException;
/**
* Invoked whenever a node in the tree is about to be collapsed.
*/
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException;
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import javax.swing.undo.*;
/**
* An event indicating that an operation which can be undone has occurred.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Ray Ryan
*/
public class UndoableEditEvent extends java.util.EventObject {
private UndoableEdit myEdit;
/**
* Constructs an UndoableEditEvent object.
*
* @param source the Object that originated the event
* (typically <code>this</code>)
* @param edit an UndoableEdit object
*/
public UndoableEditEvent(Object source, UndoableEdit edit) {
super(source);
myEdit = edit;
}
/**
* Returns the edit value.
*
* @return the UndoableEdit object encapsulating the edit
*/
public UndoableEdit getEdit() {
return myEdit;
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.event;
import javax.swing.undo.*;
/**
* Interface implemented by a class interested in hearing about
* undoable operations.
*
* @author Ray Ryan
*/
public interface UndoableEditListener extends java.util.EventListener {
/**
* An undoable edit happened
*/
void undoableEditHappened(UndoableEditEvent e);
}