javax.swing.text.html
Class FrameView

java.lang.Object
  extended byjavax.swing.text.View
      extended byjavax.swing.text.ComponentView
          extended byjavax.swing.text.html.FrameView
All Implemented Interfaces:
EventListener, HyperlinkListener, SwingConstants

class FrameView
extends ComponentView
implements HyperlinkListener

Implements a FrameView, intended to support the HTML <FRAME> tag. Supports the frameborder, scrolling, marginwidth and marginheight attributes.

Author:
Sunita Mani

Nested Class Summary
private  class FrameView.FrameEditorPane
          Editor pane rendering frame of HTML document It uses the same editor kits classes as outermost JEditorPane
 
Nested classes inherited from class javax.swing.text.ComponentView
 
Field Summary
private  boolean createdComponent
          Set to true when the component has been created.
(package private)  boolean editable
           
(package private)  float height
           
(package private)  JEditorPane htmlPane
           
(package private)  JScrollPane scroller
           
(package private)  URL src
           
(package private)  float width
           
 
Fields inherited from class javax.swing.text.ComponentView
 
Fields inherited from class javax.swing.text.View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
FrameView(Element elem)
          Creates a new Frame.
 
Method Summary
 void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
          Gives notification from the document that attributes were changed in a location that this view is responsible for.
protected  Component createComponent()
          Create the component that is associated with this view.
private  void createScrollPane()
          This method creates the JScrollPane.
(package private)  JEditorPane getHostPane()
           
 float getMaximumSpan(int axis)
          Determines the maximum span for this view along an axis.
 float getMinimumSpan(int axis)
          Determines the minimum span for this view along an axis.
private  JEditorPane getOutermostJEditorPane()
          Finds the outermost FrameSetView.
 void hyperlinkUpdate(HyperlinkEvent evt)
          Notification of a change relative to a hyperlink.
private  boolean inNestedFrameSet()
          Returns true if this frame is contained within a nested frameset.
 void paint(Graphics g, Shape allocation)
          Also determines if the FrameView should be editable or not based on whether the JTextComponent that contains it is editable.
private  void setBorder()
          If the frameborder attribute has been specified, either in the frame, or by the frames enclosing frameset, the JScrollPane's setBorder() method is invoked to achieve the desired look.
private  void setMargin()
          If the marginwidth or marginheight attributes have been specified, then the JEditorPane's margin's are set to the new values.
 void setParent(View parent)
          Sets the parent view for the FrameView.
 
Methods inherited from class javax.swing.text.ComponentView
getAlignment, getComponent, getPreferredSpan, modelToView, viewToModel
 
Methods inherited from class javax.swing.text.View
append, breakView, createFragment, forwardUpdate, forwardUpdateToView, getAttributes, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getGraphics, getNextVisualPositionFrom, getParent, getResizeWeight, getStartOffset, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, insertUpdate, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, removeUpdate, replace, setSize, updateChildren, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

htmlPane

JEditorPane htmlPane

scroller

JScrollPane scroller

editable

boolean editable

width

float width

height

float height

src

URL src

createdComponent

private boolean createdComponent
Set to true when the component has been created.

Constructor Detail

FrameView

public FrameView(Element elem)
Creates a new Frame.

Parameters:
elem - the element to represent.
Method Detail

createComponent

protected Component createComponent()
Description copied from class: ComponentView
Create the component that is associated with this view. This will be called when it has been determined that a new component is needed. This would result from a call to setParent or as a result of being notified that attributes have changed.

Overrides:
createComponent in class ComponentView

getHostPane

JEditorPane getHostPane()

setParent

public void setParent(View parent)
Sets the parent view for the FrameView. Also determines if the FrameView should be editable or not based on whether the JTextComponent that contains it is editable.

Overrides:
setParent in class ComponentView
Parameters:
parent - View

paint

public void paint(Graphics g,
                  Shape allocation)
Also determines if the FrameView should be editable or not based on whether the JTextComponent that contains it is editable. And then proceeds to call the superclass to do the paint().

Overrides:
paint in class ComponentView
Parameters:
g - the graphics context
allocation - the shape
See Also:
text.ComponentView#paint

setMargin

private void setMargin()
If the marginwidth or marginheight attributes have been specified, then the JEditorPane's margin's are set to the new values.


setBorder

private void setBorder()
If the frameborder attribute has been specified, either in the frame, or by the frames enclosing frameset, the JScrollPane's setBorder() method is invoked to achieve the desired look.


createScrollPane

private void createScrollPane()
This method creates the JScrollPane. The scrollbar policy is determined by the scrolling attribute. If not defined, the default is "auto" which maps to the scrollbar's being displayed as needed.


getOutermostJEditorPane

private JEditorPane getOutermostJEditorPane()
Finds the outermost FrameSetView. It then returns that FrameSetView's container.


inNestedFrameSet

private boolean inNestedFrameSet()
Returns true if this frame is contained within a nested frameset.


hyperlinkUpdate

public void hyperlinkUpdate(HyperlinkEvent evt)
Notification of a change relative to a hyperlink. This method searches for the outermost JEditorPane, and then fires an HTMLFrameHyperlinkEvent to that frame. In addition, if the target is _parent, and there is not nested framesets then the target is reset to _top. If the target is _top, in addition to firing the event to the outermost JEditorPane, this method also invokes the setPage() method and explicitly replaces the current document with the destination url.

Specified by:
hyperlinkUpdate in interface HyperlinkListener
Parameters:
evt - the event responsible for the update

changedUpdate

public void changedUpdate(DocumentEvent e,
                          Shape a,
                          ViewFactory f)
Gives notification from the document that attributes were changed in a location that this view is responsible for. Currently this view handles changes to its SRC attribute.

Overrides:
changedUpdate in class View
Parameters:
e - the change information from the associated document
a - the current allocation of the view
f - the factory to use to rebuild if the view has children
See Also:
View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)

getMinimumSpan

public float getMinimumSpan(int axis)
Determines the minimum span for this view along an axis.

Overrides:
getMinimumSpan in class ComponentView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the preferred span; given that we do not support resizing of frames, the minimum span returned is the same as the preferred span

getMaximumSpan

public float getMaximumSpan(int axis)
Determines the maximum span for this view along an axis.

Overrides:
getMaximumSpan in class ComponentView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the preferred span; given that we do not support resizing of frames, the maximum span returned is the same as the preferred span