2020-06-26 04:39:05 +00:00
|
|
|
package com.bytezone.diskbrowser.utilities;
|
|
|
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
|
|
|
import javax.swing.AbstractAction;
|
|
|
|
import javax.swing.Action;
|
|
|
|
import javax.swing.ImageIcon;
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------//
|
|
|
|
public abstract class DefaultAction extends AbstractAction
|
|
|
|
// -----------------------------------------------------------------------------------//
|
|
|
|
{
|
|
|
|
final String baseURL;
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
public DefaultAction (String text, String tip)
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
{
|
|
|
|
super (text);
|
2022-07-30 23:21:52 +00:00
|
|
|
|
2020-06-26 04:39:05 +00:00
|
|
|
this.baseURL = null;
|
|
|
|
putValue (Action.SHORT_DESCRIPTION, tip);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
public DefaultAction (String text, String tip, String baseURL)
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
{
|
|
|
|
super (text);
|
2022-07-30 23:21:52 +00:00
|
|
|
|
2020-06-26 04:39:05 +00:00
|
|
|
this.baseURL = baseURL;
|
|
|
|
putValue (Action.SHORT_DESCRIPTION, tip);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
protected void setIcon (String iconType, String iconName)
|
|
|
|
// ---------------------------------------------------------------------------------//
|
|
|
|
{
|
|
|
|
if (baseURL == null)
|
|
|
|
{
|
|
|
|
System.out.println ("Base URL not set");
|
|
|
|
return;
|
|
|
|
}
|
2022-07-30 23:21:52 +00:00
|
|
|
|
2020-06-26 04:39:05 +00:00
|
|
|
URL url = this.getClass ().getResource (baseURL + iconName);
|
|
|
|
if (url != null)
|
|
|
|
putValue (iconType, new ImageIcon (url));
|
|
|
|
}
|
|
|
|
}
|