package Common.Visual.Menus; import Common.CommonConstants; import Common.Utils.Utils_; import javax.swing.*; public class TableMenu extends StyledPopupMenu { int row = CommonConstants.Nan; int column = CommonConstants.Nan; Object target = null; //- JTable owner = null; VisualiserMenuItem mcopy; public TableMenu(JTable owner_in) { owner = owner_in; mcopy = new VisualiserMenuItem("Копировать текст текущей ячейки", "/icons/Editor/Copy.png"); //если удалось нажать значит все условия выполнены mcopy.addActionListener(e -> Utils_.CopyToClipboard(target.toString())); add(mcopy); } @Override public void CheckElementsVisibility() { row = owner.getSelectedRow(); column = owner.getSelectedColumn(); if ((row >= 0) && (column >= 0)) { target = owner.getValueAt(row, column); mcopy.setVisible(true); } else mcopy.setVisible(false); super.CheckElementsVisibility(); } }