/* * Created on February 8, 2007 * * Copyright (c) 2007 Jens Gulden * * http://www.frinika.com * * This file is part of Frinika. * * Frinika 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 2 of the License, or * (at your option) any later version. * Frinika 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 Frinika; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package com.frinika.sequencer.gui.menu.midi; import javax.swing.JPanel; /** * GUI-component for setting options of a MidiTransposeAction. * * (Created with NetBeans 5.5 gui-editor, see corresponding .form file.) * * @see MidiTransposeAction * @author Jens Gulden */ class MidiTransposeActionEditor extends JPanel { private MidiTransposeAction action; /** Creates new form MidiTransposeActionEditor */ public MidiTransposeActionEditor(MidiTransposeAction action) { this.action = action; initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jLabel1 = new javax.swing.JLabel(); octaveSpinner = new javax.swing.JSpinner(); jLabel2 = new javax.swing.JLabel(); notesSpinner = new javax.swing.JSpinner(); setLayout(new java.awt.GridBagLayout()); jLabel1.setText("Octaves"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0); add(jLabel1, gridBagConstraints); octaveSpinner.setModel(new javax.swing.SpinnerNumberModel(action.transpose / 12, -12, 12, 1)); octaveSpinner.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { octaveSpinnerStateChanged(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 0); add(octaveSpinner, gridBagConstraints); jLabel2.setText("Notes"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; add(jLabel2, gridBagConstraints); notesSpinner.setModel(new javax.swing.SpinnerNumberModel(action.transpose % 12, -12 * 8, 12 * 8, 1)); notesSpinner.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { notesSpinnerStateChanged(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); add(notesSpinner, gridBagConstraints); }// </editor-fold>//GEN-END:initComponents private void octaveSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_octaveSpinnerStateChanged updateAction(); }//GEN-LAST:event_octaveSpinnerStateChanged private void notesSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_notesSpinnerStateChanged updateAction(); }//GEN-LAST:event_notesSpinnerStateChanged private void updateAction() { int octave = (Integer)octaveSpinner.getValue(); int note = (Integer)notesSpinner.getValue(); action.transpose = octave * 12 + note; } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JSpinner notesSpinner; private javax.swing.JSpinner octaveSpinner; // End of variables declaration//GEN-END:variables }