IMFDemopublic class IMFDemo extends Applet implements ActionListener
Methods Summary |
---|
public void | actionPerformed(java.awt.event.ActionEvent event)
String command = event.getActionCommand();
if (Character.isDigit(command.charAt(0))) {
int size = Integer.parseInt(command);
for (int i = 0; i < 3; i++) {
LWTextComponent component = (LWTextComponent) getComponent(i);
component.setFontSize(size);
component.invalidateTextLayout();
component.repaint();
}
PeeredTextArea textArea = (PeeredTextArea) getComponent(3);
textArea.setFontSize(size);
textArea.repaint();
} else {
String language, country;
if (command.length() == 2) {
language = command;
country = "";
} else {
language = command.substring(0, 2);
country = command.substring(3);
}
if (!getInputContext().selectInputMethod(new Locale(language, country))) {
Toolkit.getDefaultToolkit().beep();
}
}
| public void | addComponents()
setLayout(new GridLayout(4, 1, 10, 10));
add(new ActiveClient("Lightweight component, active client"));
add(new LWTextComponent("Lightweight component, passive client", true));
add(new LWTextComponent("Lightweight component, non-client", false));
add(new PeeredTextArea());
| private static void | addMenuItem(java.awt.Menu menu, java.lang.String label, java.awt.event.ActionListener listener, java.lang.String command)
MenuItem item = new MenuItem(label);
menu.add(item);
item.setActionCommand(command);
item.addActionListener(listener);
| public void | init()
addComponents();
| public static void | main(java.lang.String[] argv)
final IMFDemo applet = new IMFDemo();
applet.init();
applet.start();
makeFrame(applet, "Input Method Framework Demo");
| public static void | makeFrame(IMFDemo applet, java.lang.String title)
Frame frame = new Frame(title);
frame.pack(); // adds peer
makeMenuBar(frame, applet);
frame.add("Center", applet);
frame.setSize(400, 400);
WindowListener listener = new AppletWindowListener(applet);
frame.addWindowListener(listener);
frame.pack();
frame.show();
| private static void | makeMenuBar(java.awt.Frame frame, java.awt.event.ActionListener listener)
MenuBar menuBar = new MenuBar();
frame.setMenuBar(menuBar);
Menu menu;
menu = new Menu("Locale");
menuBar.add(menu);
addMenuItem(menu, "English", listener, "en");
addMenuItem(menu, "French", listener, "fr");
addMenuItem(menu, "German", listener, "de");
addMenuItem(menu, "Japanese", listener, "ja");
addMenuItem(menu, "Simplified Chinese", listener, "zh_CN");
addMenuItem(menu, "Traditional Chinese", listener, "zh_TW");
menu = new Menu("Size");
menuBar.add(menu);
addMenuItem(menu, "12", listener, "12");
addMenuItem(menu, "24", listener, "24");
addMenuItem(menu, "36", listener, "36");
| public void | start()
| public void | stop()
|
|