< prev index next >
test/java/awt/GridLayout/LayoutExtraGaps/LayoutExtraGaps.java
Print this page
*** 25,43 ****
@test
@key headful
@bug 4370316
@summary GridLayout does not centre its component properly
(summary was GridLayout does not fill its Container)
- @library ../../regtesthelpers
- @build Util
@author Andrei Dmitriev : area=awt.layout
@run main LayoutExtraGaps
*/
! import java.awt.*;
! import java.awt.event.*;
! import test.java.awt.regtesthelpers.Util;
public class LayoutExtraGaps extends Frame {
final static int compCount = 30;
public LayoutExtraGaps() {
--- 25,47 ----
@test
@key headful
@bug 4370316
@summary GridLayout does not centre its component properly
(summary was GridLayout does not fill its Container)
@author Andrei Dmitriev : area=awt.layout
@run main LayoutExtraGaps
*/
!
! import java.awt.Frame;
! import java.awt.Panel;
! import java.awt.GridLayout;
! import java.awt.Color;
! import java.awt.Label;
! import java.awt.Component;
! import java.awt.ComponentOrientation;
! import java.awt.Rectangle;
public class LayoutExtraGaps extends Frame {
final static int compCount = 30;
public LayoutExtraGaps() {
*** 89,109 ****
add(blackPanel);
pack();
setSize((int)getPreferredSize().getWidth() + 50, (int)getPreferredSize().getHeight() + 50);
setVisible(true);
! Util.waitForIdle(Util.createRobot());
if (isComponentCentredLTR(yellowPanel) && isComponentCentredLTR(bluePanel)
&& isComponentCentredLTR(blackPanel) && isComponentCentredRTL(redPanel))
{
System.out.println("Test passed.");
} else {
throw new RuntimeException("Test failed. GridLayout doesn't center component.");
}
}
/**
* Checks if the components under Panel p are properly centred (i.e.
* opposite borders between the Panel and component are equal). Panel p
* must not be affect by RTL orientation (RTL only affects horizontal
* positioning and components lay out from top right corner).
--- 93,128 ----
add(blackPanel);
pack();
setSize((int)getPreferredSize().getWidth() + 50, (int)getPreferredSize().getHeight() + 50);
setVisible(true);
! blockTillDisplayed();
if (isComponentCentredLTR(yellowPanel) && isComponentCentredLTR(bluePanel)
&& isComponentCentredLTR(blackPanel) && isComponentCentredRTL(redPanel))
{
System.out.println("Test passed.");
} else {
throw new RuntimeException("Test failed. GridLayout doesn't center component.");
}
+
+ setVisible(false);
+ dispose();
}
+ void blockTillDisplayed() {
+ while (isVisible() == false) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ setVisible(false);
+ dispose();
+ throw new RuntimeException("Test failed.");
+ }
+ }
+ }
/**
* Checks if the components under Panel p are properly centred (i.e.
* opposite borders between the Panel and component are equal). Panel p
* must not be affect by RTL orientation (RTL only affects horizontal
* positioning and components lay out from top right corner).
< prev index next >