6664309: Docking point of a floating toolbar changes after closing
Reviewed-by: tr, prr
This commit is contained in:
parent
a96e92c83d
commit
a420ff48da
@ -1431,15 +1431,6 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
|
|||||||
if (floatingToolBar instanceof Window) ((Window)floatingToolBar).setVisible(false);
|
if (floatingToolBar instanceof Window) ((Window)floatingToolBar).setVisible(false);
|
||||||
floatingToolBar.getContentPane().remove(toolBar);
|
floatingToolBar.getContentPane().remove(toolBar);
|
||||||
String constraint = constraintBeforeFloating;
|
String constraint = constraintBeforeFloating;
|
||||||
if (toolBar.getOrientation() == JToolBar.HORIZONTAL) {
|
|
||||||
if (constraint == "West" || constraint == "East") {
|
|
||||||
constraint = "North";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (constraint == "North" || constraint == "South") {
|
|
||||||
constraint = "West";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dockingSource == null)
|
if (dockingSource == null)
|
||||||
dockingSource = toolBar.getParent();
|
dockingSource = toolBar.getParent();
|
||||||
if (propertyListener != null)
|
if (propertyListener != null)
|
||||||
|
100
test/jdk/javax/swing/JToolBar/TestToolBarConstraint.java
Normal file
100
test/jdk/javax/swing/JToolBar/TestToolBarConstraint.java
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* @test
|
||||||
|
* @bug 6664309
|
||||||
|
* @key headful
|
||||||
|
* @library /java/awt/regtesthelpers
|
||||||
|
* @build PassFailJFrame
|
||||||
|
* @summary Verifies docking point of a floating toolbar changes after closing
|
||||||
|
* @run main/manual TestToolBarConstraint
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JToolBar;
|
||||||
|
import javax.swing.GroupLayout;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
|
public class TestToolBarConstraint {
|
||||||
|
static String instructions = "INSTRUCTIONS: \n" +
|
||||||
|
"\tA toolbar is docked at EAST side.\n" +
|
||||||
|
" \tPlease drag the toolbar in any direction\n" +
|
||||||
|
" \tthen release the mouse to make it floating \n" +
|
||||||
|
" \tand close the floating toolbar.\n" +
|
||||||
|
" \tIf it retains the docking position at EAST, press Pass\n" +
|
||||||
|
" \telse if it gets docked at NORTH press Fail.";
|
||||||
|
|
||||||
|
static PassFailJFrame passFailJFrame;
|
||||||
|
static JFrame frame;
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
SwingUtilities.invokeAndWait(() -> {
|
||||||
|
try {
|
||||||
|
createUI();
|
||||||
|
passFailJFrame = new PassFailJFrame(instructions);
|
||||||
|
PassFailJFrame.addTestWindow(frame);
|
||||||
|
PassFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
passFailJFrame.awaitAndCheck();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createUI() {
|
||||||
|
frame = new JFrame();
|
||||||
|
JToolBar jToolBar1 = new JToolBar();
|
||||||
|
JButton jButton1 = new JButton();
|
||||||
|
JPanel jPanel1 = new JPanel();
|
||||||
|
|
||||||
|
jToolBar1.setRollover(true);
|
||||||
|
|
||||||
|
jButton1.setText("jButton1");
|
||||||
|
jButton1.setFocusable(false);
|
||||||
|
|
||||||
|
jButton1.setHorizontalTextPosition(SwingConstants.CENTER);
|
||||||
|
jButton1.setVerticalTextPosition(SwingConstants.BOTTOM);
|
||||||
|
jToolBar1.add(jButton1);
|
||||||
|
|
||||||
|
frame.getContentPane().add(jToolBar1, BorderLayout.EAST);
|
||||||
|
|
||||||
|
GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||||
|
jPanel1.setLayout(jPanel1Layout);
|
||||||
|
jPanel1Layout.setHorizontalGroup(
|
||||||
|
jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGap(0, 340, Short.MAX_VALUE));
|
||||||
|
jPanel1Layout.setVerticalGroup(
|
||||||
|
jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
|
.addGap(0, 300, Short.MAX_VALUE));
|
||||||
|
|
||||||
|
frame.getContentPane().add(jPanel1, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
frame.pack();
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user