⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 142-145.html

📁 dshfghfhhgsfgfghfhfghgfhfghfgh fg hfg hh ghghf hgf hghg gh fg hg hfg hfh f hg hgfh gkjh kjkh g yj f
💻 HTML
字号:
<HTML>
<HEAD>
<META name=vsisbn content="1558515682"><META name=vstitle content="Java Digital Signal Processing"><META name=vsauthor content="Douglas A. Lyon"><META name=vsimprint content="M&T Books"><META name=vspublisher content="IDG Books Worldwide, Inc."><META name=vspubdate content="11/01/97"><META name=vscategory content="Web and Software Development: Programming, Scripting, and Markup Languages: Java"><TITLE>Java Digital Signal Processing:The Graphical User Interface</TITLE>
<!-- HEADER --><STYLE type="text/css">  <!-- A:hover  { 	color : Red; } --></STYLE><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<!--ISBN=1558515682//-->
<!--TITLE=Java Digital Signal Processing//-->
<!--AUTHOR=Douglas A. Lyon//-->
<!--PUBLISHER=IDG Books Worldwide, Inc.//-->
<!--IMPRINT=M & T Books//-->
<!--CHAPTER=3//-->
<!--PAGES=142-145//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="138-142.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="146-150.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>To paint the component and the subcomponents:
</P>
<!-- CODE SNIP //-->
<PRE>
component.paintAll(graphics);
</PRE>
<!-- END CODE SNIP //-->
<P>To schedule a call to update:
</P>
<!-- CODE SNIP //-->
<PRE>
component.repaint();
</PRE>
<!-- END CODE SNIP //-->
<P>To schedule a call to update for a specific interval:
</P>
<!-- CODE SNIP //-->
<PRE>
component.repaint(milliseconds);
component.repaint(x, y, width, height);
</PRE>
<!-- END CODE SNIP //-->
<P>To schedule a call to update for a part of the component in a specific time:
</P>
<!-- CODE SNIP //-->
<PRE>
component.repaint(milliseconds, x, y, width, height);
</PRE>
<!-- END CODE SNIP //-->
<P>To paint the component on the <I>graphics</I> context (typically overridden):</P>
<!-- CODE SNIP //-->
<PRE>
component.print(graphics);
</PRE>
<!-- END CODE SNIP //-->
<P>To invoke <I>print</I> on the component and subcomponents:</P>
<!-- CODE SNIP //-->
<PRE>
component.printAll(graphics);
</PRE>
<!-- END CODE SNIP //-->
<P>To repaint the component after the image has been delivered (typically called by an image observer and returns <I>false</I> if image has not changed):</P>
<!-- CODE SNIP //-->
<PRE>
aBoolean = component.imageUpdate(anImage, flags, x, y, width, height);
</PRE>
<!-- END CODE SNIP //-->
<P>To create an image from the image producer (see <I>ImageProducer</I> for more information):</P>
<!-- CODE SNIP //-->
<PRE>
anImage = component.createImage(anImageProducer);
</PRE>
<!-- END CODE SNIP //-->
<P>To create an off-screen image for double buffering:
</P>
<!-- CODE SNIP //-->
<PRE>
anImage = component.createImage(width, height);
</PRE>
<!-- END CODE SNIP //-->
<P>To prepare an image for display on the component (this starts a thread; see the <I>ImageObserver</I>):</P>
<!-- CODE SNIP //-->
<PRE>
component.prepareImage(anImage, anImageObservser);
</PRE>
<!-- END CODE SNIP //-->
<P>To prepare the image with a particular width and height:
</P>
<!-- CODE SNIP //-->
<PRE>
component.prepareImage(anImage, width, height, anImageObservser);
</PRE>
<!-- END CODE SNIP //-->
<P>To obtain the status of the screen representation of an image:
</P>
<!-- CODE SNIP //-->
<PRE>
statusInt = component.checkImage(anImage, anImageObserver);
</PRE>
<!-- END CODE SNIP //-->
<P>See <I>ImageObserver</I> to decode <I>statusInt</I>.</P>
<P>To get the status for an image to be scaled:</P>
<!-- CODE SNIP //-->
<PRE>
statusInt = component.checkImage(anImage, width, height,
 anImageObserver);
</PRE>
<!-- END CODE SNIP //-->
<P>To see whether a location is inside a component&#146;s borders relative to the component&#146;s coordinate system:
</P>
<!-- CODE SNIP //-->
<PRE>
aBoolean = component.inside(x,y);
</PRE>
<!-- END CODE SNIP //-->
<P>To get the component containing a location:
</P>
<!-- CODE SNIP //-->
<PRE>
component = locate( x, y);
</PRE>
<!-- END CODE SNIP //-->
<P>To post an event:
</P>
<!-- CODE SNIP //-->
<PRE>
component.deliverEvent(anEvent); // the same as postEvent(anEvent)
</PRE>
<!-- END CODE SNIP //-->
<P>To call <I>handleEvent</I> with an event on a component (or, if the component does not handle it, the parent of the component):</P>
<!-- CODE SNIP //-->
<PRE>
component.postEvent(anEvent);
</PRE>
<!-- END CODE SNIP //-->
<P>See the discussion in the preceding section for a description of the events and how to handle them.
</P>
<P>The component provides call backmethods:</P>
<!-- CODE //-->
<PRE>
    public boolean mouseDown(Event evt, int x, int y)
    public boolean mouseDrag(Event evt, int x, int y)
    public boolean mouseUp(Event evt, int x, int y)
    public boolean mouseMove(Event evt, int x, int y)
    public boolean mouseEnter(Event evt, int x, int y)
    public boolean mouseExit(Event evt, int x, int y)
    public boolean keyDown(Event evt, int key)
    public boolean keyUp(Event evt, int key)
    public boolean action(Event evt, Object what)
    public boolean gotFocus(Event evt, Object what)
    public boolean lostFocus(Event evt, Object what)
