< prev index next >

src/com/sun/javatest/tool/UIFactory.java

Print this page




1241      * component that allows freeform editing of the user's response.
1242      * @param uiKey the base name of the resources to be used for the menu
1243      * @param editable True if the user should be allowed to edit the
1244      * response.
1245      * @return the choice component that was created
1246      * @see #createChoice(String)
1247      */
1248     public JComboBox createChoice(String uiKey, boolean editable) {
1249         return createChoice(uiKey, editable, (JLabel) null);
1250     }
1251 
1252     /**
1253      * Same as the one parameter version, except a label can be
1254      * associated with this component.  This is to support accessibility.
1255      * @param uiKey the base name of the resources to be used for the menu
1256      * @param label Label to associate with this component
1257      * @return the choice component that was created
1258      * @see #createChoice(String)
1259      * @see javax.swing.JLabel#setLabelFor
1260      */
1261     public JComboBox createChoice(String uiKey, JLabel label) {
1262         return createChoice(uiKey, false, label);
1263     }
1264 
1265     /**
1266      * Combination of the two parameter methods, allowing you to select
1267      * a mutable response and associate a label.
1268      * @param uiKey the base name of the resources to be used for the menu
1269      * @param editable True if the user should be allowed to edit the
1270      * response.
1271      * @param label Label to associate with this component
1272      * @return a choice box with the attributes indicated by the parameters
1273      * @see #createChoice(String,JLabel)
1274      * @see #createChoice(String,boolean)
1275      * @see #createChoice(String)
1276      * @see javax.swing.JLabel#setLabelFor
1277      */
1278     public JComboBox createChoice(String uiKey, boolean editable, JLabel label) {
1279         JComboBox choice = new JComboBox();
1280         choice.setName(uiKey);
1281         setToolTip(choice, uiKey);
1282 
1283         if (label != null)
1284             label.setLabelFor(choice);
1285         else
1286             setAccessibleName(choice, uiKey);
1287 
1288         choice.setEditable(editable);
1289         if (editable) {
1290             Component editComp = choice.getEditor().getEditorComponent();
1291             if (editComp instanceof Accessible) {
1292                 if (editComp.getName() == null)
1293                     editComp.setName(uiKey + ".ed");
1294                 AccessibleContext ac = choice.getAccessibleContext();
1295                 AccessibleContext ed_ac = editComp.getAccessibleContext();
1296                 ed_ac.setAccessibleName(ac.getAccessibleName());
1297                 ed_ac.setAccessibleDescription(ac.getAccessibleDescription());
1298             }


1302     }
1303 
1304     /**
1305      * Create an choice item containing literal choices,
1306      * and using a resource to specify the tool tip.
1307      * The choices appear as given: for example, this method might be used to
1308      * create a choice item containing a set of filenames from which to choose. <br>
1309      * Note that if the choices are strings, they should probably be localized, and
1310      * if they are otherwise should probably be shown to the user using a renderer
1311      * which produces localized output.
1312      * The resource used is:
1313      * <table>
1314      * <tr><td><i>uiKey</i>.tip  <td>the tool tip for the choice item
1315      * </table>
1316      * In addition, the name of the choice is set to <i>uiKey</i>.
1317      * @param uiKey the base name of the resources to be used for the menu
1318      * @param choices the choices to appear in the choice item
1319      * @return the choice item that was created
1320      * @see #createChoice
1321      */
1322     public JComboBox createLiteralChoice(String uiKey, Object[] choices) {
1323         JComboBox choice = new JComboBox(choices);
1324         choice.setName(uiKey);
1325         setToolTip(choice, uiKey);
1326         return choice;
1327     }
1328 
1329     //----------------------------------------------------------------------------
1330     //
1331     // icons, images etc
1332 
1333     /**
1334      * Create an icon, using a resource to specify the image. <br>
1335      * The resource used is:
1336      * <table>
1337      * <tr><td><i>uiKey</i>.icon  <td>the name of a resource containing the image
1338      * </table>
1339      * @param uiKey the base name of the resource to be used
1340      * @return the icon that was created
1341      * @throws  MissingResourceException if the image resource cannot be found
1342      * @see #createIconButton
1343      */


1441     /**
1442      * Create an input text field, using a resource to specify the tool tip.  <br>
1443      * The resource used is:
1444      * <table>
1445      * <tr><td><i>uiKey</i>.tip  <td>the tool tip for the field
1446      * </table>
1447 
1448 
1449     /**
1450      * Create an empty list component. <br>
1451      * Note: list components do not currently support tool tips.
1452      * When they do, this method will use a resource to specify the tool tip.
1453      * The resources used are:
1454      * <table>
1455      * <tr><td><i>uiKey</i>.name  <td>the accessible name of the list
1456      * <tr><td><i>uiKey</i>.desc  <td>the accessible description of the list
1457      * </table>
1458      * @param uiKey the base name of the resource to be used (currently ignored)
1459      * @return the list that was created
1460      */
1461     public JList createList(String uiKey) {
1462         JList list = new JList();
1463         list.setName(uiKey);
1464         setAccessibleInfo(list, uiKey);
1465         return list;
1466     }
1467 
1468     /**
1469      * Create a list component with a given data model. <br>
1470      * Note: list components do not currently support tool tips.
1471      * When they do, this method will use a resource to specify the tool tip.
1472      * The resources used are:
1473      * <table>
1474      * <tr><td><i>uiKey</i>.name  <td>the accessible name of the list
1475      * <tr><td><i>uiKey</i>.desc  <td>the accessible description of the list
1476      * </table>
1477      * @param uiKey the base name of the resource to be used (currently ignored)
1478      * @param model the data model for this list
1479      * @return the list that was created
1480      */
1481     public JList createList(String uiKey, ListModel model) {
1482         JList list = new JList(model);
1483         list.setName(uiKey);
1484         setAccessibleInfo(list, uiKey);
1485         return list;
1486     }
1487 
1488     //----------------------------------------------------------------------------
1489     //
1490     // menus
1491 
1492     /**
1493      * Create an empty menu bar, using resources to specify the accessible info.<br>
1494      * The resources used are:
1495      * <table>
1496      * <tr><td><i>uiKey</i>.name <td>the accessible name text
1497      * <tr><td><i>uiKey</i>.desc <td>accessible description text
1498      * </table>
1499      * @param uiKey the base name of the resource to be used
1500      * @return the menu bar that was created
1501      */
1502     public JMenuBar createMenuBar(String uiKey) {




1241      * component that allows freeform editing of the user's response.
1242      * @param uiKey the base name of the resources to be used for the menu
1243      * @param editable True if the user should be allowed to edit the
1244      * response.
1245      * @return the choice component that was created
1246      * @see #createChoice(String)
1247      */
1248     public JComboBox createChoice(String uiKey, boolean editable) {
1249         return createChoice(uiKey, editable, (JLabel) null);
1250     }
1251 
1252     /**
1253      * Same as the one parameter version, except a label can be
1254      * associated with this component.  This is to support accessibility.
1255      * @param uiKey the base name of the resources to be used for the menu
1256      * @param label Label to associate with this component
1257      * @return the choice component that was created
1258      * @see #createChoice(String)
1259      * @see javax.swing.JLabel#setLabelFor
1260      */
1261     public <E> JComboBox<E> createChoice(String uiKey, JLabel label) {
1262         return createChoice(uiKey, false, label);
1263     }
1264 
1265     /**
1266      * Combination of the two parameter methods, allowing you to select
1267      * a mutable response and associate a label.
1268      * @param uiKey the base name of the resources to be used for the menu
1269      * @param editable True if the user should be allowed to edit the
1270      * response.
1271      * @param label Label to associate with this component
1272      * @return a choice box with the attributes indicated by the parameters
1273      * @see #createChoice(String,JLabel)
1274      * @see #createChoice(String,boolean)
1275      * @see #createChoice(String)
1276      * @see javax.swing.JLabel#setLabelFor
1277      */
1278     public <E> JComboBox<E> createChoice(String uiKey, boolean editable, JLabel label) {
1279         JComboBox choice = new JComboBox();
1280         choice.setName(uiKey);
1281         setToolTip(choice, uiKey);
1282 
1283         if (label != null)
1284             label.setLabelFor(choice);
1285         else
1286             setAccessibleName(choice, uiKey);
1287 
1288         choice.setEditable(editable);
1289         if (editable) {
1290             Component editComp = choice.getEditor().getEditorComponent();
1291             if (editComp instanceof Accessible) {
1292                 if (editComp.getName() == null)
1293                     editComp.setName(uiKey + ".ed");
1294                 AccessibleContext ac = choice.getAccessibleContext();
1295                 AccessibleContext ed_ac = editComp.getAccessibleContext();
1296                 ed_ac.setAccessibleName(ac.getAccessibleName());
1297                 ed_ac.setAccessibleDescription(ac.getAccessibleDescription());
1298             }


1302     }
1303 
1304     /**
1305      * Create an choice item containing literal choices,
1306      * and using a resource to specify the tool tip.
1307      * The choices appear as given: for example, this method might be used to
1308      * create a choice item containing a set of filenames from which to choose. <br>
1309      * Note that if the choices are strings, they should probably be localized, and
1310      * if they are otherwise should probably be shown to the user using a renderer
1311      * which produces localized output.
1312      * The resource used is:
1313      * <table>
1314      * <tr><td><i>uiKey</i>.tip  <td>the tool tip for the choice item
1315      * </table>
1316      * In addition, the name of the choice is set to <i>uiKey</i>.
1317      * @param uiKey the base name of the resources to be used for the menu
1318      * @param choices the choices to appear in the choice item
1319      * @return the choice item that was created
1320      * @see #createChoice
1321      */
1322     public <E> JComboBox<E> createLiteralChoice(String uiKey, E[] choices) {
1323         JComboBox<E> choice = new JComboBox<>(choices);
1324         choice.setName(uiKey);
1325         setToolTip(choice, uiKey);
1326         return choice;
1327     }
1328 
1329     //----------------------------------------------------------------------------
1330     //
1331     // icons, images etc
1332 
1333     /**
1334      * Create an icon, using a resource to specify the image. <br>
1335      * The resource used is:
1336      * <table>
1337      * <tr><td><i>uiKey</i>.icon  <td>the name of a resource containing the image
1338      * </table>
1339      * @param uiKey the base name of the resource to be used
1340      * @return the icon that was created
1341      * @throws  MissingResourceException if the image resource cannot be found
1342      * @see #createIconButton
1343      */


1441     /**
1442      * Create an input text field, using a resource to specify the tool tip.  <br>
1443      * The resource used is:
1444      * <table>
1445      * <tr><td><i>uiKey</i>.tip  <td>the tool tip for the field
1446      * </table>
1447 
1448 
1449     /**
1450      * Create an empty list component. <br>
1451      * Note: list components do not currently support tool tips.
1452      * When they do, this method will use a resource to specify the tool tip.
1453      * The resources used are:
1454      * <table>
1455      * <tr><td><i>uiKey</i>.name  <td>the accessible name of the list
1456      * <tr><td><i>uiKey</i>.desc  <td>the accessible description of the list
1457      * </table>
1458      * @param uiKey the base name of the resource to be used (currently ignored)
1459      * @return the list that was created
1460      */
1461     public <E> JList<E> createList(String uiKey) {
1462         JList<E> list = new JList<>();
1463         list.setName(uiKey);
1464         setAccessibleInfo(list, uiKey);
1465         return list;
1466     }
1467 
1468     /**
1469      * Create a list component with a given data model. <br>
1470      * Note: list components do not currently support tool tips.
1471      * When they do, this method will use a resource to specify the tool tip.
1472      * The resources used are:
1473      * <table>
1474      * <tr><td><i>uiKey</i>.name  <td>the accessible name of the list
1475      * <tr><td><i>uiKey</i>.desc  <td>the accessible description of the list
1476      * </table>
1477      * @param uiKey the base name of the resource to be used (currently ignored)
1478      * @param model the data model for this list
1479      * @return the list that was created
1480      */
1481     public <E> JList<E> createList(String uiKey, ListModel<E> model) {
1482         JList<E> list = new JList<>(model);
1483         list.setName(uiKey);
1484         setAccessibleInfo(list, uiKey);
1485         return list;
1486     }
1487 
1488     //----------------------------------------------------------------------------
1489     //
1490     // menus
1491 
1492     /**
1493      * Create an empty menu bar, using resources to specify the accessible info.<br>
1494      * The resources used are:
1495      * <table>
1496      * <tr><td><i>uiKey</i>.name <td>the accessible name text
1497      * <tr><td><i>uiKey</i>.desc <td>accessible description text
1498      * </table>
1499      * @param uiKey the base name of the resource to be used
1500      * @return the menu bar that was created
1501      */
1502     public JMenuBar createMenuBar(String uiKey) {


< prev index next >