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

📄 264-267.html

📁 java game programming e-book
💻 HTML
字号:
<HTML>
<HEAD>
<META name=vsisbn content="1571690433"><META name=vstitle content="Black Art of Java Game Programming"><META name=vsauthor content="Joel Fan"><META name=vsimprint content="Sams"><META name=vspublisher content="Macmillan Computer Publishing"><META name=vspubdate content="11/01/96"><META name=vscategory content="Web and Software Development: Programming, Scripting, and Markup Languages: Java"><TITLE>Black Art of Java Game Programming:Creating Customizable Games with the AWT</TITLE>
<!-- HEADER --><STYLE type="text/css">  <!-- A:hover  { 	color : Red; } --></STYLE><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><script><!--function displayWindow(url, width, height) {         var Win = window.open(url,"displayWindow",'width=' + width +',height=' + height + ',resizable=1,scrollbars=yes');	if (Win) {		Win.focus();	}}//--></script><SCRIPT><!--function popUp(url) {        var Win = window.open(url,"displayWindow",'width=400,height=300,resizable=1,scrollbars=yes');	if (Win) {		Win.focus();	}}//--></SCRIPT><script language="JavaScript1.2"><!--function checkForQuery(fm) {  /* get the query value */  var i = escape(fm.query.value);  if (i == "") {      alert('Please enter a search word or phrase');      return false;  }                  /* query is blank, dont run the .jsp file */  else return true;  /* execute the .jsp file */}//--></script></HEAD><BODY> 
<TABLE border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=75 valign=top>
<img src="../1571690433.gif" width=60 height=73 alt="Black Art of Java Game Programming" border="1">
</td>
<td align="left">
    <font face="arial, helvetica" size="-1" color="#336633"><b>Black Art of Java Game Programming</b></font>
    <br>
    <font face="arial, helvetica" size="-1"><i>by Joel Fan</i>
    <br>
    Sams,&nbsp;Macmillan Computer Publishing
    <br>
    <b>ISBN:</b>&nbsp;1571690433<b>&nbsp;&nbsp;&nbsp;Pub Date:</b>&nbsp;11/01/96</font>&nbsp;&nbsp;
</td>
</tr>
</table>
<P>

