2024-10-07 00:58:29 +03:00
|
|
|
package Common_old.UI.Menus_2023;
|
2024-10-07 20:04:11 +03:00
|
|
|
import Common.Utils.CommonUtils;
|
2024-10-07 00:58:29 +03:00
|
|
|
import Common_old.UI.Menus.VisualiserMenuItem;
|
|
|
|
|
import Common_old.UI.UI;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import javax.swing.plaf.ComponentUI;
|
|
|
|
|
import javax.swing.plaf.basic.BasicMenuItemUI;
|
|
|
|
|
//неичезающий меню итем. нужен для настроек
|
|
|
|
|
//https://translated.turbopages.org/proxy_u/en-ru.ru.64537f6c-6460c460-8e74a1ab-74722d776562/https/tips4java.wordpress.com/2010/09/12/keeping-menus-open/
|
|
|
|
|
class StableItemUI extends BasicMenuItemUI {
|
|
|
|
|
public static ComponentUI createUI(JComponent c) {
|
|
|
|
|
return new StableItemUI();
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void doClick(MenuSelectionManager msm) {
|
|
|
|
|
menuItem.doClick(0);
|
|
|
|
|
if (UI.last_menu_path != null)
|
|
|
|
|
MenuSelectionManager.defaultManager().setSelectedPath(UI.last_menu_path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class StableMenuItem extends VisualiserMenuItem {
|
|
|
|
|
{
|
|
|
|
|
getModel().addChangeListener(e -> {
|
|
|
|
|
if (getModel().isArmed() && isShowing())
|
|
|
|
|
UI.last_menu_path = MenuSelectionManager.defaultManager().getSelectedPath();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
public StableMenuItem(String text) {
|
|
|
|
|
super(text);
|
|
|
|
|
setUI(new StableItemUI());
|
|
|
|
|
}
|
|
|
|
|
public StableMenuItem(String text, String icon_path) {
|
|
|
|
|
super(text);
|
2024-10-07 20:04:11 +03:00
|
|
|
setIcon(CommonUtils.getIcon(icon_path));
|
2023-09-17 22:13:42 +03:00
|
|
|
setUI(new StableItemUI());
|
|
|
|
|
}
|
|
|
|
|
public StableMenuItem() {
|
|
|
|
|
setUI(new StableItemUI());
|
|
|
|
|
}
|
|
|
|
|
}
|