Search in sources :

Example 1 with WindowsTabbedPaneUI

use of com.sun.java.swing.plaf.windows.WindowsTabbedPaneUI in project java-swing-tips by aterai.

the class CloseableTabbedPaneUI method updateUI.

// /**
// * The normal closeicon.
// */
// private Icon normalCloseIcon;
// 
// /**
// * The closeicon when the mouse is over.
// */
// private Icon hooverCloseIcon;
// 
// /**
// * The closeicon when the mouse is pressed.
// */
// private Icon pressedCloseIcon;
// 
// /**
// * Creates a new instance of <code>CloseableTabbedPane</code>.
// */
// public CloseableTabbedPane() {
// super();
// init(SwingConstants.LEFT);
// }
// 
// /**
// * Creates a new instance of <code>CloseableTabbedPane</code>.
// * @param horizTextPosition  the horizontal position of the text (e.g.
// * SwingConstants.TRAILING or SwingConstants.LEFT)
// */
// public CloseableTabbedPane(int horizTextPosition) {
// super();
// init(horizTextPosition);
// }
@Override
public void updateUI() {
    removeMouseListener(handler);
    removeMouseMotionListener(handler);
    super.updateUI();
    eventListenerList = new EventListenerList();
    handler = new CloseableTabIconHandler();
    addMouseListener(handler);
    addMouseMotionListener(handler);
    if (getUI() instanceof WindowsTabbedPaneUI) {
        setUI(new CloseableWindowsTabbedPaneUI());
    } else {
        setUI(new CloseableTabbedPaneUI());
    }
}
Also used : EventListenerList(javax.swing.event.EventListenerList) WindowsTabbedPaneUI(com.sun.java.swing.plaf.windows.WindowsTabbedPaneUI)

Aggregations

WindowsTabbedPaneUI (com.sun.java.swing.plaf.windows.WindowsTabbedPaneUI)1 EventListenerList (javax.swing.event.EventListenerList)1