1 // Example for use of GNU gettext.
2 // This file is in the public domain.
4 // Source code of the Java/AWT program.
10 import java
.awt
.event
.*;
14 public static void main (String
[] args
) {
15 ResourceBundle catalog
= ResourceBundle
.getBundle("hello-java-awt");
16 Frame frame
= new Frame("Hello example");
17 frame
.addWindowListener(
19 public void windowClosing (WindowEvent event
) {
23 Label label1
= new Label(GettextResource
.gettext(catalog
,"Hello, world!"));
27 GettextResource
.gettext(catalog
,
28 "This program is running as process number {0}."),
29 new Object
[] { getPid() }));
30 Button button
= new Button("OK");
31 button
.addActionListener(
32 new ActionListener() {
33 public void actionPerformed (ActionEvent event
) {
37 Container labels
= new Container();
38 labels
.setLayout(new GridLayout(2, 1));
41 Container buttons
= new Container();
42 buttons
.setLayout(new FlowLayout(FlowLayout
.RIGHT
));
44 frame
.setLayout(new BorderLayout());
45 frame
.add(labels
, BorderLayout
.CENTER
);
46 frame
.add(buttons
, BorderLayout
.SOUTH
);
48 frame
.setVisible(true);
51 /* Return the process ID of the current process. */
52 private static String
getPid () {
54 String
[] args
= new String
[] { "/bin/sh", "-c", "echo $PPID" };
55 Process p
= Runtime
.getRuntime().exec(args
);
56 InputStream p_out
= p
.getInputStream();
57 String s
= (new BufferedReader(new InputStreamReader(p_out
))).readLine();
61 } catch (IOException e
) {