]>
git.argeo.org Git - gpl/argeo-slc.git/blob - sandbox/argeo.slc.jemmytest/src/main/java/org/argeo/slc/jemmytest/ui/SwingTestUi.java
91dfd126e03759c51ba5b9c1847789c1add02ce8
1 package org
.argeo
.slc
.jemmytest
.ui
;
3 import java
.awt
.GridLayout
;
4 import java
.awt
.event
.ActionEvent
;
5 import java
.awt
.event
.ActionListener
;
7 import javax
.swing
.JButton
;
8 import javax
.swing
.JFrame
;
9 import javax
.swing
.JLabel
;
11 public class SwingTestUi
{
12 private static void createAndShowGUI(boolean exitOnClose
) {
13 // Create and set up the window.
14 JFrame frame
= new JFrame("HelloWorldSwing");
16 frame
.setDefaultCloseOperation(JFrame
.EXIT_ON_CLOSE
);
18 frame
.getContentPane().setLayout(new GridLayout(2, 1));
20 // Add the ubiquitous "Hello World" label.
21 final JLabel label
= new JLabel("Hello World");
22 frame
.getContentPane().add(label
);
24 final JButton button
= new JButton("Button");
25 frame
.getContentPane().add(button
);
26 button
.addActionListener(new ActionListener() {
27 public void actionPerformed(ActionEvent e
) {
28 label
.setText("Pressed!!");
32 // Display the window.
34 frame
.setVisible(true);
37 public static void main(String
[] args
) {
38 boolean noExitOnClose
= false;
39 for (int i
= 0; i
< args
.length
; i
++) {
40 if (args
[i
].equals("noExitOnClose")) {
45 final boolean exitOnClose
= !noExitOnClose
;
46 javax
.swing
.SwingUtilities
.invokeLater(new Runnable() {
48 createAndShowGUI(exitOnClose
);