Package jpianotrain.gui.action

Source Code of jpianotrain.gui.action.CircleOfFifthsAction

/* License see bottom */
package jpianotrain.gui.action;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;

import javax.swing.JDialog;

import jpianotrain.ApplicationContext;
import jpianotrain.gui.CircleOfFifths;
import jpianotrain.util.ResourceFactory;
import static jpianotrain.util.ResourceKeys.*;

/**
* Displays the circle of fifths in a
* separte (non modal) dialog.
*
* @since 0
* @author Alexander Methke
*/
public class CircleOfFifthsAction extends AbstractAction {
  public CircleOfFifthsAction() {
    super(ACTION_CIRCLE_OF_FIFTHS_NAME);
  }

  /**
   * Possibly creates the dialog and displays
   * it.
   */
  public void actionPerformed(ActionEvent e) {
    if (dlg==null) {
      dlg=new JDialog(ApplicationContext.getInstance().getDefaultDialogOwner(),
        ResourceFactory.getString(ACTION_CIRCLE_OF_FIFTHS_NAME),
        false);
      dlg.setLayout(new BorderLayout());
      dlg.add(new CircleOfFifths(), BorderLayout.CENTER);
      dlg.pack();
      Dimension d=dlg.getSize();
      d.setSize(new Dimension(d.width, d.height+200));
    }

    if (dlg.isVisible()) {
      dlg.toFront();
    } else {
      dlg.setVisible(true);
    }
  }

  private JDialog dlg;
}
/*
    Copyright (C) 2008  Alexander Methke

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program (gplv3.txt).
*/
TOP

Related Classes of jpianotrain.gui.action.CircleOfFifthsAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.