engineeventpanel.java
来自「It is the Speech recognition software. 」· Java 代码 · 共 96 行
JAVA
96 行
/** * Copyright 1998-2003 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and * redistribution of this file, and for a DISCLAIMER OF ALL * WARRANTIES. */package com.sun.speech.engine;import java.awt.BorderLayout;import java.awt.Point;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import javax.swing.BorderFactory;import javax.swing.JPanel;import javax.swing.JTextArea;import javax.swing.JScrollPane;import javax.swing.JButton;/** * Simple GUI for monitoring events of an <code>Engine</code>. Used * for debugging and testing purposes. */public class EngineEventPanel extends JPanel { /** * The area where engine events are posted. */ protected JTextArea textArea; /** * The scroll pane containing the <code>textArea</code>. * * @see #textArea */ protected JScrollPane scroller; /** * The button for clearing the <code>textArea</code>. * * @see #textArea */ protected JButton clearButton; /** * Class constructor. */ public EngineEventPanel() { setLayout(new BorderLayout()); setBorder(BorderFactory.createTitledBorder("Events:")); clearButton = new JButton("Clear"); clearButton.setMnemonic('C'); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { clearText(); } }); textArea = new JTextArea(); scroller = new JScrollPane(textArea); add(scroller,BorderLayout.CENTER); add(clearButton,BorderLayout.SOUTH); } /** * Clears the text in the text area. */ public void clearText() { textArea.setText(""); } /** * Sets the text in the text area. * * @param s the new text */ public void setText(String s) { textArea.setText(s); } /** * Appends text to the text area and scrolls the text area so the * new text is visible. * * @param s the text to append */ public void addText(String s) { textArea.append(s); Point pt = new Point(0, textArea.getHeight() - 1); scroller.getViewport().setViewPosition(pt); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?