<!--ISBN=1571690433//-->
<!--TITLE=Black Art of Java Game Programming//-->
<!--AUTHOR=Joel Fan//-->
<!--AUTHOR=Eric Ries//-->
<!--AUTHOR=Calin Tenitchi//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=7//-->
<!--PAGES=264-267//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="260-264.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="267-272.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading34"></A><FONT COLOR="#000077">The Component and Container Classes</FONT></H4>
<P>Table 7-11 lists some selected Component methods. These methods are sometimes overridden by the subclasses of Component, so their exact behavior varies. You&#146;ve used most of these methods in this chapter, or in applets from previous chapters (remember, an applet is a Component too!). The key and mouse event handlers discussed in Chapter 4, Adding Interactivity, such as keyUp(), keyDown(), mouseUp(), and mouseDown(), are Component methods that are called by handleEvent().
</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 7-11</B> Component methods
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="50%" ALIGN="LEFT">Component Methods
<TH WIDTH="50%" ALIGN="LEFT" VALIGN="BOTTOM">Purpose
<TR>
<TD COLSPAN="2"><HR>
<TR>
<TD>public boolean action(Event e, Object o);
<TD>Handles action events
<TR>
<TD>public Rectangle bounds();
<TD>Returns bounding rectangle of component
<TR>
<TD>public synchronized void disable();
<TD>Disables component from receiving input
<TR>
<TD>public synchronized void enable();
<TD>Enables component to receive input
<TR>
<TD>public Color getBackground();
<TD>Gets background color
<TR>
<TD>public Font getFont();
<TD>Gets the font
<TR>
<TD>public Graphics getGraphics();
<TD>Gets the Graphics context
<TR>
<TD>public Container getParent();
<TD>Gets the parent container
<TR>
<TD>public boolean handleEvent(Event e);
<TD>The default event handler
<TR>
<TD>public synchronized void hide();
<TD>Hides component
<TR>
<TD>public void paint(Graphics g);
<TD>Paints the component
<TR>
<TD>public void repaint();
<TD>Repaints the component (calls update())
<TR>
<TD>public void resize(int width,int height);
<TD>Resizes the component
<TR>
<TD>public setBackground(Color c);
<TD>Sets the background color
<TR>
<TD>public setFont(Font f);
<TD>Sets the font
<TR>
<TD>public setForeground(Color c);
<TD>Sets the foreground color
<TR>
<TD>public synchronized void show();
<TD>Shows the component
<TR>
<TD>public void update(Graphics g);
<TD>Updates the component (calls paint())
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<P>Selected methods in the abstract class Container are listed in Table 7-12.
</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 7-12</B> Container methods
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="60%" ALIGN="LEFT">Container Methods
<TH WIDTH="40%" ALIGN="LEFT" VALIGN="BOTTOM">Purpose
<TR>
<TD COLSPAN="2"><HR>
<TR>
<TD>public Component add(Component c);
<TD>Adds the specified component
<TR>
<TD VALIGN="TOP">public Component add(String s,Component c);
<TD>Adds component with String argument
<TR>
<TD>public Insets insets();
<TD>Creates insets
<TR>
<TD VALIGN="TOP">public void setLayout(LayoutManager m);
<TD>Uses the specified layout manager
<TR>
<TD VALIGN="TOP">public synchronized void remove(Component c);
<TD>Removes the specified component
<TR>
<TD VALIGN="TOP">public synchronized void removeAll();
<TD>Removes all components from container
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<H4 ALIGN="LEFT"><A NAME="Heading35"></A><FONT COLOR="#000077">Components</FONT></H4>
<P>Table 7-13 lists the components we&#146;ve discussed in this chapter and selected methods that are available. Remember that these classes also inherit the Component methods listed above.
</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 7-13</B> Components
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="40%" ALIGN="LEFT">Class
<TH WIDTH="60%" ALIGN="LEFT" VALIGN="BOTTOM">Methods
<TR>
<TD COLSPAN="2"><HR>
<TR>
<TD VALIGN="TOP">Button
<TD>public Button();
<TR>
<TD>
<TD>public Button(String label);
<TR>
<TD>
<TD>public String getLabel();
<TR>
<TD>
<TD>public void setLabel(String label);
<TR>
<TD>Checkbox
<TD>public Checkbox();
<TR>
<TD>
<TD>public Checkbox(String label);
<TR>
<TD>
<TD>public Checkbox(String label,
<TR>
<TD>
<TD>CheckboxGroup group,boolean state);
<TR>
<TD>
<TD>public String getLabel();
<TR>
<TD>
<TD>public boolean getState();
<TR>
<TD>
<TD>public void setLabel(String label);
<TR>
<TD>
<TD>public void setState(booleanstate);
<TR>
<TD>CheckboxGroup
<TD>public CheckboxGroup();
<TR>
<TD>
<TD>public Checkbox getCurrent();
<TR>
<TD>
<TD>public synchronized void
<TR>
<TD>
<TD>setCurrent(Checkbox box);
<TR>
<TD>Label
<TD>public Label();
<TR>
<TD>
<TD>public Label(String label);
<TR>
<TD>
<TD>public Label(String label,int alignment);
<TR>
<TD>
<TD>public int getAlignment();
<TR>
<TD>
<TD>public String getText();
<TR>
<TD>
<TD>public void setAlignment(intalignment);
<TR>
<TD>
<TD>public void setText(String label);
<TR>
<TD>TextField
<TD>public Textfield();
<TR>
<TD>
<TD>public Textfield(int size);
<TR>
<TD>
<TD>public Textfield(String text,intsize);
<TR>
<TD>
<TD>public String getText(); //
<TR>
<TD>
<TD>inherited from TextComponent
<TR>
<TD>
<TD>public setText(String text); //
<TR>
<TD>
<TD>inherited from TextComponent
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<H4 ALIGN="LEFT"><A NAME="Heading36"></A><FONT COLOR="#000077">Containers</FONT></H4>
<P>Table 7-14 lists the containers discussed in this chapter and selected methods that are available.
</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 7-14</B> Container classes
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="40%" ALIGN="LEFT">Container
<TH WIDTH="60%" ALIGN="LEFT" VALIGN="BOTTOM">Methods
<TR>
<TD COLSPAN="2"><HR>
<TR>
<TD>Dialog
<TD>public Dialog(Frame parent,boolean modal);
<TR>
<TD>
<TD>public Dialog(Frame parent,String title,boolean modal);
<TR>
<TD>
<TD>public synchronized void dispose(); //
<TR>
<TD>
<TD>inherited from Window
<TR>
<TD>
<TD>public boolean isModal();
<TR>
<TD>
<TD>public boolean isResizable();
<TR>
<TD>
<TD>public synchronized void pack(); //
<TR>
<TD>
<TD>inherited from Window
<TR>
<TD>
<TD>public void setResizable(boolean b);
<TR>
<TD>Frame
<TD>public Frame();
<TR>
<TD>
<TD>public Frame(String title);
<TR>
<TD>
<TD>public synchronized void dispose(); //
<TR>
<TD>
<TD>overrides dispose() from Window
<TR>
<TD>
<TD>public MenuBar getMenuBar();
<TR>
<TD>
<TD>public boolean isResizable();
<TR>
<TD>
<TD>public synchronized void pack(); //
<TR>
<TD>
<TD>inherited from Window
<TR>
<TD>
<TD>public void setCursor(int cursorType);
<TR>
<TD>
<TD>public synchronized void
<TR>
<TD>
<TD>setMenuBar(MenuBar mb);
<TR>
<TD>
<TD>public void setResizable(boolean b);
<TR>
<TD>Panel
<TD>public Panel();
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<H4 ALIGN="LEFT"><A NAME="Heading37"></A><FONT COLOR="#000077">Cursors</FONT></H4>
<P>Cursor types are static constants defined within the Frame class. To set the cursor, use the Frame method
</P>
<!-- CODE SNIP //-->
<PRE>
public void setCursor(int cursorType);
</PRE>
<!-- END CODE SNIP //-->
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="260-264.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="267-272.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>


</BODY>

⌨️ 快捷键说明

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