|
| 1 | +/* |
| 2 | + * Copyright (c) 2001, 2024, 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 javax.swing.JButton; |
| 25 | +import javax.swing.JFrame; |
| 26 | + |
| 27 | +/* |
| 28 | + * @test |
| 29 | + * @bug 4644444 8076246 |
| 30 | + * @summary JToolTip is shown improperly when placed very close to screen boundaries |
| 31 | + * @library /java/awt/regtesthelpers |
| 32 | + * @build PassFailJFrame |
| 33 | + * @run main/manual bug4644444 |
| 34 | + */ |
| 35 | + |
| 36 | +public class bug4644444 { |
| 37 | + |
| 38 | + private static final String INSTRUCTIONS = """ |
| 39 | + 1. Move the mouse on the button, so that the tooltip is visible. |
| 40 | + 2. Tooltip should get adjusted itself to show its full length of text. |
| 41 | + 3. Similarly, move the frame to different locations of the screen |
| 42 | + & see if tooltip works properly everywhere. |
| 43 | + 4. Press 'Pass' if tooltip text is fully visible else press 'Fail'. """; |
| 44 | + |
| 45 | + public static void main(String[] args) throws Exception { |
| 46 | + PassFailJFrame.builder() |
| 47 | + .title("JToolTip Instructions") |
| 48 | + .instructions(INSTRUCTIONS) |
| 49 | + .testUI(bug4644444::createUI) |
| 50 | + .build() |
| 51 | + .awaitAndCheck(); |
| 52 | + } |
| 53 | + |
| 54 | + private static JFrame createUI() { |
| 55 | + JFrame frame = new JFrame("bug4644444"); |
| 56 | + JButton button = new JButton("Button"); |
| 57 | + button.setToolTipText("Something really long 1234567890 1234567890 " + |
| 58 | + "1234567890 1234567890 1234567890 1234567890 1234567890 1234567890"); |
| 59 | + frame.getContentPane().add(button); |
| 60 | + frame.setSize(200, 80); |
| 61 | + return frame; |
| 62 | + } |
| 63 | +} |
0 commit comments