diff options
author | kbr <[email protected]> | 2006-12-20 01:57:05 +0000 |
---|---|---|
committer | kbr <[email protected]> | 2006-12-20 01:57:05 +0000 |
commit | fe96056b559fdcae63b36c1692bc114a49acf11a (patch) | |
tree | bb9ca2046cc13a609519db8284604f2e7b1bf57b | |
parent | cc66c1ffb53c2838c1e641dc00f8731f23c68aed (diff) |
Added option for excluding Quit button from GUI
git-svn-id: file:///home/mbien/NetBeansProjects/JOGAMP/joal-sync/svn-server-sync-demos/joal-demos/trunk@53 235fdd13-0e8c-4fed-b5ee-0a390d04b286
-rwxr-xr-x | src/java/demos/devmaster/lesson1/SingleStaticSource.java | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/java/demos/devmaster/lesson1/SingleStaticSource.java b/src/java/demos/devmaster/lesson1/SingleStaticSource.java index 431544e..32834cb 100755 --- a/src/java/demos/devmaster/lesson1/SingleStaticSource.java +++ b/src/java/demos/devmaster/lesson1/SingleStaticSource.java @@ -57,10 +57,10 @@ import javax.swing.*; public class SingleStaticSource { public SingleStaticSource(boolean gui) { - this(gui, null); + this(gui, null, true); } - public SingleStaticSource(boolean gui, Container parent) { + public SingleStaticSource(boolean gui, Container parent, boolean showQuitButton) { if (gui) { JFrame frame = null; @@ -71,7 +71,7 @@ public class SingleStaticSource { } JPanel container = new JPanel(); - container.setLayout(new GridLayout(4, 1)); + container.setLayout(new GridLayout((showQuitButton ? 4 : 3), 1)); JButton button = new JButton("Play sound"); button.addActionListener(new ActionListener() { @@ -100,16 +100,19 @@ public class SingleStaticSource { } }); container.add(button); - button = new JButton("Quit"); - button.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (!initialize()) - System.exit(1); - killAllData(); - System.exit(0); - } - }); - container.add(button); + + if (showQuitButton) { + button = new JButton("Quit"); + button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (!initialize()) + System.exit(1); + killAllData(); + System.exit(0); + } + }); + container.add(button); + } parent.add(container); |