This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 268681
Collapse All | Expand All

(-)a/core.windows/src/org/netbeans/core/windows/view/ui/CloseButtonTabbedPane.java (-4 / +19 lines)
Lines 84-95 Link Here
84
    CloseButtonTabbedPane() {
84
    CloseButtonTabbedPane() {
85
            // close tab via middle button
85
            // close tab via middle button
86
            addMouseListener(new MouseAdapter() {
86
            addMouseListener(new MouseAdapter() {
87
                int lastIdx = -1;
87
                // Tab index at the time of the previous two mouse presses.
88
                private int lastTwoIdx[] = new int[] {-1, -1};
89
                // Tab index of an ongoing middle mouse button press.
90
                private int ongoingMiddleIdx = -1;
88
91
89
                @Override
92
                @Override
90
                public void mousePressed(MouseEvent e) {
93
                public void mousePressed(MouseEvent e) {
94
                    int idx =
95
                        getUI().tabForCoordinate(CloseButtonTabbedPane.this, e.getX(), e.getY());
96
                    lastTwoIdx = new int[] { idx, lastTwoIdx[0] };
91
                    if (SwingUtilities.isMiddleMouseButton(e)) {
97
                    if (SwingUtilities.isMiddleMouseButton(e)) {
92
                        lastIdx = getUI().tabForCoordinate(CloseButtonTabbedPane.this, e.getX(), e.getY());
98
                        ongoingMiddleIdx = idx;
93
                    }
99
                    }
94
                }
100
                }
95
101
Lines 99-115 Link Here
99
                        int idx = getUI().tabForCoordinate(CloseButtonTabbedPane.this, e.getX(), e.getY());
105
                        int idx = getUI().tabForCoordinate(CloseButtonTabbedPane.this, e.getX(), e.getY());
100
                        if (idx >= 0) {
106
                        if (idx >= 0) {
101
                            Component comp = getComponentAt(idx);
107
                            Component comp = getComponentAt(idx);
102
                            if (idx == lastIdx && comp != null && !hideCloseButton(comp)) {
108
                            if (idx == ongoingMiddleIdx && comp != null && !hideCloseButton(comp)) {
103
                                fireCloseRequest(comp);
109
                                fireCloseRequest(comp);
104
                            }
110
                            }
105
                        }
111
                        }
106
                        lastIdx = -1;
112
                        ongoingMiddleIdx = -1;
107
                    }
113
                    }
108
                }
114
                }
109
115
110
            @Override
116
            @Override
111
            public void mouseClicked( MouseEvent e ) {
117
            public void mouseClicked( MouseEvent e ) {
112
                if( e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton( e ) ) {
118
                if( e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton( e ) ) {
119
                    /* Fix for bug #268681. Avoid maximizing if the user is simply clicking the
120
                    "left" or "right" tab-switching buttons quickly. By the time the double click
121
                    event is delivered, the initial press or click of the left or right buttons may
122
                    already have changed which tab button is currently under the mouse cursor, so
123
                    instead of trying to detect whether the button pressed is a left/right button,
124
                    perform the maximization action only if the same tab button was showing under
125
                    the mouse cursor for both of the button presses involved in the double click. */
126
                    if (!(lastTwoIdx[0] >= 0 && lastTwoIdx[0] == lastTwoIdx[1]))
127
                      return;
113
                    //toggle maximize
128
                    //toggle maximize
114
                    TopComponent tc = ( TopComponent ) SwingUtilities.getAncestorOfClass( TopComponent.class, CloseButtonTabbedPane.this );
129
                    TopComponent tc = ( TopComponent ) SwingUtilities.getAncestorOfClass( TopComponent.class, CloseButtonTabbedPane.this );
115
                    if( null != tc ) {
130
                    if( null != tc ) {

Return to bug 268681