Upload
rachel-evans
View
225
Download
0
Embed Size (px)
DESCRIPTION
Advanced Controls and Internationalization / Session3 / 3 of 27 Module 4 Review
Citation preview
Session 3Module 5: Swing Advanced ControlsModule 6: Internationalization
Advanced Controls and Internationalization / Session3 / 2 of 27
Module 3 Review
Advanced Controls and Internationalization / Session3 / 3 of 27
Module 4 Review
Advanced Controls and Internationalization / Session3 / 4 of 27
Module 5: Swing Advanced Controls Objectives
Advanced Controls and Internationalization / Session3 / 5 of 27
javax.swing.JColorChooser class
Swatches: sample colorsHSB: Hue, Saturation, BrightnessRGB: Red Green Blue
Constructors:JColorChooser()JColorChooser(java.awt.Color initColor)
Methods:ColorSelectionModel getSelectionModel()Color getColor()void setColor (Color c)Color showDialog(Component container ,String title ,Color initColor)
Event handling:javax.swing.event.ChangeEventjavax.swing.event.ChangeListenerpublic void stateChanged(ChangeEvent e)
Advanced Controls and Internationalization / Session3 / 6 of 27
javax.swing.JList class• JList displays a groups of items in one or more columns.• JList does not support scrolling inherently.• Add JList to a JScrollPane to support scrolling functionality.
ConstructorsJList()JList ( Object[] dataItems)JList ( Vector vectorItems)
Common used Methods
Event handling:ListSelectionEventListSelectionListenerpublic void valueChanged(ListSelectionEvent e)
Advanced Controls and Internationalization / Session3 / 7 of 27
javax.swing.JComboBox class
Common used methods
Event handling:ActionEventActionListenerpublic void actionPerformed(ActionEvent e)
ItemEventItemListenerpublic void itemStateChanged(ItemEvent e)
Advanced Controls and Internationalization / Session3 / 8 of 27
javax.swingJTable class
Column Headers
data
Event handling:MouseEventMouseListener public void mouseClicked( MouseEvent e)
Common used methods
Advanced Controls and Internationalization / Session3 / 9 of 27
javax.swing.JTree class
Event Handlingjavax.swing.event.TreeSelectionEventjavax.swing.event.TreeSelectionListenerpublic void valueChanged(TreeSelectionEvent e)
javax.swing.event.TreeExpansionEventjavax.swing.event.TreeExpansionListenerpublic void treeExpanded(TreeExpansionEvent e)public void treeCollapsed(TreeExpansionEvent e)
javax.swing.event.TreeWillExpandEventjavax.swing.event.TreeWillExpandListenerpublic void treeWillExpand(TreeWillExpandEvent e)public void treeWillCollapse(TreeWillExpandEvent e)
Advanced Controls and Internationalization / Session3 / 10 of 27
Event HandlingChangeEventChangeListenerpublic void stateChanged(ChangeEvent e
javax.swing.JTabbedPane class
ConstructorsJTabbedPane()JTabbedPane( int direction)
Advanced Controls and Internationalization / Session3 / 11 of 27
javax.swing.JSplitPane classConstructors:JSplitPane() // side by side, no continuous layoutJSplitPane(int direction )JSplitPane(int direction , boolean continuous)JSplitPane(int direction, boolean continuous, Component comp1, Component comp2)
Advanced Controls and Internationalization / Session3 / 12 of 27
Module 5 Summary
Advanced Controls and Internationalization / Session3 / 13 of 27
Module 6: Internationalization
Advanced Controls and Internationalization / Session3 / 14 of 27
Need of Internationalization
X Internationalization
• Component Captions • Formatting numbers• Formatting date and time• Messages
Where should you use internationalization?
Advanced Controls and Internationalization / Session3 / 15 of 27
Unicode
Advanced Controls and Internationalization / Session3 / 16 of 27
Creating a Properties File
Examples
Advanced Controls and Internationalization / Session3 / 17 of 27
Defining Locale: Locale Class
Example:
Advanced Controls and Internationalization / Session3 / 18 of 27
ResourceBundle Class
public static ResourceBundle getBundle (String propertiesFileName, Locale obj)
Fetching the text from ResourceBundle
Advanced Controls and Internationalization / Session3 / 19 of 27
Classes for formatting
Advanced Controls and Internationalization / Session3 / 20 of 27
Class java.text.NumberFormat:Format numbers, currencies, percentages
• Abstract class• static NumberFormat getInstance() // default locale• static NumberFormat getInstance(Locale inLocale) • static NumberFormat getNumberInstance() • static NumberFormat getNumberInstance(Locale inLocale) • static NumberFormat getIntegerInstance() • static NumberFormat getIntegerInstance(Locale inLocale) • static NumberFormat getCurrencyInstance() • static NumberFormat getCurrencyInstance(Locale inLocale ) • static NumberFormat getPercentInstance() • static NumberFormat getPercentInstance(Locale inLocale) • String format(double number) • String format(long number)• get/set minimumFractionDigits• get/set maximunFractionDigits• get/set minimumIntegerDigits
Advanced Controls and Internationalization / Session3 / 21 of 27
public asbtract class java.text.DateFormat
Advanced Controls and Internationalization / Session3 / 22 of 27
Class public java.text.SimpleDateFormat
Advanced Controls and Internationalization / Session3 / 23 of 27
Class public java.text.SimpleDateFormat
Advanced Controls and Internationalization / Session3 / 24 of 27
Class java.text.MessageFormat
Advanced Controls and Internationalization / Session3 / 25 of 27
Procedure to use MessageFormat class
Advanced Controls and Internationalization / Session3 / 26 of 27
MessageFormat class
Advanced Controls and Internationalization / Session3 / 27 of 27
Module 6 Summary