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

📄 filenamedialog.java

📁 It is the Speech recognition software. It is platform independent. To execute the source code,
💻 JAVA
字号:
/* * Copyright 1999-2004 Carnegie Mellon University.   * Portions Copyright 2002-2004 Sun Microsystems, Inc.   * Portions Copyright 2002-2004 Mitsubishi Electric Research Laboratories. * All Rights Reserved.  Use is subject to license terms. *  * See the file "license.terms" for information on usage and * redistribution of this file, and for a DISCLAIMER OF ALL  * WARRANTIES. * */package edu.cmu.sphinx.tools.audio;import java.awt.Container;import java.awt.Frame;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JTextField;/** * Creates a dialog that prompts for a filename. */public class FilenameDialog extends JDialog {    String action;    JTextField filename;    /**     * Class constructor.     *     * @param parent the parent of this dialog     * @param modal if true, this dialog box is modal     * @param title the title for the login box     */    public FilenameDialog(Frame parent,                          boolean modal,                          String title) {        super(parent, modal);        setTitle(title);        addWindowListener(new WindowAdapter () {                public void windowClosing(WindowEvent event) {                    setVisible(false);                }            });                createFilenamePanel();        pack();    }    /**     * Creates the filename panel.     */    void createFilenamePanel() {        Container contentPane = getContentPane();        GridBagLayout gridBag = new GridBagLayout();        GridBagConstraints constraints;        Insets insets;                contentPane.setLayout(gridBag);        filename = new JTextField(12);        JLabel filenameLabel = new JLabel("Filename:");        filenameLabel.setLabelFor(filename);        insets = new Insets(12, 12, 0, 0);  // top, left, bottom, right        constraints = new GridBagConstraints(            0, 0, 1, 1,                     // x, y, width, height            0.0, 0.0,                       // weightx, weighty            GridBagConstraints.WEST,        // anchor            GridBagConstraints.NONE,        // fill            insets,                         // insets            0, 0);                          // ipadx, ipady                gridBag.setConstraints(filenameLabel, constraints);        contentPane.add(filenameLabel);                insets = new Insets(12, 7, 0, 12);  // top, left, bottom, right        constraints = new GridBagConstraints(            1, 0, 1, 1,                     // x, y, width, height            1.0, 1.0,                       // weightx, weighty            GridBagConstraints.WEST,        // anchor            GridBagConstraints.HORIZONTAL,  // fill            insets,                         // insets            0, 0);                          // ipadx, ipady        gridBag.setConstraints(filename, constraints);        contentPane.add(filename);        /* BUTTON PANEL         */        JButton okButton = new JButton("Save");        okButton.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent event) {                    setVisible(false);                }            });                insets = new Insets(0, 12, 12, 12); // top, left, bottom, right        constraints = new GridBagConstraints(            0, 2, 2, 1,                     // x, y, width, height            1.0, 1.0,                       // weightx, weighty            GridBagConstraints.EAST,        // anchor            GridBagConstraints.NONE,        // fill            insets,                         // insets            0, 0);                          // ipadx, ipady        gridBag.setConstraints(okButton, constraints);        contentPane.add(okButton);                getRootPane().setDefaultButton(okButton);            }    /**     * Gets the user ID.     *     * @return the user ID     */    public String getFilename() {        return filename.getText();    }        /**     * Debug and example use.     */    public static void main(String args[]) {        JFrame frame = new JFrame();        frame.setTitle("Debug");        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        frame.pack();        frame.setVisible(false);                FilenameDialog dialog = new FilenameDialog(frame, true, "Save as...");        System.out.println("Showing dialog...");        dialog.setVisible(true);        String filename = dialog.getFilename();        System.out.println("Filename: " + filename                           + " (length = " + filename.length() + ")");        System.exit(0);    }     }

⌨️ 快捷键说明

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