< prev index next >
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java
Print this page
*** 40,65 ****
* @author David Kloba
* @author Rich Schiavi
*/
public class BasicInternalFrameUI extends InternalFrameUI
{
!
protected JInternalFrame frame;
private Handler handler;
protected MouseInputAdapter borderListener;
protected PropertyChangeListener propertyChangeListener;
protected LayoutManager internalFrameLayout;
protected ComponentListener componentListener;
protected MouseInputListener glassPaneDispatcher;
private InternalFrameListener internalFrameListener;
protected JComponent northPane;
protected JComponent southPane;
protected JComponent westPane;
protected JComponent eastPane;
!
protected BasicInternalFrameTitlePane titlePane; // access needs this
private static DesktopManager sharedDesktopManager;
private boolean componentListenerAdded = false;
--- 40,74 ----
* @author David Kloba
* @author Rich Schiavi
*/
public class BasicInternalFrameUI extends InternalFrameUI
{
! /** frame */
protected JInternalFrame frame;
private Handler handler;
+ /** border listener */
protected MouseInputAdapter borderListener;
+ /** property change listener */
protected PropertyChangeListener propertyChangeListener;
+ /** internal frame layout */
protected LayoutManager internalFrameLayout;
+ /** component listener */
protected ComponentListener componentListener;
+ /** glass pane dispatcher */
protected MouseInputListener glassPaneDispatcher;
private InternalFrameListener internalFrameListener;
+ /** north pane */
protected JComponent northPane;
+ /** south pane */
protected JComponent southPane;
+ /** west pane */
protected JComponent westPane;
+ /** east pane */
protected JComponent eastPane;
! /** title pane */
protected BasicInternalFrameTitlePane titlePane; // access needs this
private static DesktopManager sharedDesktopManager;
private boolean componentListenerAdded = false;
*** 83,103 ****
--- 92,125 ----
private boolean keyBindingActive = false;
/////////////////////////////////////////////////////////////////////////////
// ComponentUI Interface Implementation methods
/////////////////////////////////////////////////////////////////////////////
+ /**
+ * Returns a component UI.
+ * @param b a component
+ * @return a component UI
+ */
public static ComponentUI createUI(JComponent b) {
return new BasicInternalFrameUI((JInternalFrame)b);
}
+ /**
+ * Constructs a {@code BasicInternalFrameUI}.
+ * @param b the internal frame
+ */
public BasicInternalFrameUI(JInternalFrame b) {
LookAndFeel laf = UIManager.getLookAndFeel();
if (laf instanceof BasicLookAndFeel) {
((BasicLookAndFeel)laf).installAWTEventListener();
}
}
+ /**
+ * Install the UI.
+ * @param c the component
+ */
public void installUI(JComponent c) {
frame = (JInternalFrame)c;
installDefaults();
*** 106,115 ****
--- 128,141 ----
installKeyboardActions();
LookAndFeel.installProperty(frame, "opaque", Boolean.TRUE);
}
+ /**
+ * Uninstall the UI.
+ * @param c the component
+ */
public void uninstallUI(JComponent c) {
if(c != frame)
throw new IllegalComponentStateException(
this + " was asked to deinstall() "
+ c + " when it only knows about "
*** 122,131 ****
--- 148,160 ----
updateFrameCursor();
handler = null;
frame = null;
}
+ /**
+ * Install the defaults.
+ */
protected void installDefaults(){
Icon frameIcon = frame.getFrameIcon();
if (frameIcon == null || frameIcon instanceof UIResource) {
frame.setFrameIcon(UIManager.getIcon("InternalFrame.icon"));
}
*** 142,151 ****
--- 171,183 ----
frame.setBackground(UIManager.getLookAndFeelDefaults().getColor("control"));
LookAndFeel.installBorder(frame, "InternalFrame.border");
}
+ /**
+ * Install the keyboard actions.
+ */
protected void installKeyboardActions(){
createInternalFrameListener();
if (internalFrameListener != null) {
frame.addInternalFrameListener(internalFrameListener);
}
*** 182,199 ****
--- 214,235 ----
// Set the ActionMap's parent to the Auditory Feedback Action Map
BasicLookAndFeel.installAudioActionMap(map);
}
+ /**
+ * Installs the components.
+ */
protected void installComponents(){
setNorthPane(createNorthPane(frame));
setSouthPane(createSouthPane(frame));
setEastPane(createEastPane(frame));
setWestPane(createWestPane(frame));
}
/**
+ * Installs the listeners.
* @since 1.3
*/
protected void installListeners() {
borderListener = createBorderListener(frame);
propertyChangeListener = createPropertyChangeListener();
*** 255,274 ****
--- 291,316 ----
}
}
return null;
}
+ /**
+ * Uninstall the defaults.
+ */
protected void uninstallDefaults() {
Icon frameIcon = frame.getFrameIcon();
if (frameIcon instanceof UIResource) {
frame.setFrameIcon(null);
}
internalFrameLayout = null;
frame.setLayout(null);
LookAndFeel.uninstallBorder(frame);
}
+ /**
+ * Uninstall the components.
+ */
protected void uninstallComponents(){
setNorthPane(null);
setSouthPane(null);
setEastPane(null);
setWestPane(null);
*** 277,286 ****
--- 319,329 ----
}
titlePane = null;
}
/**
+ * Uninstall the listeners.
* @since 1.3
*/
protected void uninstallListeners() {
if ((frame.getParent() != null) && componentListenerAdded) {
frame.getParent().removeComponentListener(componentListener);
*** 296,305 ****
--- 339,351 ----
frame.removePropertyChangeListener(propertyChangeListener);
propertyChangeListener = null;
borderListener = null;
}
+ /**
+ * Uninstall the keyboard actions.
+ */
protected void uninstallKeyboardActions(){
if (internalFrameListener != null) {
frame.removeInternalFrameListener(internalFrameListener);
}
internalFrameListener = null;
*** 319,351 ****
s = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
}
frame.setCursor(s);
}
protected LayoutManager createLayoutManager(){
return getHandler();
}
protected PropertyChangeListener createPropertyChangeListener(){
return getHandler();
}
!
!
public Dimension getPreferredSize(JComponent x) {
if(frame == x)
return frame.getLayout().preferredLayoutSize(x);
return new Dimension(100, 100);
}
public Dimension getMinimumSize(JComponent x) {
if(frame == x) {
return frame.getLayout().minimumLayoutSize(x);
}
return new Dimension(0, 0);
}
public Dimension getMaximumSize(JComponent x) {
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
--- 365,418 ----
s = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
}
frame.setCursor(s);
}
+ /**
+ * Creates the layout manager.
+ * @return the layout manager
+ */
protected LayoutManager createLayoutManager(){
return getHandler();
}
+ /**
+ * Creates the property change listener.
+ * @return the property change listener
+ */
protected PropertyChangeListener createPropertyChangeListener(){
return getHandler();
}
! /**
! * Returns the preferred size.
! * @param x the component
! * @return the preferred size
! */
public Dimension getPreferredSize(JComponent x) {
if(frame == x)
return frame.getLayout().preferredLayoutSize(x);
return new Dimension(100, 100);
}
+ /**
+ * Returns the minimum size.
+ * @param x the component
+ * @return the minimum size
+ */
public Dimension getMinimumSize(JComponent x) {
if(frame == x) {
return frame.getLayout().minimumLayoutSize(x);
}
return new Dimension(0, 0);
}
+ /**
+ * Returns the maximum size.
+ * @param x the component
+ * @return the maximum size
+ */
public Dimension getMaximumSize(JComponent x) {
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
*** 369,432 ****
frame.add(newPane);
installMouseHandlers(newPane);
}
}
protected void deinstallMouseHandlers(JComponent c) {
c.removeMouseListener(borderListener);
c.removeMouseMotionListener(borderListener);
}
protected void installMouseHandlers(JComponent c) {
c.addMouseListener(borderListener);
c.addMouseMotionListener(borderListener);
}
protected JComponent createNorthPane(JInternalFrame w) {
titlePane = new BasicInternalFrameTitlePane(w);
return titlePane;
}
protected JComponent createSouthPane(JInternalFrame w) {
return null;
}
protected JComponent createWestPane(JInternalFrame w) {
return null;
}
protected JComponent createEastPane(JInternalFrame w) {
return null;
}
!
protected MouseInputAdapter createBorderListener(JInternalFrame w) {
return new BorderListener();
}
protected void createInternalFrameListener(){
internalFrameListener = getHandler();
}
protected final boolean isKeyBindingRegistered(){
return keyBindingRegistered;
}
protected final void setKeyBindingRegistered(boolean b){
keyBindingRegistered = b;
}
public final boolean isKeyBindingActive(){
return keyBindingActive;
}
protected final void setKeyBindingActive(boolean b){
keyBindingActive = b;
}
protected void setupMenuOpenKey(){
// PENDING(hania): Why are these WHEN_IN_FOCUSED_WINDOWs? Shouldn't
// they be WHEN_ANCESTOR_OF_FOCUSED_COMPONENT?
// Also, no longer registering on the desktopicon, the previous
// action did nothing.
--- 436,553 ----
frame.add(newPane);
installMouseHandlers(newPane);
}
}
+ /**
+ * Deinstalls the mouse handlers.
+ * @param c the component
+ */
protected void deinstallMouseHandlers(JComponent c) {
c.removeMouseListener(borderListener);
c.removeMouseMotionListener(borderListener);
}
+ /**
+ * Installs the mouse handlers.
+ * @param c the component
+ */
protected void installMouseHandlers(JComponent c) {
c.addMouseListener(borderListener);
c.addMouseMotionListener(borderListener);
}
+ /**
+ * Creates the north pane.
+ * @param w the internal frame
+ * @return the north pane
+ */
protected JComponent createNorthPane(JInternalFrame w) {
titlePane = new BasicInternalFrameTitlePane(w);
return titlePane;
}
+ /**
+ * Creates the north pane.
+ * @param w the internal frame
+ * @return the north pane
+ */
protected JComponent createSouthPane(JInternalFrame w) {
return null;
}
+ /**
+ * Creates the west pane.
+ * @param w the internal frame
+ * @return the west pane
+ */
protected JComponent createWestPane(JInternalFrame w) {
return null;
}
+ /**
+ * Creates the east pane.
+ * @param w the internal frame
+ * @return the east pane
+ */
protected JComponent createEastPane(JInternalFrame w) {
return null;
}
! /**
! * Creates the border listener.
! * @param w the internal frame
! * @return the border listener
! */
protected MouseInputAdapter createBorderListener(JInternalFrame w) {
return new BorderListener();
}
+ /**
+ * Creates the internal frame listener.
+ */
protected void createInternalFrameListener(){
internalFrameListener = getHandler();
}
+ /**
+ * Returns whether or no the key binding is registered.
+ * @return whether or no the key binding is registered
+ */
protected final boolean isKeyBindingRegistered(){
return keyBindingRegistered;
}
+ /**
+ * Sets the key binding registration.
+ * @param b new value for key binding registration
+ */
protected final void setKeyBindingRegistered(boolean b){
keyBindingRegistered = b;
}
+ /**
+ * Returns whether or no the key binding is active.
+ * @return whether or no the key binding is active
+ */
public final boolean isKeyBindingActive(){
return keyBindingActive;
}
+ /**
+ * Sets the key binding activity.
+ * @param b new value for key binding activity
+ */
protected final void setKeyBindingActive(boolean b){
keyBindingActive = b;
}
+ /**
+ * Setup the menu open key.
+ */
protected void setupMenuOpenKey(){
// PENDING(hania): Why are these WHEN_IN_FOCUSED_WINDOWs? Shouldn't
// they be WHEN_ANCESTOR_OF_FOCUSED_COMPONENT?
// Also, no longer registering on the desktopicon, the previous
// action did nothing.
*** 435,451 ****
--- 556,583 ----
JComponent.WHEN_IN_FOCUSED_WINDOW, map);
//ActionMap actionMap = getActionMap();
//SwingUtilities.replaceUIActionMap(frame, actionMap);
}
+ /**
+ * Setup the menu close key.
+ */
protected void setupMenuCloseKey(){
}
+ /**
+ * Returns the north pane.
+ * @return the north pane
+ */
public JComponent getNorthPane() {
return northPane;
}
+ /**
+ * Set the north pane.
+ * @param c the new north pane
+ */
public void setNorthPane(JComponent c) {
if (northPane != null &&
northPane instanceof BasicInternalFrameTitlePane) {
((BasicInternalFrameTitlePane)northPane).uninstallListeners();
}
*** 454,487 ****
--- 586,646 ----
if (c instanceof BasicInternalFrameTitlePane) {
titlePane = (BasicInternalFrameTitlePane)c;
}
}
+ /**
+ * Returns the south pane.
+ * @return the south pane
+ */
public JComponent getSouthPane() {
return southPane;
}
+ /**
+ * Set the south pane.
+ * @param c the new south pane
+ */
public void setSouthPane(JComponent c) {
southPane = c;
}
+ /**
+ * Returns the west pane.
+ * @return the west pane
+ */
public JComponent getWestPane() {
return westPane;
}
+ /**
+ * Set the west pane.
+ * @param c the new west pane
+ */
public void setWestPane(JComponent c) {
westPane = c;
}
+ /**
+ * Returns the east pane.
+ * @return the east pane
+ */
public JComponent getEastPane() {
return eastPane;
}
+ /**
+ * Set the east pane.
+ * @param c the new east pane
+ */
public void setEastPane(JComponent c) {
eastPane = c;
}
+ /**
+ * Internal frame property change listener.
+ */
public class InternalFramePropertyChangeListener implements
PropertyChangeListener {
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
*** 493,523 ****
--- 652,700 ----
public void propertyChange(PropertyChangeEvent evt) {
getHandler().propertyChange(evt);
}
}
+ /**
+ * Internal frame layout.
+ */
public class InternalFrameLayout implements LayoutManager {
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
+ /**
+ * {@inheritDoc}
+ */
public void addLayoutComponent(String name, Component c) {
getHandler().addLayoutComponent(name, c);
}
+ /**
+ * {@inheritDoc}
+ */
public void removeLayoutComponent(Component c) {
getHandler().removeLayoutComponent(c);
}
+ /**
+ * {@inheritDoc}
+ */
public Dimension preferredLayoutSize(Container c) {
return getHandler().preferredLayoutSize(c);
}
+ /**
+ * {@inheritDoc}
+ */
public Dimension minimumLayoutSize(Container c) {
return getHandler().minimumLayoutSize(c);
}
+ /**
+ * {@inheritDoc}
+ */
public void layoutContainer(Container c) {
getHandler().layoutContainer(c);
}
}
*** 525,544 ****
--- 702,726 ----
/**
* Returns the proper DesktopManager. Calls getDesktopPane() to
* find the JDesktop component and returns the desktopManager from
* it. If this fails, it will return a default DesktopManager that
* should work in arbitrary parents.
+ * @return the proper DesktopManager
*/
protected DesktopManager getDesktopManager() {
if(frame.getDesktopPane() != null
&& frame.getDesktopPane().getDesktopManager() != null)
return frame.getDesktopPane().getDesktopManager();
if(sharedDesktopManager == null)
sharedDesktopManager = createDesktopManager();
return sharedDesktopManager;
}
+ /**
+ * Creates the desktop manager.
+ * @return the desktop manager
+ */
protected DesktopManager createDesktopManager(){
return new DefaultDesktopManager();
}
/**
*** 651,661 ****
// __x & __y are the mousePressed location in source view's coordinate system
int __x, __y;
Rectangle startingBounds;
int resizeDir;
!
protected final int RESIZE_NONE = 0;
private boolean discardRelease = false;
int resizeCornerSize = 16;
--- 833,843 ----
// __x & __y are the mousePressed location in source view's coordinate system
int __x, __y;
Rectangle startingBounds;
int resizeDir;
! /** resize none */
protected final int RESIZE_NONE = 0;
private boolean discardRelease = false;
int resizeCornerSize = 16;
*** 1112,1217 ****
updateFrameCursor();
}
} /// End BorderListener Class
protected class ComponentHandler implements ComponentListener {
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
/** Invoked when a JInternalFrame's parent's size changes. */
public void componentResized(ComponentEvent e) {
getHandler().componentResized(e);
}
public void componentMoved(ComponentEvent e) {
getHandler().componentMoved(e);
}
public void componentShown(ComponentEvent e) {
getHandler().componentShown(e);
}
public void componentHidden(ComponentEvent e) {
getHandler().componentHidden(e);
}
}
protected ComponentListener createComponentListener() {
return getHandler();
}
protected class GlassPaneDispatcher implements MouseInputListener {
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
public void mousePressed(MouseEvent e) {
getHandler().mousePressed(e);
}
public void mouseEntered(MouseEvent e) {
getHandler().mouseEntered(e);
}
public void mouseMoved(MouseEvent e) {
getHandler().mouseMoved(e);
}
public void mouseExited(MouseEvent e) {
getHandler().mouseExited(e);
}
public void mouseClicked(MouseEvent e) {
getHandler().mouseClicked(e);
}
public void mouseReleased(MouseEvent e) {
getHandler().mouseReleased(e);
}
public void mouseDragged(MouseEvent e) {
getHandler().mouseDragged(e);
}
}
protected MouseInputListener createGlassPaneDispatcher() {
return null;
}
!
protected class BasicInternalFrameListener implements InternalFrameListener
{
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
public void internalFrameClosing(InternalFrameEvent e) {
getHandler().internalFrameClosing(e);
}
public void internalFrameClosed(InternalFrameEvent e) {
getHandler().internalFrameClosed(e);
}
public void internalFrameOpened(InternalFrameEvent e) {
getHandler().internalFrameOpened(e);
}
public void internalFrameIconified(InternalFrameEvent e) {
getHandler().internalFrameIconified(e);
}
public void internalFrameDeiconified(InternalFrameEvent e) {
getHandler().internalFrameDeiconified(e);
}
public void internalFrameActivated(InternalFrameEvent e) {
getHandler().internalFrameActivated(e);
}
!
public void internalFrameDeactivated(InternalFrameEvent e) {
getHandler().internalFrameDeactivated(e);
}
}
--- 1294,1465 ----
updateFrameCursor();
}
} /// End BorderListener Class
+ /**
+ * Component handler.
+ */
protected class ComponentHandler implements ComponentListener {
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
/** Invoked when a JInternalFrame's parent's size changes. */
public void componentResized(ComponentEvent e) {
getHandler().componentResized(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void componentMoved(ComponentEvent e) {
getHandler().componentMoved(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void componentShown(ComponentEvent e) {
getHandler().componentShown(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void componentHidden(ComponentEvent e) {
getHandler().componentHidden(e);
}
}
+ /**
+ * Creates a component listener.
+ * @return a component listener
+ */
protected ComponentListener createComponentListener() {
return getHandler();
}
+ /**
+ * Glass pane dispatcher.
+ */
protected class GlassPaneDispatcher implements MouseInputListener {
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
+ /**
+ * {@inheritDoc}
+ */
public void mousePressed(MouseEvent e) {
getHandler().mousePressed(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void mouseEntered(MouseEvent e) {
getHandler().mouseEntered(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void mouseMoved(MouseEvent e) {
getHandler().mouseMoved(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void mouseExited(MouseEvent e) {
getHandler().mouseExited(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void mouseClicked(MouseEvent e) {
getHandler().mouseClicked(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void mouseReleased(MouseEvent e) {
getHandler().mouseReleased(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void mouseDragged(MouseEvent e) {
getHandler().mouseDragged(e);
}
}
+ /**
+ * Creates a {@code GlassPaneDispatcher}.
+ * @return a {@code GlassPaneDispatcher}
+ */
protected MouseInputListener createGlassPaneDispatcher() {
return null;
}
! /**
! * Basic internal frame listener.
! */
protected class BasicInternalFrameListener implements InternalFrameListener
{
// NOTE: This class exists only for backward compatibility. All
// its functionality has been moved into Handler. If you need to add
// new functionality add it to the Handler, but make sure this
// class calls into the Handler.
+ /**
+ * {@inheritDoc}
+ */
public void internalFrameClosing(InternalFrameEvent e) {
getHandler().internalFrameClosing(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void internalFrameClosed(InternalFrameEvent e) {
getHandler().internalFrameClosed(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void internalFrameOpened(InternalFrameEvent e) {
getHandler().internalFrameOpened(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void internalFrameIconified(InternalFrameEvent e) {
getHandler().internalFrameIconified(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void internalFrameDeiconified(InternalFrameEvent e) {
getHandler().internalFrameDeiconified(e);
}
+ /**
+ * {@inheritDoc}
+ */
public void internalFrameActivated(InternalFrameEvent e) {
getHandler().internalFrameActivated(e);
}
! /**
! * {@inheritDoc}
! */
public void internalFrameDeactivated(InternalFrameEvent e) {
getHandler().internalFrameDeactivated(e);
}
}
< prev index next >