1 // Example for use of GNU gettext.
2 // This file is in the public domain.
4 // Source code of the Java/QtJambi program.
9 import com.trolltech.qt.core.*;
10 import com.trolltech.qt.gui.*;
14 public static void main (String[] args) {
15 ResourceBundle catalog = ResourceBundle.getBundle("hello-java-qtjambi");
17 QApplication.initialize(args);
19 QMainWindow window = new QMainWindow();
20 window.setWindowTitle("Hello example");
22 QWidget panel = new QWidget();
23 QVBoxLayout panelLayout = new QVBoxLayout();
24 panelLayout.setSpacing(2);
27 new QLabel(GettextResource.gettext(catalog,"Hello, world!"));
28 panelLayout.addWidget(label1);
33 GettextResource.gettext(catalog,
34 "This program is running as process number {0}."),
35 new Object[] { getPid() }));
36 panelLayout.addWidget(label2);
38 QWidget buttonBar = new QWidget();
39 QHBoxLayout buttonBarLayout = new QHBoxLayout();
40 QWidget filler = new QWidget(); // makes the button right-aligned
41 buttonBarLayout.addWidget(filler);
42 QPushButton button = new QPushButton("OK");
43 button.setMaximumWidth(button.sizeHint().width()+20);
44 button.clicked.connect(window, "close()");
45 buttonBarLayout.addWidget(button);
46 buttonBar.setLayout(buttonBarLayout);
47 panelLayout.addWidget(buttonBar);
49 panel.setLayout(panelLayout);
51 window.setCentralWidget(panel);
58 /* Return the process ID of the current process. */
59 private static String getPid () {
61 String[] args = new String[] { "/bin/sh", "-c", "echo $PPID" };
62 Process p = Runtime.getRuntime().exec(args);
63 InputStream p_out = p.getInputStream();
64 String s = (new BufferedReader(new InputStreamReader(p_out))).readLine();
68 } catch (IOException e) {