dmolony-DiskBrowser/src/com/bytezone/diskbrowser/gui/PreviousPaletteAction.java

44 lines
1.2 KiB
Java
Raw Normal View History

2017-01-14 01:40:58 +00:00
package com.bytezone.diskbrowser.gui;
import java.awt.event.ActionEvent;
import java.util.Enumeration;
import javax.swing.*;
import com.bytezone.diskbrowser.applefile.Palette;
import com.bytezone.diskbrowser.applefile.PaletteFactory.CycleDirection;
public class PreviousPaletteAction extends AbstractAction
{
private final DataPanel owner;
private final ButtonGroup buttonGroup;
public PreviousPaletteAction (DataPanel owner, ButtonGroup buttonGroup)
{
super ("Previous Palette");
putValue (Action.SHORT_DESCRIPTION, "Select previous color palette");
2017-01-26 04:19:23 +00:00
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("meta alt P"));
2017-01-14 01:40:58 +00:00
this.owner = owner;
this.buttonGroup = buttonGroup;
}
@Override
public void actionPerformed (ActionEvent e)
{
Palette palette = owner.cyclePalette (CycleDirection.BACKWARDS);
2017-01-14 11:11:07 +00:00
2017-01-14 01:40:58 +00:00
if (palette != null)
{
Enumeration<AbstractButton> enumeration = buttonGroup.getElements ();
while (enumeration.hasMoreElements ())
{
JCheckBoxMenuItem item = (JCheckBoxMenuItem) enumeration.nextElement ();
if (item.getText ().equals (palette.getName ()))
{
item.setSelected (true);
break;
}
}
}
}
}