 |
Home | Changes | Index | Search | Go
Foam is an easy to use Swing-based panel editor, available at http://www.computersinmotion.com.
Pointed at the Layout Showdown, it took about 20 minutes to come up with a solution in Foam. I believe it follows the spec entirely, including platform-specific button spacing.
Note the code was all generated. Note the useful action handlers at the bottom!
There's an XML file containing the layout XML and a Foam project file at http://www.ausperks.net/FoamShowdown.zip
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextField;
import com.cim.dlgedit.loader.DialogResource;
import com.cim.util.swing.DlgUtils;
public class DlgShowdown extends JDialog implements ActionListener {
// Declare beans.
private JButton newButton;
private JButton deleteButton;
private JButton editButton;
private JButton saveButton;
private JButton cancelButton;
private JTextField country;
private JTextField state;
private JTextField phone;
private JTextField email;
private JTextField address1;
private JTextField address2;
private JTextField city;
// Constructor.
public DlgShowdown(Frame owner) {
// This dialog is modal.
super(owner, "Showdown", true);
// Load up the dialog contents.
JPanel panel = DialogResource.load("Showdown.gui_xml");
setContentPane(panel);
// Attach beans to fields.
newButton = (JButton) DialogResource.getComponentByName(panel, "newButton");
deleteButton = (JButton) DialogResource.getComponentByName(panel, "deleteButton");
editButton = (JButton) DialogResource.getComponentByName(panel, "editButton");
saveButton = (JButton) DialogResource.getComponentByName(panel, "saveButton");
cancelButton = (JButton) DialogResource.getComponentByName(panel, "cancelButton");
country = (JTextField) DialogResource.getComponentByName(panel, "country");
state = (JTextField) DialogResource.getComponentByName(panel, "state");
phone = (JTextField) DialogResource.getComponentByName(panel, "phone");
email = (JTextField) DialogResource.getComponentByName(panel, "email");
address1 = (JTextField) DialogResource.getComponentByName(panel, "address1");
address2 = (JTextField) DialogResource.getComponentByName(panel, "address2");
city = (JTextField) DialogResource.getComponentByName(panel, "city");
// Add dialog as ActionListener.
newButton.addActionListener(this);
deleteButton.addActionListener(this);
editButton.addActionListener(this);
saveButton.addActionListener(this);
cancelButton.addActionListener(this);
pack();
setLocationRelativeTo(owner);
// Set Enter and Escape keys as default keys.
//getRootPane().setDefaultButton(ok);
//DlgKeyHandler.addDefaultKeysHandler(this, ok, cancel);
//setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
/**
* Invoke the onXxx() action handlers.
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
DlgUtils.invokeHandler(this, e);
}
public void onnewButton() {
}
public void ondeleteButton() {
}
public void oneditButton() {
}
public void onsaveButton() {
}
public void oncancelButton() {
}
}
-- Main.johngunther - 21 Jun 2007 Since the XML is where the real layout is specified, it would be nice to see the XML here, not just in the ZIP.
|