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

47 lines
1.1 KiB
Java
Raw Normal View History

2015-06-01 09:35:51 +00:00
package com.bytezone.diskbrowser.gui;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFrame;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
class HideLayoutAction extends AbstractAction
{
JFrame owner;
JPanel layoutPanel;
public HideLayoutAction (JFrame owner, JPanel layoutPanel)
{
super ("Show disk layout panel");
putValue (Action.SHORT_DESCRIPTION, "Show/hide the disk layout panel");
putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("alt D"));
putValue (Action.MNEMONIC_KEY, KeyEvent.VK_D);
this.owner = owner;
this.layoutPanel = layoutPanel;
}
public void actionPerformed (ActionEvent e)
{
set (((JMenuItem) e.getSource ()).isSelected ());
}
public void set (boolean show)
{
if (show)
{
owner.add (layoutPanel, BorderLayout.EAST);
owner.validate ();
}
else
{
owner.remove (layoutPanel);
owner.validate ();
}
}
}