8316627: JViewport Test headless failure
Reviewed-by: dcubed, prr
This commit is contained in:
parent
5cacf212f0
commit
c04c9ea361
@ -28,46 +28,23 @@
|
||||
* @run main bug4546474
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Robot;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollBar;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class bug4546474 {
|
||||
static JScrollPane scrollpane;
|
||||
static JScrollBar sbar;
|
||||
static volatile boolean viewChanged;
|
||||
public static void main(String[] args) {
|
||||
JPanel panel = new JPanel();
|
||||
JScrollPane scrollpane = new JScrollPane(panel,
|
||||
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
JScrollBar sbar = scrollpane.getVerticalScrollBar();
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setPreferredSize(new Dimension(500, 500));
|
||||
scrollpane = new JScrollPane(panel,
|
||||
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
||||
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
sbar = scrollpane.getVerticalScrollBar();
|
||||
});
|
||||
scrollpane.setViewportView(null);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.delay(500);
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
sbar.addAdjustmentListener(e -> viewChanged = true);
|
||||
scrollpane.setViewportView(null);
|
||||
});
|
||||
robot.delay(500);
|
||||
if (!viewChanged) {
|
||||
viewChanged = true;
|
||||
if (sbar.getVisibleAmount() > 0) {
|
||||
throw new RuntimeException("Vertical scrollbar is not " +
|
||||
"updated when viewport is replaced");
|
||||
}
|
||||
robot.delay(500);
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (sbar.getVisibleAmount() > 0) {
|
||||
throw new RuntimeException("Vertical scrollbar is not " +
|
||||
"updated when viewport is replaced");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user