FileDocCategorySizeDatePackage
IMFDemo.javaAPI DocExample4163Wed Apr 19 11:19:36 BST 2000None

IMFDemo

public class IMFDemo extends Applet implements ActionListener

Fields Summary
Constructors Summary
Methods Summary
public voidactionPerformed(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 voidaddComponents()

        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 voidaddMenuItem(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 voidinit()

        addComponents();
    
public static voidmain(java.lang.String[] argv)

        final IMFDemo applet = new IMFDemo();
        applet.init();
        applet.start();
        makeFrame(applet, "Input Method Framework Demo");
    
public static voidmakeFrame(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 voidmakeMenuBar(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 voidstart()

    
public voidstop()