mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-16 04:04:39 +00:00
47 lines
1.1 KiB
Java
47 lines
1.1 KiB
Java
|
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 ();
|
||
|
}
|
||
|
}
|
||
|
}
|