< prev index next >
test/java/awt/ComponentOrientation/WindowTest.java
Print this page
*** 25,79 ****
* @test
* @key headful
* @bug 4108453 4778440 6304785
* @summary Test Window.applyResourceBundle orientation support
*
- * @build TestBundle TestBundle_es TestBundle_iw
- * @build TestBundle1 TestBundle1_ar
* @run main WindowTest
*/
import java.awt.*;
- import java.applet.*;
- import java.util.Locale;
- import java.util.ResourceBundle;
-
- public class WindowTest extends Applet {
- static Exception failure=null;
- static Thread mainThread=null;
! public static void main(String args[]) throws Exception {
! mainThread = Thread.currentThread();
! WindowTest app = new WindowTest();
! app.start();
! try {
! Thread.sleep(300000);
! } catch (InterruptedException e) {
! if (failure != null) {
! throw failure;
! }
! }
! }
! public void start() {
try {
! doTest();
! } catch (Exception e) {
! failure = e;
}
- mainThread.interrupt();
}
! public void doTest() {
System.out.println("WindowTest {");
- ResourceBundle rb;
- Frame myFrame;
-
// Create a window containing a hierarchy of components.
System.out.println(" Creating component hierarchy...");
- myFrame = new Frame();
myFrame.setLayout(new FlowLayout());
Panel panel1 = new Panel();
panel1.setLayout(new BorderLayout());
panel1.add("North", new Button("North"));
panel1.add("South", new Button("South"));
--- 25,59 ----
* @test
* @key headful
* @bug 4108453 4778440 6304785
* @summary Test Window.applyResourceBundle orientation support
*
* @run main WindowTest
*/
import java.awt.*;
! public class WindowTest {
!
! public static void main(String args[]) throws Exception {
! Frame frame = new Frame();
! frame.setSize(200,200);
! frame.setVisible(true);
try {
! doTest(frame);
! } finally {
! frame.setVisible(false);
! frame.dispose();
}
}
! public static void doTest (Frame myFrame) throws Exception{
System.out.println("WindowTest {");
// Create a window containing a hierarchy of components.
System.out.println(" Creating component hierarchy...");
myFrame.setLayout(new FlowLayout());
Panel panel1 = new Panel();
panel1.setLayout(new BorderLayout());
panel1.add("North", new Button("North"));
panel1.add("South", new Button("South"));
*** 94,125 ****
// After construction, all of the components' orientations should be
// set to ComponentOrientation.UNKNOWN.
System.out.println(" Verifying orientation is UNKNOWN...");
verifyOrientation(myFrame, ComponentOrientation.UNKNOWN);
! // This will load TestBundle1 using the default locale and apply
! // it to the component hierarchy. Since the bundle has no Orientation
! // specified, this should fall back to the bundle-locale's orientation
! System.out.println(" Applying TestBundle1 by name and verifying...");
! myFrame.applyResourceBundle("TestBundle1");
! verifyOrientation(myFrame,
! ComponentOrientation.getOrientation(
! ResourceBundle.getBundle("TestBundle1", Locale.getDefault())));
!
! System.out.println(" Applying TestBundle_iw and verifying...");
! rb = ResourceBundle.getBundle("TestBundle", new Locale("iw", ""));
! myFrame.applyResourceBundle(rb);
verifyOrientation(myFrame, ComponentOrientation.RIGHT_TO_LEFT);
! System.out.println(" Applying TestBundle_es and verifying...");
! rb = ResourceBundle.getBundle("TestBundle", new Locale("es", ""));
! myFrame.applyResourceBundle(rb);
verifyOrientation(myFrame, ComponentOrientation.LEFT_TO_RIGHT);
-
- myFrame.setVisible(false);
- myFrame.dispose();
System.out.println("}");
}
static void verifyOrientation(Component c, ComponentOrientation orient) {
--- 74,91 ----
// After construction, all of the components' orientations should be
// set to ComponentOrientation.UNKNOWN.
System.out.println(" Verifying orientation is UNKNOWN...");
verifyOrientation(myFrame, ComponentOrientation.UNKNOWN);
! System.out.println(" Applying RIGHT_TO_LEFT orientation and verifying...");
! myFrame.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);;
verifyOrientation(myFrame, ComponentOrientation.RIGHT_TO_LEFT);
! System.out.println(" Applying LEFT_TO_RIGHT orientation and verifying...");
! myFrame.applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
verifyOrientation(myFrame, ComponentOrientation.LEFT_TO_RIGHT);
System.out.println("}");
}
static void verifyOrientation(Component c, ComponentOrientation orient) {
< prev index next >