FileDocCategorySizeDatePackage
XwmChooser.javaAPI DocExample2170Sat Jan 27 21:38:42 GMT 2001None

XwmChooser

public class XwmChooser extends Object
Prototype for Window Manager chooser. Recode in Qt for speed, someday.

Fields Summary
JFrame
jf
JButton
apply
JButton
cancel
JComboBox
choice
Constructors Summary
public XwmChooser()

		jf = new JFrame("Choose a Window Mangler");
		Container cp = jf.getContentPane();
		choice  = new JComboBox();
		choice.addItem(new WM("K Desktop 2.0 (KDE)", "/usr/local/bin/startkde"));
		choice.addItem(new WM("OPEN LOOK (olvwm)", "/usr/local/bin/olvwm"));
		choice.addItem(new WM("fvwm", "/usr/X11R6/bin/fvwm"));
		choice.addItem(new WM("xfwm", "/usr/local/bin/xfwm"));

		cp.add(BorderLayout.CENTER, choice);

		JPanel bottom = new JPanel();
		bottom.add(apply = new JButton("Apply"));
		apply.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				int n;
				if ((n = choice.getSelectedIndex()) == -1)
					return;
				WM wm = (WM)choice.getSelectedItem();
				String program = wm.getProgram();
				if (!new File(program).exists()) {
					JOptionPane.showMessageDialog(jf,
						"Program " + program + " does not seem to exist",
						"Whoa!", JOptionPane.ERROR_MESSAGE);
					return;
				}
				try {
					Runtime.getRuntime().exec(wm.program);
				} catch (IOException ex) {
					JOptionPane.showMessageDialog(jf,
						"Program " + program + " could not be run\n" + ex,
						"Whoa!", JOptionPane.ERROR_MESSAGE);
					return;
					
				}
			}
		});

		bottom.add(apply = new JButton("Cancel"));
		apply.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				System.exit(0);
			}
		});

		cp.add(BorderLayout.SOUTH, bottom);

		jf.pack();
		UtilGUI.center(jf);

		jf.setVisible(true);
	
Methods Summary
public static voidmain(java.lang.String[] args)

		new XwmChooser();