Package jrackattack.gui

Source Code of jrackattack.gui.JRackAttackFrame$LookAndFeelAction

/* For License see bottom */
/*
* JRackAttackFrame.java
*
* Created on 29. Juni 2007, 19:33
*/

package jrackattack.gui;

import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.ResourceBundle;

import javax.swing.AbstractAction;
import javax.swing.ButtonGroup;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.WindowConstants;

import jonkoshare.util.VersionInformation;
import jrackattack.event.ColorSchemeListener;
import jrackattack.event.FXParameterEvent;
import jrackattack.event.FXParameterListener;
import jrackattack.event.GlobalParameterListener;
import jrackattack.event.PatternParameterEvent;
import jrackattack.event.PatternParameterListener;
import jrackattack.event.ProgramParameterEvent;
import jrackattack.event.ProgramParameterListener;
import jrackattack.event.SoundParameterEvent;
import jrackattack.event.SoundParameterListener;
import jrackattack.midi.FXParameter;
import jrackattack.midi.GlobalParameter;
import jrackattack.midi.ParameterChange;
import jrackattack.midi.PatternParameter;
import jrackattack.midi.ProgramParameter;
import jrackattack.midi.SoundParameter;
import jrackattack.util.UserConfiguration;

import org.apache.log4j.Logger;

