List of usage examples for javax.swing JTabbedPane removeTabAt
@SuppressWarnings("deprecation") public void removeTabAt(int index)
index
. From source file:Main.java
@Override protected void processMouseEvent(MouseEvent e, JLayer<? extends JTabbedPane> l) { if (e.getID() != MouseEvent.MOUSE_CLICKED) { return;/*from w w w . j a va 2s .c o m*/ } pt.setLocation(e.getPoint()); JTabbedPane tabbedPane = (JTabbedPane) l.getView(); int index = tabbedPane.indexAtLocation(pt.x, pt.y); if (index >= 0) { Rectangle rect = tabbedPane.getBoundsAt(index); Dimension d = button.getPreferredSize(); int x = rect.x + rect.width - d.width - 2; int y = rect.y + (rect.height - d.height) / 2; Rectangle r = new Rectangle(x, y, d.width, d.height); if (r.contains(pt)) { tabbedPane.removeTabAt(index); } } l.getView().repaint(); }
From source file:it.unifi.rcl.chess.traceanalysis.gui.TracePanel.java
public void dispose() { JTabbedPane parent = ((JTabbedPane) getParent()); parent.removeTabAt(parent.indexOfComponent(this)); }
From source file:gui.LauncherFrame.java
/** * removes a tab that begins with the specified name. * /*from w w w . j a v a 2 s . c o m*/ * @param tabbedPane - the tabbed pane to remove an entry from * @param name - the name (or begining of the name) of the tab * * @return 1 if tab removed, 0 if not */ private int removeTextTab(javax.swing.JTabbedPane tabbedPane, String name) { int count = tabbedPane.getTabCount(); for (int ix = 0; ix < count; ix++) { String tabname = tabbedPane.getTitleAt(ix); if (tabname.startsWith(name)) { tabbedPane.removeTabAt(ix); debug.print(DebugMessage.StatusType.Info, "Removed tab: " + tabname); return 1; } } return 0; }