|
| 1 | +/* |
| 2 | + * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | + * accompanied this code). |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License version |
| 16 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + */ |
| 23 | + |
| 24 | +import java.awt.BorderLayout; |
| 25 | + |
| 26 | +import javax.swing.JComponent; |
| 27 | +import javax.swing.JFrame; |
| 28 | +import javax.swing.JLabel; |
| 29 | +import javax.swing.JToolBar; |
| 30 | +import javax.swing.SwingUtilities; |
| 31 | + |
| 32 | +/* |
| 33 | + * @test |
| 34 | + * @bug 4203039 |
| 35 | + * @summary JToolBar needs a way to limit docking to a particular orientation |
| 36 | + * @library /java/awt/regtesthelpers |
| 37 | + * @build PassFailJFrame |
| 38 | + * @run main/manual bug4203039 |
| 39 | + */ |
| 40 | + |
| 41 | +public class bug4203039 { |
| 42 | + private static final String instructionsText = """ |
| 43 | + This test is used to verify that application-installed |
| 44 | + components prevent the toolbar from docking in |
| 45 | + those locations. |
| 46 | +
|
| 47 | + This test has installed components on the SOUTH |
| 48 | + and EAST, so verify the toolbar cannot dock in those |
| 49 | + locations but can dock on the NORTH and WEST"""; |
| 50 | + |
| 51 | + public static void main(String[] args) throws Exception { |
| 52 | + PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() |
| 53 | + .title("bug4203039 Instructions") |
| 54 | + .instructions(instructionsText) |
| 55 | + .testTimeOut(5) |
| 56 | + .rows(10) |
| 57 | + .columns(35) |
| 58 | + .build(); |
| 59 | + |
| 60 | + SwingUtilities.invokeAndWait(() -> { |
| 61 | + JFrame frame = new JFrame("bug4203039"); |
| 62 | + frame.setSize(300, 200); |
| 63 | + |
| 64 | + JToolBar toolbar = new JToolBar(); |
| 65 | + JLabel label = new JLabel("This is the toolbar"); |
| 66 | + toolbar.add(label); |
| 67 | + |
| 68 | + frame.add(toolbar, BorderLayout.NORTH); |
| 69 | + |
| 70 | + frame.add(new JComponent(){}, BorderLayout.SOUTH); |
| 71 | + frame.add(new JComponent(){}, BorderLayout.EAST); |
| 72 | + |
| 73 | + PassFailJFrame.addTestWindow(frame); |
| 74 | + PassFailJFrame.positionTestWindow(frame, |
| 75 | + PassFailJFrame.Position.HORIZONTAL); |
| 76 | + |
| 77 | + frame.setVisible(true); |
| 78 | + }); |
| 79 | + |
| 80 | + passFailJFrame.awaitAndCheck(); |
| 81 | + } |
| 82 | +} |
0 commit comments