/**
* Main Frame responsible to combine all the nice controls and offering some
* basic error handling functions.
*
* @version 0.7
* @author Alexander Methke
*/
@VersionInformation(//
lastChanged = "$LastChangedDate: 2009-07-25 04:59:33 -0500 (Sat, 25 Jul 2009) $", //
authors = { "Alexander Methke" }, //
revision = "$LastChangedRevision: 11 $", //
lastEditor = "$LastChangedBy: onkobu $", //
id = "$Id")
public class JRackAttackFrame extends JFrame implements WindowListener,
    ProgramBuffer, SoundBuffer, FXBuffer, ColorSchemeListener {
  private static final Logger log = Logger.getLogger(JRackAttackFrame.class);

  /** Creates new form JRackAttackFrame */
  public JRackAttackFrame() {
    super("JRackAttack - " + jrackattack.Constants.VERSION);
    for (int i = 0; i < 24; i++) {
      soundParameter[i] = new SoundParameter();
      soundParameter[i].setSoundNumber(i);
      patternParameter[i] = new PatternParameter();
      patternParameter[i].setSoundNumber(i);
    }
    for (int i = 0; i < 4; i++) {
      fxParameter[i] = new FXParameter();
      fxParameter[i].setFxNumber(i);
    }
    for (int i = 0; i < 50; i++) {
      programParameter[i] = new ProgramParameter();
      programParameter[i].setProgramNumber(i);
    }
    globalParameter = new GlobalParameter();
  }

  public static JRackAttackFrame getInstance() {
    if (instance == null) {
      instance = new JRackAttackFrame();
    }
    return instance;
  }

  public void handleError(String msgCode) {
    ResourceBundle bdl = ResourceBundle.getBundle("jrackattack.gui");
    JOptionPane.showMessageDialog(this, bdl.getString(msgCode), bdl
        .getString("title.error"), JOptionPane.ERROR_MESSAGE);

  }

  public void handleError(String msgCode, Object param) {
    ResourceBundle bdl = ResourceBundle.getBundle("jrackattack.gui");
    JOptionPane.showMessageDialog(this, MessageFormat.format(bdl
        .getString(msgCode), param), bdl.getString("title.error"),
        JOptionPane.ERROR_MESSAGE);
  }

  public void handleError(String msgCode, Object[] params) {
    ResourceBundle bdl = ResourceBundle.getBundle("jrackattack.gui");
    JOptionPane.showMessageDialog(this, MessageFormat.format(bdl
        .getString(msgCode), params), bdl.getString("title.error"),
        JOptionPane.ERROR_MESSAGE);
  }

  public void internalParamChange(SoundParameterEvent e) {
    soundParameter[e.getSoundNumber()].applyChange(e);
    fireParamChanged(e);
  }

  public void internalPatternChange(PatternParameterEvent e) {
    patternParameter[e.getPatternNumber()].applyChange(e);
    firePatternChanged(e);
  }

  public void internalFxChange(FXParameterEvent e) {
    fxParameter[e.getFxNumber()].applyChange(e);
    fireFxChanged(e);
  }

  public void internalProgramChange(ProgramParameterEvent e) {
    programParameter[e.getProgramNumber()].applyChange(e);
    fireProgramChanged(e);
  }

  public void setSoundParameter(SoundParameter param) {
    soundParameter[param.getSoundNumber()] = param;
    fireSoundParamChanged(param);
  }

  public void setFxParameter(FXParameter param) {
    fxParameter[param.getFxNumber()] = param;
    fireFxParameterChanged(param);
  }

  public void setGlobalParameter(GlobalParameter param) {
    globalParameter = param;
    fireGlobalParamChanged(param);
  }

  public void setPatternParameter(PatternParameter param) {
    patternParameter[param.getSoundNumber()] = param;
    firePatternChanged(param);
  }

  public void setPatternParameter(PatternParameter[] param) {
    patternParameter = param;
    for (PatternParameter pp : param) {
      firePatternChanged(pp);
    }
  }

  public void setProgramParameter(ProgramParameter param) {
    programParameter[param.getProgramNumber()] = param;
    fireProgramChanged(param);
  }

  public void setParameterChange(ParameterChange pc) {
    switch (pc.getType()) {
    case SND: {
      soundParameter[pc.getSoundNumber()].applyChange(pc);
      fireSoundParamChanged(pc);
    }
      break;
    case PRG: {
      programParameter[pc.getProgramNumber()].applyChange(pc);
      fireProgramParamChanged(pc);
    }
      break;
    case GLB: {
      globalParameter.applyChange(pc);
      fireGlobalParamChanged(pc);
    }
      break;
    case PAT: {
      patternParameter[pc.getPatternNumber()].applyChange(pc);
      firePatternParamChanged(pc);
    }
      break;
    case FX: {
      fxParameter[pc.getFxNumber()].applyChange(pc);
      fireFXParamChanged(pc);
    }
      break;
    }
  }

  public void setSoundParameter(SoundParameter[] params) {
    soundParameter = params;
    for (SoundParameter param : params) {
      fireSoundParamChanged(param);
    }
  }

  public void setFxParameter(FXParameter[] params) {
    for (FXParameter param : params) {
      fireFxParameterChanged(param);
    }
  }

  /**
   * 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 ">
  private void initComponents() {
    keyBoard = new jrackattack.gui.JKeyBoard();
    jTabbedPane1 = new JTabbedPane();
    introPanel = new jrackattack.gui.IntroPanel();
    globalPanel = new jrackattack.gui.GlobalPanel();
    programPanel = new jrackattack.gui.ProgramPanel();
    soundPanel = new jrackattack.gui.SoundPanel();
    volumePanel1 = new jrackattack.gui.VolumePanel();
    volumePanel2 = new jrackattack.gui.VolumePanel2();
    oscillatorPanel = new jrackattack.gui.OscillatorPanel();
    modEnvPanel = new jrackattack.gui.ModEnvPanel();
    fxPanel = new jrackattack.gui.FXPanel();
    ioPanel = new jrackattack.gui.IOPanel();
    menuBar = new JMenuBar();
    rackAttackMenu = new JMenu();
    loadSoundItem = new JMenuItem();
    saveSoundItem = new JMenuItem();
    exportSoundItem = new JMenuItem();
    importSoundItem = new JMenuItem();
    jSeparator1 = new JSeparator();
    loadFXItem = new JMenuItem();
    saveFXItem = new JMenuItem();
    exportFXItem = new JMenuItem();
    importFXItem = new JMenuItem();
    jSeparator2 = new JSeparator();
    loadProgramItem = new JMenuItem();
    saveProgramItem = new JMenuItem();
    exportProgramItem = new JMenuItem();
    importProgramItem = new JMenuItem();
    jSeparator3 = new JSeparator();
    loadPatternItem = new JMenuItem();
    savePatternItem = new JMenuItem();
    exportPatternItem = new JMenuItem();
    importPatternItem = new JMenuItem();
    jSeparator4 = new JSeparator();
    loadGlobalItem = new JMenuItem();
    saveGlobalItem = new JMenuItem();
    jSeparator5 = new JSeparator();
    exitItem = new JMenuItem();
    midiMenu = new JMenu();
    configureItem = new JMenuItem();
    jMenu1 = new JMenu();
    channelItem1 = new JRadioButtonMenuItem();
    channelItem2 = new JRadioButtonMenuItem();
    channelItem3 = new JRadioButtonMenuItem();
    channelItem4 = new JRadioButtonMenuItem();
    channelItem5 = new JRadioButtonMenuItem();
    channelItem6 = new JRadioButtonMenuItem();
    channelItem7 = new JRadioButtonMenuItem();
    channelItem8 = new JRadioButtonMenuItem();
    channelItem9 = new JRadioButtonMenuItem();
    channelItem10 = new JRadioButtonMenuItem();
    channelItem11 = new JRadioButtonMenuItem();
    channelItem12 = new JRadioButtonMenuItem();
    channelItem13 = new JRadioButtonMenuItem();
    channelItem14 = new JRadioButtonMenuItem();
    channelItem15 = new JRadioButtonMenuItem();
    channelItem16 = new JRadioButtonMenuItem();
    lookAndFeelMenu = new JMenu();
    colorItem = new JMenuItem();
    jSeparator6 = new JSeparator();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setMinimumSize(new java.awt.Dimension(800, 600));
    getContentPane().add(keyBoard, java.awt.BorderLayout.SOUTH);

    java.util.ResourceBundle bundle = java.util.ResourceBundle
        .getBundle("jrackattack/gui"); // NOI18N
    jTabbedPane1.addTab(bundle.getString("tab.intro"), introPanel); // NOI18N

    jTabbedPane1.addTab(bundle.getString("tab.global"), globalPanel); // NOI18N

    jTabbedPane1.addTab(bundle.getString("tab.program"), programPanel); // NOI18N

    jTabbedPane1.addTab(bundle.getString("tab.sound"), soundPanel); // NOI18N

    jTabbedPane1.addTab(bundle.getString("tab.volume"), volumePanel1); // NOI18N

    jTabbedPane1.addTab(bundle.getString("tab.volume2"), volumePanel2); // NOI18N

    jTabbedPane1
        .addTab(bundle.getString("tab.oscillator"), oscillatorPanel); // NOI18N

    jTabbedPane1.addTab(bundle.getString("tab.mod_env"), modEnvPanel); // NOI18N

    jTabbedPane1.addTab(bundle.getString("tab.fx"), fxPanel); // NOI18N

    jTabbedPane1.addTab(bundle.getString("tab.io"), ioPanel); // NOI18N

    getContentPane().add(jTabbedPane1, java.awt.BorderLayout.CENTER);

    rackAttackMenu.setText(bundle.getString("menu.rackattack")); // NOI18N
    loadSoundItem.setText(bundle.getString("item.load")); // NOI18N
    loadSoundItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        loadSoundItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(loadSoundItem);

    saveSoundItem.setText(bundle.getString("item.store")); // NOI18N
    saveSoundItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        saveSoundItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(saveSoundItem);

    exportSoundItem.setText(bundle.getString("item.export")); // NOI18N
    exportSoundItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        exportSoundItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(exportSoundItem);

    importSoundItem.setText(bundle.getString("item.import")); // NOI18N
    importSoundItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        importSoundItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(importSoundItem);

    rackAttackMenu.add(jSeparator1);

    loadFXItem.setText(bundle.getString("item.load_fx")); // NOI18N
    loadFXItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        loadFXItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(loadFXItem);

    saveFXItem.setText(bundle.getString("item.save_fx")); // NOI18N
    saveFXItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        saveFXItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(saveFXItem);

    exportFXItem.setText(bundle.getString("item.export_fx")); // NOI18N
    exportFXItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        exportFXItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(exportFXItem);

    importFXItem.setText(bundle.getString("item.import_fx")); // NOI18N
    importFXItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        importFXItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(importFXItem);

    rackAttackMenu.add(jSeparator2);

    loadProgramItem.setText(bundle.getString("item.load_program")); // NOI18N
    loadProgramItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        loadProgramItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(loadProgramItem);

    saveProgramItem.setText(bundle.getString("item.save_program")); // NOI18N
    saveProgramItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        saveProgramItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(saveProgramItem);

    exportProgramItem.setText(bundle.getString("item.export_program")); // NOI18N
    exportProgramItem
        .addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            exportProgramItemActionPerformed(evt);
          }
        });

    rackAttackMenu.add(exportProgramItem);

    importProgramItem.setText(bundle.getString("item.import_program")); // NOI18N
    importProgramItem
        .addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            importProgramItemActionPerformed(evt);
          }
        });

    rackAttackMenu.add(importProgramItem);

    rackAttackMenu.add(jSeparator3);

    loadPatternItem.setText(bundle
        .getString("JRackAttackFrame.loadPatternItem.text")); // NOI18N
    loadPatternItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        loadPatternItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(loadPatternItem);

    savePatternItem.setText(bundle
        .getString("JRackAttackFrame.savePatternItem.text")); // NOI18N
    savePatternItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        savePatternItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(savePatternItem);

    exportPatternItem.setText(bundle
        .getString("JRackAttackFrame.exportPatternItem.text")); // NOI18N
    exportPatternItem
        .addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            exportPatternItemActionPerformed(evt);
          }
        });

    rackAttackMenu.add(exportPatternItem);

    importPatternItem.setText(bundle
        .getString("JRackAttackFrame.importPatternItem.text")); // NOI18N
    importPatternItem
        .addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            importPatternItemActionPerformed(evt);
          }
        });

    rackAttackMenu.add(importPatternItem);

    rackAttackMenu.add(jSeparator4);

    loadGlobalItem.setText(bundle
        .getString("JRackAttackFrame.loadGlobalItem.text")); // NOI18N
    loadGlobalItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        loadGlobalItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(loadGlobalItem);

    saveGlobalItem.setText(bundle
        .getString("JRackAttackFrame.saveGlobalItem.text")); // NOI18N
    saveGlobalItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        saveGlobalItemActionPerformed(evt);
      }
    });

    rackAttackMenu.add(saveGlobalItem);

    rackAttackMenu.add(jSeparator5);

    exitItem.setText(bundle.getString("menu.exit")); // NOI18N
    exitItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        ExitHandler(evt);
      }
    });

    rackAttackMenu.add(exitItem);

    menuBar.add(rackAttackMenu);

    midiMenu.setText(bundle.getString("midiMenu.text")); // NOI18N
    configureItem.setText(bundle.getString("configureItem.text")); // NOI18N
    configureItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        configureItemActionPerformed(evt);
      }
    });

    midiMenu.add(configureItem);

    jMenu1.setText(bundle.getString("menu.keyboard_channel")); // NOI18N
    channelItem1.setText(bundle.getString("item.channel1")); // NOI18N
    channelItem1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem1ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem1);

    channelItem2.setText(bundle
        .getString("JRackAttackFrame.channelItem2.text")); // NOI18N
    channelItem2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem2ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem2);

    channelItem3.setText(bundle
        .getString("JRackAttackFrame.channelItem3.text")); // NOI18N
    channelItem3.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem3ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem3);

    channelItem4.setText(bundle
        .getString("JRackAttackFrame.channelItem4.text")); // NOI18N
    channelItem4.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem4ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem4);

    channelItem5.setText(bundle
        .getString("JRackAttackFrame.channelItem5.text")); // NOI18N
    channelItem5.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem5ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem5);

    channelItem6.setText(bundle
        .getString("JRackAttackFrame.channelItem6.text")); // NOI18N
    channelItem6.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem6ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem6);

    channelItem7.setText(bundle
        .getString("JRackAttackFrame.channelItem7.text")); // NOI18N
    channelItem7.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem7ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem7);

    channelItem8.setText(bundle
        .getString("JRackAttackFrame.channelItem8.text")); // NOI18N
    channelItem8.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem8ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem8);

    channelItem9.setText(bundle
        .getString("JRackAttackFrame.channelItem9.text")); // NOI18N
    channelItem9.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem9ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem9);

    channelItem10.setText(bundle
        .getString("JRackAttackFrame.channelItem10.text")); // NOI18N
    channelItem10.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem10ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem10);

    channelItem11.setText(bundle
        .getString("JRackAttackFrame.channelItem11.text")); // NOI18N
    channelItem11.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem11ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem11);

    channelItem12.setText(bundle
        .getString("JRackAttackFrame.channelItem12.text")); // NOI18N
    channelItem12.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem12ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem12);

    channelItem13.setText(bundle
        .getString("JRackAttackFrame.channelItem13.text")); // NOI18N
    channelItem13.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem13ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem13);

    channelItem14.setText(bundle
        .getString("JRackAttackFrame.channelItem14.text")); // NOI18N
    channelItem14.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem14ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem14);

    channelItem15.setText(bundle
        .getString("JRackAttackFrame.channelItem15.text")); // NOI18N
    channelItem15.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem15ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem15);

    channelItem16.setText(bundle
        .getString("JRackAttackFrame.channelItem16.text")); // NOI18N
    channelItem16.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        channelItem16ActionPerformed(evt);
      }
    });

    jMenu1.add(channelItem16);

    midiMenu.add(jMenu1);

    menuBar.add(midiMenu);

    lookAndFeelMenu.setText(bundle.getString("menu.look_and_feel")); // NOI18N
    colorItem.setText(bundle.getString("item.color")); // NOI18N
    colorItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorItemActionPerformed(evt);
      }
    });

    lookAndFeelMenu.add(colorItem);

    lookAndFeelMenu.add(jSeparator6);

    menuBar.add(lookAndFeelMenu);

    setJMenuBar(menuBar);

    pack();
  }// </editor-fold>

  private void colorItemActionPerformed(java.awt.event.ActionEvent evt) {

    ColorDialog csd = new ColorDialog();
    csd.setVisible(true);
  }

  private void saveGlobalItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      try {
        File f = fileChooser.getSelectedFile();
        XMLEncoder e = new XMLEncoder(new BufferedOutputStream(
            new FileOutputStream(f)));
        e.writeObject(globalParameter);
        e.close();
      } catch (Exception ex) {
        handleError("error.file.save", ex.getMessage());
      }
    }
  }

  private void loadGlobalItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      GlobalParameter pr = null;
      try {
        File f = fileChooser.getSelectedFile();
        XMLDecoder e = new XMLDecoder(new BufferedInputStream(
            new FileInputStream(f)));
        Object o = e.readObject();
        if (!(o instanceof GlobalParameter)) {
          throw new Exception("not a global parameter file");
        }
        pr = (GlobalParameter) o;
        e.close();
      } catch (Exception ex) {
        handleError("error.file.load", ex.getMessage());
      }
      if (pr != null) {
        setGlobalParameter(pr);
      }
    }
  }

  private void importPatternItemActionPerformed(java.awt.event.ActionEvent evt) {

  }

  private void exportPatternItemActionPerformed(java.awt.event.ActionEvent evt) {

  }

  private void savePatternItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      try {
        File f = fileChooser.getSelectedFile();
        XMLEncoder e = new XMLEncoder(new BufferedOutputStream(
            new FileOutputStream(f)));
        e.writeObject(patternParameter);
        e.close();
      } catch (Exception ex) {
        handleError("error.file.save", ex.getMessage());
      }
    }
  }

  private void loadPatternItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      PatternParameter[] pr = null;
      try {
        File f = fileChooser.getSelectedFile();
        XMLDecoder e = new XMLDecoder(new BufferedInputStream(
            new FileInputStream(f)));
        Object o = e.readObject();
        if (!(o instanceof PatternParameter[])) {
          throw new Exception("not a pattern parameter file");
        }
        pr = (PatternParameter[]) o;
        e.close();
      } catch (Exception ex) {
        handleError("error.file.load", ex.getMessage());
      }
      if (pr != null) {
        setPatternParameter(pr);
      }
    }
  }

  private void importProgramItemActionPerformed(java.awt.event.ActionEvent evt) {

  }

  private void exportProgramItemActionPerformed(java.awt.event.ActionEvent evt) {

  }

  private void saveProgramItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      try {
        File f = fileChooser.getSelectedFile();
        XMLEncoder e = new XMLEncoder(new BufferedOutputStream(
            new FileOutputStream(f)));
        e.writeObject(soundParameter);
        e.writeObject(patternParameter);
        e.writeObject(fxParameter);
        e.writeObject(programParameter);
        e.close();
      } catch (Exception ex) {
        handleError("error.file.save", ex.getMessage());
      }
    }
  }

  private void loadProgramItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      PatternParameter[] ppr = null;
      SoundParameter[] spr = null;
      FXParameter[] fpr = null;
      ProgramParameter prgPar = null;
      try {
        File f = fileChooser.getSelectedFile();
        XMLDecoder e = new XMLDecoder(new BufferedInputStream(
            new FileInputStream(f)));
        Object o = e.readObject();
        if (!(o instanceof SoundParameter[])) {
          throw new Exception("not a program parameter file");
        }
        spr = (SoundParameter[]) o;
        if (!(o instanceof PatternParameter[])) {
          throw new Exception("not a program parameter file");
        }
        ppr = (PatternParameter[]) o;
        if (!(o instanceof FXParameter[])) {
          throw new Exception("not a program parameter file");
        }
        fpr = (FXParameter[]) o;
        if (!(o instanceof ProgramParameter)) {
          throw new Exception("not a program parameter file");
        }
        prgPar = (ProgramParameter) o;
        e.close();
      } catch (Exception ex) {
        handleError("error.file.load", ex.getMessage());
      }
      if (spr != null && ppr != null && fpr != null && prgPar != null) {
        setSoundParameter(spr);
        setPatternParameter(ppr);
        setFxParameter(fpr);
        setProgramParameter(prgPar);
      }
    }
  }

  private void channelItem16ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 16;
  }

  private void channelItem15ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 15;
  }

  private void channelItem14ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 14;
  }

  private void channelItem13ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 13;
  }

  private void channelItem12ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 12;
  }

  private void channelItem11ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 11;
  }

  private void channelItem10ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 10;
  }

  private void channelItem9ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 9;
  }

  private void channelItem8ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 8;
  }

  private void channelItem7ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 7;
  }

  private void channelItem6ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 6;
  }

  private void channelItem5ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 5;
  }

  private void channelItem4ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 4;
  }

  private void channelItem3ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 3;
  }

  private void channelItem2ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 2;
  }

  private void channelItem1ActionPerformed(java.awt.event.ActionEvent evt) {

    activeChannel = 1;
  }

  private void importFXItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      FXParameter[] pr = null;
      try {
        File f = fileChooser.getSelectedFile();
        XMLDecoder e = new XMLDecoder(new BufferedInputStream(
            new FileInputStream(f)));
        Object o = e.readObject();
        if (o instanceof FXParameter) {
          setFxParameter((FXParameter) o);
        } else if (o instanceof FXParameter[]) {
          FXParameter[] sp = (FXParameter[]) o;
          boolean[] bArr = new ImportFxDialog(this)
              .getParameterList();
          for (int i = 0; i < 4; i++) {
            if (bArr[i]) {
              setFxParameter(sp[i]);
            }
          }
        } else {
          throw new Exception("not a sound parameter file");
        }
        e.close();
      } catch (Exception ex) {
        handleError("error.file.import", ex.getMessage());
      }
      if (pr != null) {
        setFxParameter(pr);
      }
    }
  }

  private void exportFXItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    int idx = new ImportFxDialog(this).getFxIndex();
    if (idx > -1
        && fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      try {
        File f = fileChooser.getSelectedFile();
        XMLEncoder e = new XMLEncoder(new BufferedOutputStream(
            new FileOutputStream(f)));
        e.writeObject(fxParameter[idx]);
        e.close();
      } catch (Exception ex) {
        handleError("error.file.import", ex.getMessage());
      }
    }
  }

  private void saveFXItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      try {
        File f = fileChooser.getSelectedFile();
        XMLEncoder e = new XMLEncoder(new BufferedOutputStream(
            new FileOutputStream(f)));
        e.writeObject(fxParameter);
        e.close();
      } catch (Exception ex) {
        handleError("error.file.save", ex.getMessage());
      }
    }
  }

  private void loadFXItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      FXParameter[] pr = null;
      try {
        File f = fileChooser.getSelectedFile();
        XMLDecoder e = new XMLDecoder(new BufferedInputStream(
            new FileInputStream(f)));
        Object o = e.readObject();
        if (!(o instanceof FXParameter[])) {
          throw new Exception("not a fx parameter file");
        }
        pr = (FXParameter[]) o;
        e.close();
      } catch (Exception ex) {
        handleError("error.file.load", ex.getMessage());
      }
      if (pr != null) {
        setFxParameter(pr);
      }
    }
  }

  private void importSoundItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      SoundParameter[] pr = null;
      try {
        File f = fileChooser.getSelectedFile();
        XMLDecoder e = new XMLDecoder(new BufferedInputStream(
            new FileInputStream(f)));
        Object o = e.readObject();
        if (o instanceof SoundParameter) {
          setSoundParameter((SoundParameter) o);
        } else if (o instanceof SoundParameter[]) {
          SoundParameter[] sp = (SoundParameter[]) o;
          boolean[] bArr = new ImportSoundDialog(this)
              .getParameterList();
          for (int i = 0; i < 24; i++) {
            if (bArr[i]) {
              setSoundParameter(sp[i]);
            }
          }
        } else {
          throw new Exception("not a sound parameter file");
        }
        e.close();
      } catch (Exception ex) {
        handleError("error.file.import", ex.getMessage());
      }
      if (pr != null) {
        setSoundParameter(pr);
      }
    }
  }

  private void exportSoundItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      try {
        File f = fileChooser.getSelectedFile();
        XMLEncoder e = new XMLEncoder(new BufferedOutputStream(
            new FileOutputStream(f)));
        e.writeObject(getActiveSoundParameter());
        e.close();
      } catch (Exception ex) {
        handleError("error.file.export", ex.getMessage());
      }
    }
  }

  private void loadSoundItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      SoundParameter[] pr = null;
      try {
        File f = fileChooser.getSelectedFile();
        XMLDecoder e = new XMLDecoder(new BufferedInputStream(
            new FileInputStream(f)));
        Object o = e.readObject();
        if (!(o instanceof SoundParameter[])) {
          throw new Exception("not a sound parameter file");
        }
        e.close();
      } catch (Exception ex) {
        handleError("error.file.load", ex.getMessage());
      }
      if (pr != null) {
        setSoundParameter(pr);
      }
    }
  }

  private void saveSoundItemActionPerformed(java.awt.event.ActionEvent evt) {

    initFileChooser();
    if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
      oldDir = fileChooser.getCurrentDirectory().getAbsolutePath();
      try {
        File f = fileChooser.getSelectedFile();
        XMLEncoder e = new XMLEncoder(new BufferedOutputStream(
            new FileOutputStream(f)));
        e.writeObject(soundParameter);
        e.close();
      } catch (Exception ex) {
        handleError("error.file.save", ex.getMessage());
      }
    }
  }

  protected void initFileChooser() {
    if (fileChooser == null) {
      fileChooser = new JFileChooser();
    }
    if (oldDir == null) {
      fileChooser.setCurrentDirectory(new File(System.getProperties()
          .getProperty("user.home", "./")));
    } else {
      fileChooser.setCurrentDirectory(new File(oldDir));
    }
  }

  protected void initListener() {
    addWindowListener(this);
    oscillatorPanel.setSoundBuffer(this);
    addSoundParameterListener(oscillatorPanel);
    volumePanel1.setSoundBuffer(this);
    addSoundParameterListener(volumePanel1);
    volumePanel2.setSoundBuffer(this);
    addSoundParameterListener(volumePanel2);
    fxPanel.setSoundBuffer(this);
    addSoundParameterListener(fxPanel);
    modEnvPanel.setSoundBuffer(this);
    addSoundParameterListener(modEnvPanel);
    soundPanel.setSoundBuffer(this);
    addSoundParameterListener(soundPanel);
    addGlobalParameterListener(globalPanel);
    addProgramParameterListener(programPanel);
    programPanel.setProgramBuffer(this);
    addColorSchemeListener(this);
  }

  private void configureItemActionPerformed(java.awt.event.ActionEvent evt) {

    MidiSettingsDialog msd = new MidiSettingsDialog(this, true);
    msd.setVisible(true);
  }

  private void ExitHandler(java.awt.event.ActionEvent evt) {

    setVisible(false);
    storeConfiguration();
    dispose();
  }

  /**
   * @param args
   *            the command line arguments
   */
  public void initGUI() {
    initComponents();
    for (UIManager.LookAndFeelInfo info : UIManager
        .getInstalledLookAndFeels()) {
      lookAndFeelMenu.add(new LookAndFeelAction(info));
    }
    String lf = UserConfiguration.getInstance().getProperty(
        UserConfiguration.LOOK_AND_FEEL, null);
    if (lf != null) {
      try {
        UIManager.setLookAndFeel(lf);
        SwingUtilities.updateComponentTreeUI(JRackAttackFrame
            .getInstance());
      } catch (Exception ex) {
        handleError("error.lookandfeel", lf);
      }
    }
    ButtonGroup bg = new ButtonGroup();
    bg.add(channelItem1);
    bg.add(channelItem2);
    bg.add(channelItem3);
    bg.add(channelItem4);
    bg.add(channelItem5);
    bg.add(channelItem6);
    bg.add(channelItem7);
    bg.add(channelItem8);
    bg.add(channelItem9);
    bg.add(channelItem10);
    bg.add(channelItem11);
    bg.add(channelItem12);
    bg.add(channelItem13);
    bg.add(channelItem14);
    bg.add(channelItem15);
    bg.add(channelItem16);
    channelItem1.setSelected(true);
    initListener();
    colorSchemeChanged(colorScheme);
  }

  // ColorSchemeListener
  public void addColorSchemeListener(ColorSchemeListener spl) {
    colorSchemeListener.add(spl);
  }

  public void removeColorSchemeListener(ColorSchemeListener spl) {
    colorSchemeListener.remove(spl);
  }

  public void removeAllColorSchemeListener() {
    colorSchemeListener.clear();
  }

  public boolean isColorSchemeListener(ColorSchemeListener spl) {
    return colorSchemeListener.contains(spl);
  }

  public void colorSchemeChanged(ColorScheme cs) {
    GUIUtilities.traverseComponents(this, BackgroundColorHandler.HANDLER);
    GUIUtilities.traverseComponents(this, ForegroundColorHandler.HANDLER);
    GUIUtilities.traverseComponents(this, BorderHandler.HANDLER);
    GUIUtilities.traverseComponents(this, FontHandler.HANDLER);
    GUIUtilities.traverseComponents(getJMenuBar(),
        BackgroundColorHandler.HANDLER);
    GUIUtilities.traverseComponents(getJMenuBar(),
        ForegroundColorHandler.HANDLER);
    GUIUtilities.traverseComponents(getJMenuBar(), FontHandler.HANDLER);
  }

  // SoundParameter-Listener
  public void addSoundParameterListener(SoundParameterListener spl) {
    soundParameterListener.add(spl);
  }

  public void removeSoundParameterListener(SoundParameterListener spl) {
    soundParameterListener.remove(spl);
  }

  public void removeAllSoundParameterListener() {
    soundParameterListener.clear();
  }

  public boolean isSoundParameterListener(SoundParameterListener spl) {
    return soundParameterListener.contains(spl);
  }

  // ProgramParameterListener
  public void addProgramParameterListener(ProgramParameterListener spl) {
    programParameterListener.add(spl);
  }

  public void removeProgramParameterListener(ProgramParameterListener spl) {
    programParameterListener.remove(spl);
  }

  public void removeAllProgramParameterListener() {
    programParameterListener.clear();
  }

  public boolean isProgramParameterListener(ProgramParameterListener spl) {
    return programParameterListener.contains(spl);
  }

  // PatternParameterListener
  public void addPatternParameterListener(PatternParameterListener spl) {
    patternParameterListener.add(spl);
  }

  public void removePatternParameterListener(PatternParameterListener spl) {
    patternParameterListener.remove(spl);
  }

  public void removeAllPatternParameterListener() {
    patternParameterListener.clear();
  }

  public boolean isPatternParameterListener(PatternParameterListener spl) {
    return patternParameterListener.contains(spl);
  }

  // FXParameterListener
  public void addFXParameterListener(FXParameterListener spl) {
    fxParameterListener.add(spl);
  }

  public void removeFXParameterListener(FXParameterListener spl) {
    fxParameterListener.remove(spl);
  }

  public void removeAllFXParameterListener() {
    fxParameterListener.clear();
  }

  public boolean isFXParameterListener(FXParameterListener spl) {
    return fxParameterListener.contains(spl);
  }

  // GlobalParameterListener
  public void addGlobalParameterListener(GlobalParameterListener spl) {
    globalParameterListener.add(spl);
  }

  public void removeGlobalParameterListener(GlobalParameterListener spl) {
    globalParameterListener.remove(spl);
  }

  public void removeAllGlobalParameterListener() {
    globalParameterListener.clear();
  }

  public boolean isGlobalParameterListener(GlobalParameterListener spl) {
    return globalParameterListener.contains(spl);
  }

  // ListenerControlMethods
  protected void fireSoundParamChanged(SoundParameter sp) {
    for (SoundParameterListener spl : soundParameterListener) {
      spl.soundParameterChanged(sp);
    }
  }

  protected void fireGlobalParamChanged(GlobalParameter gp) {
    for (GlobalParameterListener gpl : globalParameterListener) {
      gpl.globalParameterChanged(gp);
    }
  }

  protected void firePatternChanged(PatternParameter pp) {
    for (PatternParameterListener ppl : patternParameterListener) {
      ppl.patternParameterChanged(pp);
    }
  }

  protected void fireProgramChanged(ProgramParameter pp) {
    for (ProgramParameterListener ppl : programParameterListener) {
      ppl.programParameterChanged(pp);
    }
  }

  protected void fireSoundParamChanged(ParameterChange pc) {
    for (SoundParameterListener spl : soundParameterListener) {
      spl.parameterChanged(pc);
    }
  }

  protected void fireColorSchemeChanged() {
    for (ColorSchemeListener ccl : colorSchemeListener) {
      ccl.colorSchemeChanged(colorScheme);
    }
  }

  protected void fireFXParamChanged(ParameterChange pc) {
    for (FXParameterListener fpl : fxParameterListener) {
      fpl.parameterChanged(pc);
    }
  }

  protected void fireProgramParamChanged(ParameterChange pc) {
    for (ProgramParameterListener ppl : programParameterListener) {
      ppl.parameterChanged(pc);
    }
  }

  protected void firePatternParamChanged(ParameterChange pc) {
    for (SoundParameterListener spl : soundParameterListener) {
      spl.parameterChanged(pc);
    }
  }

  protected void fireGlobalParamChanged(ParameterChange pc) {
    for (GlobalParameterListener gpl : globalParameterListener) {
      gpl.parameterChanged(pc);
    }
  }

  protected void firePatternChanged(PatternParameterEvent ppe) {
    for (PatternParameterListener ppl : patternParameterListener) {
      ppl.patternChanged(ppe);
    }
  }

  protected void fireParamChanged(SoundParameterEvent spe) {
    for (SoundParameterListener spl : soundParameterListener) {
      spl.parameterChanged(spe);
    }
  }

  protected void fireProgramNumberChanged(ProgramParameterEvent spe) {
    for (ProgramParameterListener spl : programParameterListener) {
      spl.programNumberChanged(spe);
    }
  }

  protected void fireSoundNumberChanged(SoundParameterEvent spe) {
    for (SoundParameterListener spl : soundParameterListener) {
      spl.soundNumberChanged(spe);
    }
    for (PatternParameterListener ppl : patternParameterListener) {
      ppl.soundNumberChanged(getActiveSoundNumber());
    }
  }

  protected void fireFxChanged(FXParameterEvent fpe) {
    for (FXParameterListener fpl : fxParameterListener) {
      fpl.parameterChanged(fpe);
    }
  }

  protected void fireProgramChanged(ProgramParameterEvent ppe) {
    for (ProgramParameterListener ppl : programParameterListener) {
      ppl.parameterChanged(ppe);
    }
  }

  protected void fireFxParameterChanged(FXParameter fp) {
    fxParameter[fp.getFxNumber()] = fp;
    for (FXParameterListener fpl : fxParameterListener) {
      fpl.parameterChanged(fp);
    }
  }

  // MidiChannel methods
  public int getActiveMidiChannel() {
    return activeChannel;
  }

  // ProgramBuffer methods
  public int getActiveProgramNumber() {
    return programNumber;
  }

  public void setActiveProgramNumber(Object src, int num) {
    fireProgramNumberChanged(new ProgramParameterEvent(this, num));
    programNumber = num;
  }

  public ProgramParameter getActiveProgramParameter() {
    return programParameter[getActiveProgramNumber()];
  }

  public PatternParameter getActivePatternParameter() {
    return patternParameter[getActiveSoundNumber()];
  }

  public ProgramParameter[] getAllProgramParameter() {
    return programParameter;
  }

  // SoundBuffer methods
  /**
   * Returns the active sound's number.
   */
  public int getActiveSoundNumber() {
    return activeSoundNumber;
  }

  /**
   * Focuses the given sound for all displaying components.
   */
  public void setActiveSoundNumber(Object src, int num) {
    log(" component " + src.getClass().getName()
        + " forced sound number update to " + num);
    activeSoundNumber = num;
    fireSoundNumberChanged(new SoundParameterEvent(src, num));
  }

  /**
   * Returns the currently active parameter references.
   *
   * @return A valid reference, never <code>null</code>
   */
  public SoundParameter getActiveSoundParameter() {
    return soundParameter[getActiveSoundNumber()];
  }

  /**
   * Returns an array of all editable sounds.
   */
  public SoundParameter[] getAllSoundParameter() {
    return soundParameter;
  }

  /**
   * Returns an array of all editable sounds.
   */
  public FXParameter[] getAllFXParameter() {
    return fxParameter;
  }

  // Message methods
  public void setMessage(String msg) {
    ioPanel.setMessage(msg);
  }

  public void appendMessage(String msg) {
    ioPanel.appendMessage(msg);
  }

  // WindowListener
  public void windowOpened(WindowEvent e) {

  }

  public void windowIconified(WindowEvent e) {

  }

  public void windowDeiconified(WindowEvent e) {

  }

  public void windowActivated(WindowEvent e) {

  }

  public void windowDeactivated(WindowEvent e) {

  }

  public void windowClosing(WindowEvent e) {
    storeConfiguration();
  }

  public void windowClosed(WindowEvent e) {

  }

  public void log(String msg) {
    log.debug(msg);
  }

  protected void storeConfiguration() {
    Rectangle r = getBounds();
    // enlightenment window manager on Linux/Unix
    // causes confusion and adds extra space for
    // window decoration...
    // Insets i=getInsets();
    // r.x-=i.left;
    // r.y-=i.top;
    // r.width+=i.right;
    // r.height+=i.bottom;

    UserConfiguration.getInstance().putProperty(
        UserConfiguration.WINDOW_BOUNDS, r);
    UserConfiguration.getInstance().putProperty(
        UserConfiguration.LOOK_AND_FEEL,
        UIManager.getLookAndFeel().getClass().getName());
    colorScheme.storeTo(UserConfiguration.getInstance());
    UserConfiguration.getInstance().done();
  }

  public class LookAndFeelAction extends AbstractAction {
    public LookAndFeelAction(UIManager.LookAndFeelInfo info) {
      super(info.getName());
      lookAndFeelInfo = info;
    }

    public void actionPerformed(ActionEvent e) {
      try {
        UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
        SwingUtilities.updateComponentTreeUI(JRackAttackFrame
            .getInstance());
      } catch (Exception ex) {
        handleError("error.lookandfeel", lookAndFeelInfo.getName());
      }
    }

    private UIManager.LookAndFeelInfo lookAndFeelInfo;
  }

  // Variables declaration - do not modify
  private JRadioButtonMenuItem channelItem1;
  private JRadioButtonMenuItem channelItem10;
  private JRadioButtonMenuItem channelItem11;
  private JRadioButtonMenuItem channelItem12;
  private JRadioButtonMenuItem channelItem13;
  private JRadioButtonMenuItem channelItem14;
  private JRadioButtonMenuItem channelItem15;
  private JRadioButtonMenuItem channelItem16;
  private JRadioButtonMenuItem channelItem2;
  private JRadioButtonMenuItem channelItem3;
  private JRadioButtonMenuItem channelItem4;
  private JRadioButtonMenuItem channelItem5;
  private JRadioButtonMenuItem channelItem6;
  private JRadioButtonMenuItem channelItem7;
  private JRadioButtonMenuItem channelItem8;
  private JRadioButtonMenuItem channelItem9;
  private JMenuItem colorItem;
  private JMenuItem configureItem;
  private JMenuItem exitItem;
  private JMenuItem exportFXItem;
  private JMenuItem exportPatternItem;
  private JMenuItem exportProgramItem;
  private JMenuItem exportSoundItem;
  private jrackattack.gui.FXPanel fxPanel;
  private jrackattack.gui.GlobalPanel globalPanel;
  private JMenuItem importFXItem;
  private JMenuItem importPatternItem;
  private JMenuItem importProgramItem;
  private JMenuItem importSoundItem;
  private jrackattack.gui.IntroPanel introPanel;
  private jrackattack.gui.IOPanel ioPanel;
  private JMenu jMenu1;
  private JSeparator jSeparator1;
  private JSeparator jSeparator2;
  private JSeparator jSeparator3;
  private JSeparator jSeparator4;
  private JSeparator jSeparator5;
  private JSeparator jSeparator6;
  private JTabbedPane jTabbedPane1;
  private jrackattack.gui.JKeyBoard keyBoard;
  private JMenuItem loadFXItem;
  private JMenuItem loadGlobalItem;
  private JMenuItem loadPatternItem;
  private JMenuItem loadProgramItem;
  private JMenuItem loadSoundItem;
  private JMenu lookAndFeelMenu;
  private JMenuBar menuBar;
  private JMenu midiMenu;
  private jrackattack.gui.ModEnvPanel modEnvPanel;
  private jrackattack.gui.OscillatorPanel oscillatorPanel;
  private jrackattack.gui.ProgramPanel programPanel;
  private JMenu rackAttackMenu;
  private JMenuItem saveFXItem;
  private JMenuItem saveGlobalItem;
  private JMenuItem savePatternItem;
  private JMenuItem saveProgramItem;
  private JMenuItem saveSoundItem;
  private jrackattack.gui.SoundPanel soundPanel;
  private jrackattack.gui.VolumePanel volumePanel1;
  private jrackattack.gui.VolumePanel2 volumePanel2;
  // End of variables declaration

  private static JRackAttackFrame instance;

  private int activeSoundNumber;

  private int activeChannel = 1;

  private int programNumber = 1;

  private String oldDir;

  private ArrayList<SoundParameterListener> soundParameterListener = new ArrayList<SoundParameterListener>();
  private ArrayList<FXParameterListener> fxParameterListener = new ArrayList<FXParameterListener>();
  private ArrayList<GlobalParameterListener> globalParameterListener = new ArrayList<GlobalParameterListener>();
  private ArrayList<PatternParameterListener> patternParameterListener = new ArrayList<PatternParameterListener>();
  private ArrayList<ProgramParameterListener> programParameterListener = new ArrayList<ProgramParameterListener>();
  private ArrayList<ColorSchemeListener> colorSchemeListener = new ArrayList<ColorSchemeListener>();

  private JFileChooser fileChooser;

  private ColorScheme colorScheme = ColorScheme.restoreFrom(UserConfiguration
      .getInstance());

  private SoundParameter[] soundParameter = new SoundParameter[24];
  private FXParameter[] fxParameter = new FXParameter[4];
  private GlobalParameter globalParameter;
  private PatternParameter[] patternParameter = new PatternParameter[24];
  private ProgramParameter[] programParameter = new ProgramParameter[50];

  /**
   * Getter for property colorScheme.
   *
   * @return Value of property colorScheme.
   */
  public ColorScheme getColorScheme() {
    return this.colorScheme;
  }

  /**
   * Setter for property colorScheme.
   *
   * @param colorScheme
   *            New value of property colorScheme.
   */
  public void setColorScheme(ColorScheme colorScheme) {
    this.colorScheme = colorScheme;
    fireColorSchemeChanged();
  }
}
/*
* 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 jrackattack.gui.JRackAttackFrame$LookAndFeelAction

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.