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

📄 finddialog.java

📁 报表设计软件,很好的
💻 JAVA
字号:
/**
 * ========================================================================================
 * JFreeReport Designer : a graphical designer for JFreeReport - a free Java report library
 * ========================================================================================
 *
 * Project Info:  http://www.jfree.org/jfreereport/index.html
 * Project Lead:  Thomas Morgner (taquera@sherito.org);
 *
 * (C) Copyright 2003, by Heiko Evermann (heiko@evermann.de) and Contributors.
 *
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation;
 * either version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with this
 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 */

package org.jfree.designer.text;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

import org.jfree.report.modules.gui.base.components.ActionButton;

public final class FindDialog
        extends JDialog
{
  private final class CloseAction
          extends AbstractAction
  {
    /**
     * Defines an <code>Action</code> object with a default description string and default
     * icon.
     */
    public CloseAction ()
    {
      putValue(Action.NAME, "Close");
    }

    /**
     * Invoked when an action occurs.
     */
    public final void actionPerformed (final ActionEvent e)
    {
      performFindCanceled();
    }
  }

  private final class FindAction
          extends AbstractAction
  {
    /**
     * Defines an <code>Action</code> object with a default description string and default
     * icon.
     */
    public FindAction ()
    {
      putValue(Action.NAME, "Find");
    }

    /**
     * Invoked when an action occurs.
     */
    public final void actionPerformed (final ActionEvent e)
    {
      performFindOK();
    }
  }

  private JTextField txtFind;
  private boolean approved;
  private FindHandler findHandler;
  private int index;

  public FindDialog (final FindHandler hander)
  {
    this.txtFind = new JTextField();
    this.findHandler = hander;
    this.index = 0;

    final JPanel pnlFind = new JPanel(new BorderLayout());
    pnlFind.add(txtFind, BorderLayout.CENTER);
    pnlFind.setBorder(new TitledBorder(new EtchedBorder(), "Text to Find"));

    final JPanel pnlButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    pnlButtons.add(new ActionButton(new FindAction()));
    pnlButtons.add(new ActionButton(new CloseAction()));

    this.getContentPane().setLayout(new BorderLayout());
    this.getContentPane().add(pnlFind, BorderLayout.NORTH);
    this.getContentPane().add(pnlButtons, BorderLayout.SOUTH);
    this.setModal(true);
    this.setTitle("Find Text");
    this.setSize(250, 115);
    this.setResizable(false);
  }

  private void performFindOK ()
  {
    if (findHandler.getTextSize() <= index)
    {
      return;
    }
    index = findHandler.findText(txtFind.getText(), index);
    if (index == -1)
    {
      approved = false;
      index = 0;
    }
  }

  private void performFindCanceled ()
  {
    setVisible(false);
  }

  public final boolean isApproved ()
  {
    return approved;
  }

  public final boolean showDialog ()
  {
    // just make sure we are modal
    setModal(true);
    setVisible(true);
    return isApproved();
  }
}

⌨️ 快捷键说明

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