1 // Example for use of GNU gettext.
2 // Copyright (C) 2003 Free Software Foundation, Inc.
3 // This file is in the public domain.
5 // Source code of the Java/AWT program.
11 import java
.awt
.event
.*;
15 public static void main (String
[] args
) {
16 ResourceBundle catalog
= ResourceBundle
.getBundle("hello-java-awt");
17 Frame frame
= new Frame("Hello example");
18 frame
.addWindowListener(
20 public void windowClosing (WindowEvent event
) {
24 Label label1
= new Label(GettextResource
.gettext(catalog
,"Hello, world!"));
28 GettextResource
.gettext(catalog
,
29 "This program is running as process number {0}."),
30 new Object
[] { getPid() }));
31 Button button
= new Button("OK");
32 button
.addActionListener(
33 new ActionListener() {
34 public void actionPerformed (ActionEvent event
) {
38 Container labels
= new Container();
39 labels
.setLayout(new GridLayout(2, 1));
42 Container buttons
= new Container();
43 buttons
.setLayout(new FlowLayout(FlowLayout
.RIGHT
));
45 frame
.setLayout(new BorderLayout());
46 frame
.add(labels
, BorderLayout
.CENTER
);
47 frame
.add(buttons
, BorderLayout
.SOUTH
);
49 frame
.setVisible(true);
52 /* Return the process ID of the current process. */
53 private static String
getPid () {
55 String
[] args
= new String
[] { "/bin/sh", "-c", "echo $PPID" };
56 Process p
= Runtime
.getRuntime().exec(args
);
57 InputStream p_out
= p
.getInputStream();
58 String s
= (new BufferedReader(new InputStreamReader(p_out
))).readLine();
62 } catch (IOException e
) {