</PRE>
<!-- END CODE //-->
<P>An invocation of <I>show</I> or <I>pack</I> will call <I>addNotify</I> (the programmer typically does not make this call). <I>AddNotify</I> makes the component invalid and causes a peer to be created:</P>
<!-- CODE SNIP //-->
<PRE>
component.addNotify();
</PRE>
<!-- END CODE SNIP //-->
<P>To dispose of a components peer:
</P>
<!-- CODE SNIP //-->
<PRE>
component.removeNotify();
</PRE>
<!-- END CODE SNIP //-->
<P>To get the keyboard focus (i.e., keystrokes stream into your component):
</P>
<!-- CODE SNIP //-->
<PRE>
component.requestFocus();
</PRE>
<!-- END CODE SNIP //-->
<P>To advance the keyboard focus to the next component:
</P>
<!-- CODE SNIP //-->
<PRE>
component.nextFocus();
</PRE>
<!-- END CODE SNIP //-->
<P>To make a string representation of the component:
</P>
<!-- CODE SNIP //-->
<PRE>
component.toString();
</PRE>
<!-- END CODE SNIP //-->
<P>To invoke the <I>list</I> method on <I>System.out</I>:</P>
<!-- CODE SNIP //-->
<PRE>
component.list();
</PRE>
<!-- END CODE SNIP //-->
<P>To invoke the <I>list</I> method on a <I>PrintStream</I>:</P>
<!-- CODE SNIP //-->
<PRE>
component.list(aPrintStream);
</PRE>
<!-- END CODE SNIP //-->
<P>To call <I>toString</I> and print the component and all its children, with indentation:</P>
<!-- CODE SNIP //-->
<PRE>
component.list(aPrintStream, indent);
</PRE>
<!-- END CODE SNIP //-->
<H3><A NAME="Heading28"></A><FONT COLOR="#000077">The Container Class</FONT></H3>
<P>The <I>Container</I> class is an extension of the <I>Component</I> class that can hold <I>Component</I> instances. The instances that are added to an instance of a <I>Container</I> class are called <I>children</I>. The <I>Container</I> class that holds the children is called the <I>parent</I>. Because a container can hold other containers, a long line of descendants is possible. A parent can arrange the appearance of the children using a layout manager. Each child has its own layout manager. If a container (or its children) is not properly laid out, the layout is said to be invalid. A parent lays out the children and all their descendants during the layout process. Containers that are valid are not laid out needlessly.</P>
<P>The <I>Container</I> class structure is that of an AKO (a-kind-of) taxonomy. This is different from the <I>Container</I> hierarchy, which is based on has-a relationships. For example, a <I>Frame</I> has-a <I>Panel</I> that has-a <I>Checkbox</I>. Both a <I>Frame</I> and a <I>Panel</I> are kinds-of containers. Containers always have an <I>add</I> method that provides the implementation for adding either components or other containers to the has-a hierarchy. A <I>Container</I> instance can handle events with its own <I>handleEvent</I> implementation. Recall that <I>getParent</I> is inherited by any subclass of <I>Component</I> (such as the <I>Container</I> class).</P>
<H4 ALIGN="LEFT"><A NAME="Heading29"></A><FONT COLOR="#000077">Class Summary</FONT></H4>
<!-- CODE //-->
<PRE>
public abstract class Container extends Component
   public int countComponents()
   public synchronized Component getComponent(int n)
   public synchronized Component[] getComponents()
   public Insets insets()
   public Component add(Component comp)
   public synchronized Component add(Component comp, int pos)
   public synchronized Component add(String name, Component comp)
   public synchronized void remove(Component comp)
   public synchronized void removeAll()
   public LayoutManager getLayout()
   public void setLayout(LayoutManager mgr)
   public synchronized void layout()
   public synchronized void validate()
   public synchronized Dimension preferredSize()
   public synchronized Dimension minimumSize()
   public void paintComponents(Graphics g)
   public void printComponents(Graphics g)
   public void deliverEvent(Event e)
   public Component locate(int x, int y)
   public synchronized void addNotify()
   public synchronized void removeNotify()
   public void list(PrintStream out, int indent)
&#125;
</PRE>
<!-- END CODE //-->
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="138-142.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="146-150.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>

<hr width="90%" size="1" noshade><div align="center"><font face="Verdana,sans-serif" size="1">Copyright &copy; <a href="/reference/idgbooks00001.html">IDG Books Worldwide, Inc.</a></font></div>
<!-- all of the reference materials (books) have the footer and subfoot reveresed --><!-- reference_subfoot = footer --><!-- reference_footer = subfoot --></BODY></HTML><!-- END FOOTER -->

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -