HelloInJapanese.java Source code

Java tutorial

Introduction

Here is the source code for HelloInJapanese.java

Source

/*
Java Internationalization
By Andy Deitsch, David Czarnecki
    
ISBN: 0-596-00019-7
O'Reilly
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class HelloInJapanese extends JPanel {

    static JFrame frame;

    static String helloInJapanese = "Hello in Japanese is konnichi wa, \u4eca\u65e5\u306f.";

    public HelloInJapanese(String characters) {
        Font theFont = new Font("Bitstream Cyberbit", Font.PLAIN, 20);
        JTextArea area = new JTextArea(characters, 2, 30);
        area.setFont(theFont);
        area.setLineWrap(true);
        JScrollPane scrollpane = new JScrollPane(area);
        add(scrollpane);
    }

    public static void main(String argv[]) {

        HelloInJapanese japanesePanel = new HelloInJapanese(helloInJapanese);

        frame = new JFrame("Hello in Japanese");
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        frame.getContentPane().add("Center", japanesePanel);
        frame.pack();
        frame.setVisible(true);
    }
}