PieterVoet
stranger
Reged: 11/19/07
Posts: 3
|
|
Hi David and Krishnakumar,
thanks for your nice article. I couldn't stand the limitations, so I rewrote the CloseTabePaneUI, and now it supports both scrolling and tabplacements. With that, I tried to rewrite as little as possible from the BasicTabbedPaneUI. For anyone who might need it, here's the code :
------------- CloseTabPaneUI.java ------- /* * Created on Nov 14, 2007 */ package pv;
import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.image.BufferedImage; import java.lang.reflect.Field; import java.util.Random;
import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.border.Border; import javax.swing.border.SoftBevelBorder; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicTabbedPaneUI;
import com.sun.java.swing.plaf.windows.WindowsIconFactory;
/** * @author david * @author krishnakumar * @author pieter */ public class CloseTabPaneUI extends BasicTabbedPaneUI { private static final int INACTIVE = 0; private static final int OVER = 1; private static final int PRESSED = 2; protected static final int BUTTONSIZE = 15; protected static final int WIDTHDELTA = 5; private int closeIndexStatus = INACTIVE; private int maxIndexStatus = INACTIVE; private static final Border PRESSEDBORDER = new SoftBevelBorder(SoftBevelBorder.LOWERED); private static final Border OVERBORDER = new SoftBevelBorder(SoftBevelBorder.RAISED); private boolean isCloseButtonEnabled = true; private boolean isMaxButtonEnabled = true; private int overTabIndex = -1; private boolean mousePressed = false; protected CloseTabPaneMouseMotionListener mouseMotionListener; private int tabCount; private BufferedImage closeImgB; private BufferedImage maxImgB; private BufferedImage closeImgI; private BufferedImage maxImgI; private JButton closeB; private JButton maxB; protected JComponent tabScrollerTabPane = null;
public CloseTabPaneUI() { super(); closeImgB = new BufferedImage(BUTTONSIZE, BUTTONSIZE, BufferedImage.TYPE_4BYTE_ABGR); maxImgB = new BufferedImage(BUTTONSIZE, BUTTONSIZE, BufferedImage.TYPE_4BYTE_ABGR); closeImgI = new BufferedImage(BUTTONSIZE, BUTTONSIZE, BufferedImage.TYPE_4BYTE_ABGR); maxImgI = new BufferedImage(BUTTONSIZE, BUTTONSIZE, BufferedImage.TYPE_4BYTE_ABGR);
closeB = new JButton(); closeB.setSize(BUTTONSIZE, BUTTONSIZE);
maxB = new JButton(); maxB.setSize(BUTTONSIZE, BUTTONSIZE);
WindowsIconFactory.createFrameCloseIcon().paintIcon(closeB, closeImgI.createGraphics(), 0, 0); WindowsIconFactory.createFrameMaximizeIcon().paintIcon(maxB, maxImgI.createGraphics(), 0, 0); }
protected void installListeners() { super.installListeners();
try { Field tsField = BasicTabbedPaneUI.class.getDeclaredField("tabScroller"); tsField.setAccessible(true);
Object ts = tsField.get(this); Field tpField = ts.getClass().getDeclaredField("tabPanel"); tpField.setAccessible(true);
tabScrollerTabPane = (JComponent) tpField.get(ts); } catch (Exception e) { }
if ((mouseMotionListener = createMouseMotionListener()) != null) { if (tabScrollerTabPane != null) tabScrollerTabPane.addMouseMotionListener(mouseMotionListener); else tabPane.addMouseMotionListener(mouseMotionListener); } }
protected void uninstallListeners() { if (mouseMotionListener != null) { if (tabScrollerTabPane != null) tabScrollerTabPane.removeMouseMotionListener(mouseMotionListener); else tabPane.removeMouseMotionListener(mouseMotionListener); mouseMotionListener = null; } }
protected MouseListener createMouseListener() { return new CloseTabPaneMouseHandler(); }
protected CloseTabPaneMouseMotionListener createMouseMotionListener() { return new CloseTabPaneMouseMotionListener(); }
protected boolean isOneActionButtonEnabled() { return isCloseButtonEnabled || isMaxButtonEnabled; }
public boolean isCloseEnabled() { return isCloseButtonEnabled; }
public boolean isMaxEnabled() { return isMaxButtonEnabled; }
public void setCloseIcon(boolean set) { isCloseButtonEnabled = set; }
public void setMaxIcon(boolean set) { isMaxButtonEnabled = set; }
protected Rectangle newCloseRect(Rectangle rect) { int dx = rect.x + rect.width; // FIX int dy = (rect.y + rect.height) / 2 - 6; int dy = rect.y + 6;
return new Rectangle(dx - BUTTONSIZE - WIDTHDELTA, dy, BUTTONSIZE, BUTTONSIZE); }
protected Rectangle newMaxRect(Rectangle rect) { int dx = rect.x + rect.width; // FIX int dy = (rect.y + rect.height) / 2 - 6; int dy = rect.y + 6;
if (isCloseButtonEnabled) dx -= BUTTONSIZE;
return new Rectangle(dx - BUTTONSIZE - WIDTHDELTA, dy, BUTTONSIZE, BUTTONSIZE); }
protected void updateCloseIcon(int x, int y) { if (overTabIndex != -1) { int newCloseIndexStatus = INACTIVE;
Rectangle closeRect = newCloseRect(rects[overTabIndex]);
if (closeRect.contains(x, y)) newCloseIndexStatus = mousePressed ? PRESSED : OVER;
if (closeIndexStatus != (closeIndexStatus = newCloseIndexStatus)) tabPane.repaint(); } }
protected void updateMaxIcon(int x, int y) { if (overTabIndex != -1) { int newMaxIndexStatus = INACTIVE;
Rectangle maxRect = newMaxRect(rects[overTabIndex]);
if (maxRect.contains(x, y)) newMaxIndexStatus = mousePressed ? PRESSED : OVER;
if (maxIndexStatus != (maxIndexStatus = newMaxIndexStatus)) tabPane.repaint(); } }
private void setTabIcons(int x, int y) { //if the mouse isPressed if (!mousePressed) { updateOverTab(x, y); }
if (isCloseButtonEnabled) updateCloseIcon(x, y); if (isMaxButtonEnabled) updateMaxIcon(x, y); }
private int getTabAtLocation(int x, int y) { // FIX ensureCurrentLayout();
int tabCount = tabPane.getTabCount(); for (int i = 0; i < tabCount; i++) { if (rects.contains(x, y)) { return i; } } return -1; }
protected void updateOverTab(int x, int y) { if (overTabIndex != (overTabIndex = getTabAtLocation(x, y))) tabPane.repaint(); }
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) { int delta = 2; if (!isOneActionButtonEnabled()) delta += 6; else { if (isCloseButtonEnabled) delta += BUTTONSIZE + WIDTHDELTA; if (isMaxButtonEnabled) delta += BUTTONSIZE + WIDTHDELTA; }
return super.calculateTabWidth(tabPlacement, tabIndex, metrics) + delta; }
protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) { return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight) + 5; }
public static ComponentUI createUI(JComponent c) { return new CloseTabPaneUI(); }
public void paint(Graphics g, JComponent c) { int tc = tabPane.getTabCount();
if (tabCount != tc) { tabCount = tc; // FIX updateMnemonics(); }
super.paint(g, c); }
protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect) { super.paintTab(g, tabPlacement, rects, tabIndex, iconRect, textRect);
Rectangle tabRect = rects[tabIndex]; Graphics2D g2 = null; int selectedIndex = tabPane.getSelectedIndex(); boolean isOver = overTabIndex == tabIndex; boolean isSelected = selectedIndex == tabIndex;
String title = tabPane.getTitleAt(tabIndex); Font font = tabPane.getFont(); FontMetrics metrics = g.getFontMetrics(font); Icon icon = getIconForTab(tabIndex);
// Hide the super tabtext Color color = getBackgroundColor(isSelected); g.setColor(color); g.fillRect(textRect.x, textRect.y + 1, textRect.width, textRect.height - 2);
SwingUtilities.layoutCompoundLabel( (JComponent) tabPane, metrics, title, icon, SwingUtilities.CENTER, SwingUtilities.LEFT, SwingUtilities.CENTER, SwingUtilities.CENTER, tabRect, iconRect, textRect, textIconGap);
textRect.x += BUTTONSIZE; textRect.y += (tabRect.height - textRect.height) / 2; switch (tabPlacement) { case JTabbedPane.TOP: break; case JTabbedPane.LEFT: case JTabbedPane.RIGHT: textRect.y += (tabRect.height / 2) * tabIndex; break; case JTabbedPane.BOTTOM: textRect.y -= 2; }
paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected);
if (g instanceof Graphics2D) g2 = (Graphics2D) g;
if (isOver || isSelected) { int dx = tabRect.x + tabRect.width - BUTTONSIZE - WIDTHDELTA;
if (isCloseButtonEnabled) paintCloseIcon(g2, dx, textRect.y, isOver, color); if (isMaxButtonEnabled) paintMaxIcon(g2, dx, textRect.y, isOver, color); } }
protected Color getBackgroundColor(boolean isSelected) { Color color = UIManager.getColor("TabbedPane.selected");
if (!isSelected || color == null) color = tabPane.getBackground();
return color; }
protected void paintCloseIcon(Graphics g, int dx, int dy, boolean isOver, Color color) { paintActionButton(g, dx, dy, closeIndexStatus, isOver, closeB, closeImgB, color); g.drawImage(closeImgI, dx, dy + 1, null); }
protected void paintMaxIcon(Graphics g, int dx, int dy, boolean isOver, Color color) { if (isCloseButtonEnabled) dx -= BUTTONSIZE;
paintActionButton(g, dx, dy, maxIndexStatus, isOver, maxB, maxImgB, color); g.drawImage(maxImgI, dx, dy + 1, null); }
protected void paintActionButton(Graphics g, int dx, int dy, int status, boolean isOver, JButton button, BufferedImage image, Color color) { button.setBorder(null);
if (isOver) { switch (status) { case OVER: button.setBorder(OVERBORDER); break; case PRESSED: button.setBorder(PRESSEDBORDER); break; } }
button.setBackground(color); button.paint(image.getGraphics()); g.drawImage(image, dx, dy, null); }
class CloseTabPaneMouseHandler extends MouseHandler { public CloseTabPaneMouseHandler() { super(); }
public void mousePressed(MouseEvent e) { if (closeIndexStatus == OVER) { closeIndexStatus = PRESSED; tabPane.repaint(); return; }
if (maxIndexStatus == OVER) { maxIndexStatus = PRESSED; tabPane.repaint(); return; } }
public void mouseClicked(MouseEvent e) { super.mousePressed(e); if (e.getClickCount() > 1 && overTabIndex != -1) { ((CloseAndMaxTabbedPane) tabPane).fireDoubleClickTabEvent(e, overTabIndex); } }
public void mouseReleased(MouseEvent e) { updateOverTab(e.getX(), e.getY());
if (overTabIndex == -1) { if (e.isPopupTrigger()) ((CloseAndMaxTabbedPane) tabPane).firePopupOutsideTabEvent(e); return; }
if (closeIndexStatus == PRESSED) { closeIndexStatus = OVER; tabPane.repaint(); ((CloseAndMaxTabbedPane) tabPane).fireCloseTabEvent(e, overTabIndex); return; }
if (maxIndexStatus == PRESSED) { maxIndexStatus = OVER; tabPane.repaint(); ((CloseAndMaxTabbedPane) tabPane).fireMaxTabEvent(e, overTabIndex); return; } }
public void mouseExited(MouseEvent e) { if (!mousePressed) { overTabIndex = -1; tabPane.repaint(); }
super.mouseExited(e); } }
class CloseTabPaneMouseMotionListener implements MouseMotionListener { public void mouseMoved(MouseEvent e) { mousePressed = false; setTabIcons(e.getX(), e.getY()); }
public void mouseDragged(MouseEvent e) { mousePressed = true; setTabIcons(e.getX(), e.getY()); } } }
----- end of CloseTabPaneUI.java ------
You might change the package ofcourse, and maybe also re-add the popup to the UI... I didn't need it..
Have fun, Pieter Voet.
|
PieterVoet
stranger
Reged: 11/19/07
Posts: 3
|
|
Hmm... I always run my code with lower Java versions in attempt to be as downwards compatibel as possible.. But now I tried running with Java5 and it sucks ! Also, since I use Linux, the close and max icons look like crap. I'll have to dig into this a bit more...
Pieter.
|
PieterVoet
stranger
Reged: 11/19/07
Posts: 3
|
|
OK, I've got it all sorted out.. I now have it running fine on Java 5 and 4...
Here is the UI again : Code:
/* * Created on Nov 14, 2007 */ package pv.swing;
import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.event.ContainerEvent; import java.awt.event.ContainerListener; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.lang.reflect.Field;
import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.border.Border; import javax.swing.border.SoftBevelBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicTabbedPaneUI;
/** * @author pieter */ public class CloseTabPaneUI extends BasicTabbedPaneUI { private static final int INACTIVE = 0; private static final int OVER = 1; private static final int PRESSED = 2; protected static final int BUTTONSIZE = 15; protected static final int WIDTHDELTA = 5; private int closeIndexStatus = INACTIVE; private int maxIndexStatus = INACTIVE; private static final Border PRESSEDBORDER = new SoftBevelBorder(SoftBevelBorder.LOWERED); private static final Border OVERBORDER = new SoftBevelBorder(SoftBevelBorder.RAISED); private boolean isCloseButtonEnabled = true; private boolean isMaxButtonEnabled = true; private int overTabIndex = -1; private boolean mousePressed = false; protected MouseMotionListener mouseMotionListener; private int tabCount; private BufferedImage closeImgB; private BufferedImage maxImgB; private BufferedImage closeImgI; private BufferedImage maxImgI; private JButton closeB; private JButton maxB; protected JComponent tabScrollerTabPane = null; protected Object superHandler = null; protected Handler handler = null;
public CloseTabPaneUI() { super(); closeImgB = new BufferedImage(BUTTONSIZE, BUTTONSIZE, BufferedImage.TYPE_4BYTE_ABGR); maxImgB = new BufferedImage(BUTTONSIZE, BUTTONSIZE, BufferedImage.TYPE_4BYTE_ABGR); closeImgI = new BufferedImage(BUTTONSIZE, BUTTONSIZE, BufferedImage.TYPE_4BYTE_ABGR); maxImgI = new BufferedImage(BUTTONSIZE, BUTTONSIZE, BufferedImage.TYPE_4BYTE_ABGR);
closeB = new JButton(); closeB.setSize(BUTTONSIZE, BUTTONSIZE);
maxB = new JButton(); maxB.setSize(BUTTONSIZE, BUTTONSIZE);
closeB.setIcon(UIManager.getIcon("InternalFrame.closeIcon")); maxB.setIcon(UIManager.getIcon("InternalFrame.maximizeIcon")); }
protected void installListeners() { super.installListeners();
try { Field tsField = BasicTabbedPaneUI.class.getDeclaredField("tabScroller"); tsField.setAccessible(true);
Object ts = tsField.get(this); Field tpField = ts.getClass().getDeclaredField("tabPanel"); tpField.setAccessible(true);
tabScrollerTabPane = (JComponent) tpField.get(ts);
Field handlerField = BasicTabbedPaneUI.class.getDeclaredField("handler"); handlerField.setAccessible(true); superHandler = handlerField.get(this); } catch (Exception e) { }
if ((mouseMotionListener = createMouseMotionListener()) != null) { if (tabScrollerTabPane != null) { tabScrollerTabPane.addMouseMotionListener(mouseMotionListener); tabScrollerTabPane.addMouseListener(getHandler()); } else tabPane.addMouseMotionListener(mouseMotionListener); } }
protected void uninstallListeners() { if (mouseMotionListener != null) { if (tabScrollerTabPane != null) tabScrollerTabPane.removeMouseMotionListener(mouseMotionListener); else tabPane.removeMouseMotionListener(mouseMotionListener); mouseMotionListener = null; } }
protected MouseListener createMouseListener() { return getHandler(); } private Handler getHandler() { if (handler == null) { handler = new Handler(); } return handler; }
protected MouseMotionListener createMouseMotionListener() { return getHandler(); }
protected boolean isOneActionButtonEnabled() { return isCloseButtonEnabled || isMaxButtonEnabled; }
public boolean isCloseEnabled() { return isCloseButtonEnabled; }
public boolean isMaxEnabled() { return isMaxButtonEnabled; }
public void setCloseIcon(boolean set) { isCloseButtonEnabled = set; }
public void setMaxIcon(boolean set) { isMaxButtonEnabled = set; }
protected Rectangle newCloseRect(Rectangle rect) { int dx = rect.x + rect.width; int dy = rect.y + 6;
return new Rectangle(dx - BUTTONSIZE - WIDTHDELTA, dy, BUTTONSIZE, BUTTONSIZE); }
protected Rectangle newMaxRect(Rectangle rect) { int dx = rect.x + rect.width; int dy = rect.y + 6;
if (isCloseButtonEnabled) dx -= BUTTONSIZE;
return new Rectangle(dx - BUTTONSIZE - WIDTHDELTA, dy, BUTTONSIZE, BUTTONSIZE); }
protected void updateCloseIcon(int x, int y) { if (overTabIndex != -1) { int newCloseIndexStatus = INACTIVE;
Rectangle closeRect = newCloseRect(rects[overTabIndex]);
if (closeRect.contains(x, y)) newCloseIndexStatus = mousePressed ? PRESSED : OVER;
if (closeIndexStatus != (closeIndexStatus = newCloseIndexStatus)) tabPane.repaint(); } }
protected void updateMaxIcon(int x, int y) { if (overTabIndex != -1) { int newMaxIndexStatus = INACTIVE;
Rectangle maxRect = newMaxRect(rects[overTabIndex]);
if (maxRect.contains(x, y)) newMaxIndexStatus = mousePressed ? PRESSED : OVER;
if (maxIndexStatus != (maxIndexStatus = newMaxIndexStatus)) tabPane.repaint(); } }
private void setTabIcons(int x, int y) { //if the mouse isPressed if (!mousePressed) { updateOverTab(x, y); }
if (isCloseButtonEnabled) updateCloseIcon(x, y); if (isMaxButtonEnabled) updateMaxIcon(x, y); }
private int getTabAtLocation(int x, int y) { // FIX ensureCurrentLayout();
int tabCount = tabPane.getTabCount(); for (int i = 0; i < tabCount; i++) { if (rects[i].contains(x, y)) { return i; } } return -1; }
protected void updateOverTab(int x, int y) { if (overTabIndex != (overTabIndex = getTabAtLocation(x, y))) tabPane.repaint(); }
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) { int delta = 2; if (!isOneActionButtonEnabled()) delta += 6; else { if (isCloseButtonEnabled) delta += BUTTONSIZE + WIDTHDELTA; if (isMaxButtonEnabled) delta += BUTTONSIZE + WIDTHDELTA; }
return super.calculateTabWidth(tabPlacement, tabIndex, metrics) + delta; }
protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) { return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight) + WIDTHDELTA; }
public static ComponentUI createUI(JComponent c) { return new CloseTabPaneUI(); }
protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect) { super.paintTab(g, tabPlacement, rects, tabIndex, iconRect, textRect);
Rectangle tabRect = rects[tabIndex]; Graphics2D g2 = null; int selectedIndex = tabPane.getSelectedIndex(); boolean isOver = overTabIndex == tabIndex; boolean isSelected = selectedIndex == tabIndex;
String title = tabPane.getTitleAt(tabIndex); Font font = tabPane.getFont(); FontMetrics metrics = g.getFontMetrics(font); Icon icon = getIconForTab(tabIndex);
// Hide the super tabtext Color color = getBackgroundColor(isSelected); g.setColor(color); g.fillRect(textRect.x, textRect.y + 1, textRect.width, textRect.height - 2);
SwingUtilities.layoutCompoundLabel( (JComponent) tabPane, metrics, title, icon, SwingUtilities.CENTER, SwingUtilities.LEFT, SwingUtilities.CENTER, SwingUtilities.CENTER, tabRect, iconRect, textRect, textIconGap);
textRect.x += BUTTONSIZE; textRect.y += (tabRect.height - textRect.height) / 2; switch (tabPlacement) { case JTabbedPane.TOP: break; case JTabbedPane.LEFT: case JTabbedPane.RIGHT: textRect.y += (tabRect.height / 2) * tabIndex; break; case JTabbedPane.BOTTOM: textRect.y -= 2; }
paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected);
if (g instanceof Graphics2D) g2 = (Graphics2D) g;
if (isOver || isSelected) { int dx = tabRect.x + tabRect.width - BUTTONSIZE - WIDTHDELTA;
if (isCloseButtonEnabled) paintCloseIcon(g2, dx, textRect.y, isOver, color); if (isMaxButtonEnabled) paintMaxIcon(g2, dx, textRect.y, isOver, color); } }
protected Color getBackgroundColor(boolean isSelected) { Color color = UIManager.getColor("TabbedPane.selected");
if (!isSelected || color == null) color = tabPane.getBackground();
return color; }
protected void paintCloseIcon(Graphics g, int dx, int dy, boolean isOver, Color color) { paintActionButton(g, dx, dy, closeIndexStatus, isOver, closeB, closeImgB, color); g.drawImage(closeImgI, dx, dy + 1, null); }
protected void paintMaxIcon(Graphics g, int dx, int dy, boolean isOver, Color color) { if (isCloseButtonEnabled) dx -= BUTTONSIZE;
paintActionButton(g, dx, dy, maxIndexStatus, isOver, maxB, maxImgB, color); g.drawImage(maxImgI, dx, dy + 1, null); }
protected void paintActionButton(Graphics g, int dx, int dy, int status, boolean isOver, JButton button, BufferedImage image, Color color) { button.setBorder(null);
if (isOver) { switch (status) { case OVER: button.setBorder(OVERBORDER); break; case PRESSED: button.setBorder(PRESSEDBORDER); break; } }
button.setBackground(color); button.paint(image.getGraphics()); g.drawImage(image, dx, dy, null); } class Handler extends MouseHandler implements ChangeListener, ContainerListener, FocusListener, MouseMotionListener, PropertyChangeListener { public void mouseMoved(MouseEvent e) { if (superHandler != null) ((MouseMotionListener) superHandler).mouseMoved(e); mousePressed = false; setTabIcons(e.getX(), e.getY()); }
public void mouseDragged(MouseEvent e) { if (superHandler != null) ((MouseMotionListener) superHandler).mouseMoved(e); mousePressed = true; setTabIcons(e.getX(), e.getY()); }
public void stateChanged(ChangeEvent e) { if (superHandler != null) ((ChangeListener) superHandler).stateChanged(e); }
public void componentAdded(ContainerEvent e) { if (superHandler != null) ((ContainerListener) superHandler).componentAdded(e); }
public void componentRemoved(ContainerEvent e) { if (superHandler != null) ((ContainerListener) superHandler).componentRemoved(e); }
public void focusGained(FocusEvent e) { if (superHandler != null) ((FocusListener) superHandler).focusGained(e); }
public void focusLost(FocusEvent e) { if (superHandler != null) ((FocusListener) superHandler).focusLost(e); }
public void mouseClicked(MouseEvent e) { if (superHandler != null) ((MouseListener) superHandler).mouseClicked(e); else super.mouseClicked(e); if (e.getClickCount() > 1 && overTabIndex != -1) { ((CloseAndMaxTabbedPane) tabPane).fireDoubleClickTabEvent(e, overTabIndex); } }
public void mousePressed(MouseEvent e) { if (superHandler != null && e.getSource() == tabScrollerTabPane) { switch(tabPane.getTabPlacement()) { case JTabbedPane.BOTTOM : e.translatePoint(0, tabPane.getHeight() - tabScrollerTabPane.getHeight()); break; case JTabbedPane.RIGHT : e.translatePoint(tabPane.getWidth() - tabScrollerTabPane.getWidth(), 0); break; } } if (superHandler != null) ((MouseListener) superHandler).mousePressed(e); else super.mousePressed(e); if (closeIndexStatus == OVER) { closeIndexStatus = PRESSED; tabPane.repaint(); return; }
if (maxIndexStatus == OVER) { maxIndexStatus = PRESSED; tabPane.repaint(); return; } }
public void mouseReleased(MouseEvent e) { if (superHandler != null) ((MouseListener) superHandler).mouseReleased(e); else super.mouseReleased(e);
updateOverTab(e.getX(), e.getY());
if (overTabIndex == -1) { if (e.isPopupTrigger()) ((CloseAndMaxTabbedPane) tabPane).firePopupOutsideTabEvent(e); return; }
if (closeIndexStatus == PRESSED) { closeIndexStatus = OVER; tabPane.repaint(); ((CloseAndMaxTabbedPane) tabPane).fireCloseTabEvent(e, overTabIndex); return; }
if (maxIndexStatus == PRESSED) { maxIndexStatus = OVER; tabPane.repaint(); ((CloseAndMaxTabbedPane) tabPane).fireMaxTabEvent(e, overTabIndex); return; } }
public void mouseEntered(MouseEvent e) { if (superHandler != null) ((MouseListener) superHandler).mouseEntered(e); else super.mouseEntered(e); }
public void mouseExited(MouseEvent e) { if (superHandler != null) ((MouseListener) superHandler).mouseExited(e); else super.mouseExited(e);
if (!mousePressed) { overTabIndex = -1; tabPane.repaint(); } }
public void propertyChange(PropertyChangeEvent evt) { if (superHandler != null) ((PropertyChangeListener) superHandler).propertyChange(evt); } } }
|
|