Skip to content

Commit

Permalink
Backport a0b7c4f015c694425893b8d21d2aecae71a3b604
Browse files Browse the repository at this point in the history
  • Loading branch information
duke committed Feb 20, 2025
1 parent 1b49a33 commit e88b253
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/jdk/javax/swing/JScrollBar/4865918/bug4865918.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,21 @@

import java.awt.Dimension;
import java.awt.Robot;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JScrollBar;
import javax.swing.SwingUtilities;
import java.awt.event.MouseEvent;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import java.util.Date;

public class bug4865918 {

private static TestScrollBar sbar;
private static JFrame frame;
private static final CountDownLatch mousePressLatch = new CountDownLatch(1);

public static void main(String[] argv) throws Exception {
try {
Expand All @@ -52,6 +56,9 @@ public static void main(String[] argv) throws Exception {
robot.delay(1000);

SwingUtilities.invokeAndWait(() -> sbar.pressMouse());
if (!mousePressLatch.await(2, TimeUnit.SECONDS)) {
throw new RuntimeException("Timed out waiting for mouse press");
}

robot.waitForIdle();
robot.delay(200);
Expand Down Expand Up @@ -81,6 +88,11 @@ private static void createAndShowGUI() {
sbar = new TestScrollBar(JScrollBar.HORIZONTAL, -1, 10, -100, 100);
sbar.setPreferredSize(new Dimension(200, 20));
sbar.setBlockIncrement(10);
sbar.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
mousePressLatch.countDown();
}
});

frame.getContentPane().add(sbar);
frame.pack();
Expand Down

0 comments on commit e88b253

Please sign in to comment.