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

📄 169-172.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:Futil Recipes for Feudal Times</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=4//-->
<!--PAGES=169-172//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch03/167-168.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="172-177.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 4<BR>Futil Recipes for Feudal Times
</FONT></H2>
<P ALIGN="RIGHT">From cooking meals for hungry hired men<BR>And washing dishes after them<BR><I>&#151;Robert Fros</I>t</P>
<P ALIGN="RIGHT">Resistance is Futil.<BR><I>&#151;Borg</I></P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR>This book comes with a package called <I>futils.</I><HR></FONT>
</BLOCKQUOTE>
<P>The <I>futils</I> package is a collection of file utilities that simplify the writing of user-friendly GUI-based code. The <I>java.io</I> package is responsible for enabling all input-output (I/O) operations in Java. The <I>java.io</I> consists of 31 class files. Eventually, programmers will want to learn them all. However, even seasoned programmers will want to develop a set of useful tools that are less general and therefore easier to use. The premise is that simplicity is inversely related to generality and that simplicity is a feature. Thus, the <I>futils</I> package presents a set of simple tools designed to be easy to use and to make compact code that is easy to read.</P>
<P>File utilities are considered to be unsafe because they can rename, copy, list, and even delete files. This is all the more reason that there should be a centralized package of well-tested and well-understood classes for file manipulation. Furthermore, because of security manager restrictions, most classes in the <I>futils</I> package are not run within a browser.</P>
<P>The <I>futils</I> package has several public final classes, each of which has several static methods. To gain access to these methods, type the following at the head of your Java source code:</P>
<!-- CODE SNIP //-->
<PRE>
import futils.*;
</PRE>
<!-- END CODE SNIP //-->
<P>The <I>Futil</I> class is a public final class that resides in the <I>futils</I> package. It contains a single private constructor that is used to prevent instantiation of the class. The <I>Futil</I> class is dependent on the <I>java.io</I> package.</P>
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">The Dialog Class</FONT></H3>
<P>An instance of a <I>Dialog</I> class is like a low-overhead <I>Frame</I> instance. A <I>Dialog</I> instance is resizable and has a title, a border, and a layout.</P>
<P>A <I>Dialog</I> instance has a <I>modal</I> property. When a <I>Dialog</I> instance is modal, the user is forced to interact with it. If a <I>Dialog</I> instance is not modal, the user can choose other <I>Window</I> instances (such as <I>Frame</I> instances). The default layout for a Dialog instance is <I>BorderLayout</I>.</P>
<H4 ALIGN="LEFT"><A NAME="Heading3"></A><FONT COLOR="#000077">Class Summary</FONT></H4>
<!-- CODE //-->
<PRE>
public class Dialog extends Window {
    public Dialog(Frame parent, boolean modal)
    public Dialog(Frame parent, String title, boolean modal)
    public synchronized void addNotify()
    public boolean isModal()
    public String getTitle()
    public void setTitle(String title)
    public boolean isResizable()
    public void setResizable(boolean resizable)
}
</PRE>
<!-- END CODE //-->
<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">Class Usage</FONT></H4>
<P>Suppose the following variables are predefined:
</P>
<!-- CODE SNIP //-->
<PRE>
String title;
boolean resizable, modal;
Dialog dialog;
Frame parent;
</PRE>
<!-- END CODE SNIP //-->
<P>To make an (initially invisible) instance of a <I>Dialog</I>, use this statement:</P>
<!-- CODE SNIP //-->
<PRE>
dialog = new Dialog(parent, modal);
</PRE>
<!-- END CODE SNIP //-->
<P>To make an (initially invisible) instance of a <I>Dialog</I> with a title:</P>
<!-- CODE SNIP //-->
<PRE>
dialog = new Dialog(parent, title, modal);
</PRE>
<!-- END CODE SNIP //-->
<P>To create a peer:
</P>
<!-- CODE SNIP //-->
<PRE>
dialog.addNotify();
</PRE>
<!-- END CODE SNIP //-->
<P>To see whether a <I>Dialog</I> instance is modal:</P>
<!-- CODE SNIP //-->
<PRE>
modal = dialog.isModal();
</PRE>
<!-- END CODE SNIP //-->
<P>To get and set the title:
</P>
<!-- CODE SNIP //-->
<PRE>
title = dialog.getTitle();
dialog.setTitle(title);
</PRE>
<!-- END CODE SNIP //-->
<P>To get and set the <I>resizable</I> property:</P>
<!-- CODE SNIP //-->
<PRE>
resizable = dialog.isResizable();
dialog.setResizable(resizable);
</PRE>
<!-- END CODE SNIP //-->
<H3><A NAME="Heading5"></A><FONT COLOR="#000077">The FileDialog Class</FONT></H3>
<P>The <I>FileDialog</I> class is a subclass of the <I>Dialog</I> class. Instances of <I>FileDialog</I> are used by the <I>futils</I> package to obtain file and directory information from the user. An instance of <I>FileDialog</I> will block the invoking thread when shown. The <I>FileDialog</I> class is always modal.</P>
<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">Class Summary</FONT></H4>
<!-- CODE //-->
<PRE>
public class FileDialog extends Dialog
    public static final int LOAD
    public static final int SAVE
    public FileDialog(Frame parent, String title)
    public FileDialog(Frame parent, String title, int mode)
    public synchronized void addNotify()
    public int getMode()
    public String getDirectory()
    public void setDirectory(String dir)
    public String getFile()
    public void setFile(String file)
    public FilenameFilter getFilenameFilter()
    public void setFilenameFilter(FilenameFilter filter)
}
</PRE>
<!-- END CODE //-->
<H4 ALIGN="LEFT"><A NAME="Heading7"></A><FONT COLOR="#000077">Class Usage</FONT></H4>
<P>Suppose the following variables are predefined:
</P>
<!-- CODE SNIP //-->
<PRE>
FileDialog fileDialog;
Frame parent;
String title, path;
int mode;
FileNameFilter filter;
</PRE>
<!-- END CODE SNIP //-->
<P><I>Mode</I> must be either <I>FileDialog.LOAD</I> or <I>FileDialog.SAVE</I>.</P>
<P>To create a <I>FileDialog</I> instance for reading a file, use:</P>
<!-- CODE SNIP //-->
<PRE>
fileDialog = new FileDialog(parent, title);
</PRE>
<!-- END CODE SNIP //-->
<P>To specify a mode during instantiation:
</P>
<!-- CODE SNIP //-->
<PRE>
fileDialog = new FileDialog(parent, title, mode);
</PRE>
<!-- END CODE SNIP //-->
<P>To get the mode:
</P>
<!-- CODE SNIP //-->
<PRE>
mode = fileDialog.getMode();
</PRE>
<!-- END CODE SNIP //-->
<P>To get and set the directory:
</P>
<!-- CODE SNIP //-->
<PRE>
path = fileDialog.getDirectory();
fileDialog.setDirectory(path);
</PRE>
<!-- END CODE SNIP //-->
<P>To get the file name:
</P>
<!-- CODE SNIP //-->
<PRE>
path = fileDialog.getFile();
</PRE>
<!-- END CODE SNIP //-->
<P>To set the default file name before the dialog box is shown:
</P>
<!-- CODE SNIP //-->
<PRE>
fileDialog.setFile(path);
</PRE>
<!-- END CODE SNIP //-->
<P>To get and set <I>FilenameFilter</I>:</P>
<!-- CODE SNIP //-->
<PRE>
filter = fileDialog.getFilenameFilter();
fileDialog.setFilenameFilter(filter);
</PRE>
<!-- END CODE SNIP //-->
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch03/167-168.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="172-177.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 + -