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

📄 preferencesdialog.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.prefs;

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

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

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

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

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

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

  private JComboBox cboLooks;

  public PreferencesDialog ()
  {
    final UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels();
    cboLooks = new JComboBox();
    for (int i = 0; i < lafs.length; i++)
    {
      cboLooks.addItem(lafs[i].getName());
    }

    cboLooks.setSelectedItem(UIManager.getLookAndFeel().getName());

    final JPanel pnlLooks = new JPanel(new BorderLayout());
    pnlLooks.add(cboLooks, BorderLayout.CENTER);
    pnlLooks.setBorder(new TitledBorder(new EtchedBorder(), "Look and Feel"));

    final JPanel pnlBtn = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    pnlBtn.add(new ActionButton(new ConfirmAction()));
    pnlBtn.add(new ActionButton(new CancelAction()));

    this.getContentPane().setLayout(new BorderLayout());
    this.getContentPane().add(pnlLooks, BorderLayout.NORTH);
    this.getContentPane().add(pnlBtn, BorderLayout.SOUTH);
    this.setModal(true);
    this.setTitle("Preferences");
    this.setSize(250, 115);
    this.setResizable(false);
  }

  private void handleConfirmDialog ()
  {
    try
    {
      // UIManager.setLookAndFeel(lafs[cboLooks.getSelectedIndex()].getClassName());
      // JFreeReportDesigner.updateComponentTreeUI();

      // playing around with the look and feel should be left to a real
      // UI manager component.  And even then it is unsafe!

      // as this is no core functionality I removed it for now.
      setVisible(false);
    }
    catch (Exception e)
    {
      Log.debug(e.toString());
    }
  }

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

⌨️ 快捷键说明

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