Terai Atsuhiro 2024-01-27 (土) 14:37:42

http://terai.xrea.jp/swing/tabbedpane/screenshot.png

private void showTabPop(MouseEvent e){
  JPopupMenu pop = new JPopupMenu();
  AbstractAction action = new NewTabAction(MENUITEM_NEWTAB, null);
  pop.add(action);
  pop.addSeparator();
  action = new ClosePageAction(MENUITEM_CLOSEPAGE, null);
  
  int num = tab.getUI().tabForCoordinate(tab, e.getX(), e.getY());
  action = new ClosePageAction(MENUITEM_CLOSEPAGE, null);
  action.setEnabled(num>0?true:false);
  //boolean flg = false;
  //for(int i=0;i<tab.getTabCount();i++){
  //  if(tab.getBoundsAt(i).contains(e.getPoint())){
  //    flg = true;
  //    break;
  //  }
  //}
  //action.setEnabled(flg);
  pop.add(action);
  pop.addSeparator();
  action = new CloseAllAction(MENUITEM_CLOSEALL, null);
  pop.add(action);
  action = new CloseAllButActiveAction(MENUITEM_CLOSEALLBUTACTIVE, null);
  pop.add(action);
  pop.show(tab, e.getX(), e.getY());
}