summaryrefslogtreecommitdiff
path: root/libs/FLib/TableLayout/doc/example
diff options
context:
space:
mode:
Diffstat (limited to 'libs/FLib/TableLayout/doc/example')
-rw-r--r--libs/FLib/TableLayout/doc/example/Example1.java242
-rw-r--r--libs/FLib/TableLayout/doc/example/TableExplorer.java2118
2 files changed, 1180 insertions, 1180 deletions
diff --git a/libs/FLib/TableLayout/doc/example/Example1.java b/libs/FLib/TableLayout/doc/example/Example1.java
index 797d1e7..5791d1a 100644
--- a/libs/FLib/TableLayout/doc/example/Example1.java
+++ b/libs/FLib/TableLayout/doc/example/Example1.java
@@ -44,137 +44,137 @@ public class Example1
// main
//**********************************************************************
-public static void
-main(
- String[] args)
-{
- new Example1();
-}
+ public static void
+ main(
+ String[] args)
+ {
+ new Example1();
+ }
//**********************************************************************
// Constructors
//**********************************************************************
-/**
- * Create the two windows and display them.
- */
+ /**
+ * Create the two windows and display them.
+ */
-public
-Example1()
-{
- JFrame frame1 = createGridBagLayout();
- JFrame frame2 = createTableLayout();
- frame1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- frame2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- frame1.pack();
- frame2.pack();
- frame1.setLocation(10, 100);
- frame2.setLocation(400, 100);
- frame1.setVisible(true);
- frame2.setVisible(true);
-}
+ public
+ Example1()
+ {
+ JFrame frame1 = createGridBagLayout();
+ JFrame frame2 = createTableLayout();
+ frame1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ frame2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ frame1.pack();
+ frame2.pack();
+ frame1.setLocation(10, 100);
+ frame2.setLocation(400, 100);
+ frame1.setVisible(true);
+ frame2.setVisible(true);
+ }
//**********************************************************************
// Private
//**********************************************************************
-/**
- * Create the layout using GridBagLayout. This code comes from the API
- * page for GridBagLayout.
- *
- * @return The JFrame containing the layout.
- */
-
-public JFrame
-createGridBagLayout()
-{
- JFrame frame = new JFrame("GridBagLayout");
-
- GridBagLayout gridbag = new GridBagLayout();
- GridBagConstraints c = new GridBagConstraints();
-
- JPanel panel = new JPanel(gridbag);
- frame.getContentPane().add(panel);
-
- c.fill = GridBagConstraints.BOTH;
- c.weightx = 1.0;
- makebutton(panel, "Button1", gridbag, c);
- makebutton(panel, "Button2", gridbag, c);
- makebutton(panel, "Button3", gridbag, c);
-
- c.gridwidth = GridBagConstraints.REMAINDER; //end row
- makebutton(panel, "Button4", gridbag, c);
-
- c.weightx = 0.0; //reset to the default
- makebutton(panel, "Button5", gridbag, c); //another row
-
- c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last in row
- makebutton(panel, "Button6", gridbag, c);
-
- c.gridwidth = GridBagConstraints.REMAINDER; //end row
- makebutton(panel, "Button7", gridbag, c);
-
- c.gridwidth = 1; //reset to the default
- c.gridheight = 2;
- c.weighty = 1.0;
- makebutton(panel, "Button8", gridbag, c);
-
- c.weighty = 0.0; //reset to the default
- c.gridwidth = GridBagConstraints.REMAINDER; //end row
- c.gridheight = 1; //reset to the default
- makebutton(panel, "Button9", gridbag, c);
- makebutton(panel, "Button10", gridbag, c);
-
- return frame;
-}
-
-/**
- * Helper method for createGridBagLayout().
- *
- * @param panel The panel to add the button to.
- * @param name The button's label.
- * @param gridbag The GridBagLayout to use.
- * @param c The constraints to use.
- */
-
-private void
-makebutton(
- JPanel panel,
- String name,
- GridBagLayout gridbag,
- GridBagConstraints c)
-{
- JButton button = new JButton(name);
- gridbag.setConstraints(button, c);
- panel.add(button);
-}
-
-/**
- * Create the layout using TableLayout.
- *
- * @return The JFrame containing the layout.
- */
-
-public JFrame
-createTableLayout()
-{
- JFrame frame = new JFrame("TableLayout");
-
- JPanel panel = new JPanel(new TableLayout("cols=4"));
- frame.getContentPane().add(panel);
-
- panel.add(new JButton("Button1"));
- panel.add(new JButton("Button2"));
- panel.add(new JButton("Button3"));
- panel.add(new JButton("Button4"));
- panel.add(new JButton("Button5"), "cspan=4");
- panel.add(new JButton("Button6"), "cspan=3");
- panel.add(new JButton("Button7"));
- panel.add(new JButton("Button8"), "rspan=2");
- panel.add(new JButton("Button9"), "cspan=3");
- panel.add(new JButton("Button10"), "cspan=3 rweight=1");
-
- return frame;
-}
+ /**
+ * Create the layout using GridBagLayout. This code comes from the API
+ * page for GridBagLayout.
+ *
+ * @return The JFrame containing the layout.
+ */
+
+ public JFrame
+ createGridBagLayout()
+ {
+ JFrame frame = new JFrame("GridBagLayout");
+
+ GridBagLayout gridbag = new GridBagLayout();
+ GridBagConstraints c = new GridBagConstraints();
+
+ JPanel panel = new JPanel(gridbag);
+ frame.getContentPane().add(panel);
+
+ c.fill = GridBagConstraints.BOTH;
+ c.weightx = 1.0;
+ makebutton(panel, "Button1", gridbag, c);
+ makebutton(panel, "Button2", gridbag, c);
+ makebutton(panel, "Button3", gridbag, c);
+
+ c.gridwidth = GridBagConstraints.REMAINDER; //end row
+ makebutton(panel, "Button4", gridbag, c);
+
+ c.weightx = 0.0; //reset to the default
+ makebutton(panel, "Button5", gridbag, c); //another row
+
+ c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last in row
+ makebutton(panel, "Button6", gridbag, c);
+
+ c.gridwidth = GridBagConstraints.REMAINDER; //end row
+ makebutton(panel, "Button7", gridbag, c);
+
+ c.gridwidth = 1; //reset to the default
+ c.gridheight = 2;
+ c.weighty = 1.0;
+ makebutton(panel, "Button8", gridbag, c);
+
+ c.weighty = 0.0; //reset to the default
+ c.gridwidth = GridBagConstraints.REMAINDER; //end row
+ c.gridheight = 1; //reset to the default
+ makebutton(panel, "Button9", gridbag, c);
+ makebutton(panel, "Button10", gridbag, c);
+
+ return frame;
+ }
+
+ /**
+ * Helper method for createGridBagLayout().
+ *
+ * @param panel The panel to add the button to.
+ * @param name The button's label.
+ * @param gridbag The GridBagLayout to use.
+ * @param c The constraints to use.
+ */
+
+ private void
+ makebutton(
+ JPanel panel,
+ String name,
+ GridBagLayout gridbag,
+ GridBagConstraints c)
+ {
+ JButton button = new JButton(name);
+ gridbag.setConstraints(button, c);
+ panel.add(button);
+ }
+
+ /**
+ * Create the layout using TableLayout.
+ *
+ * @return The JFrame containing the layout.
+ */
+
+ public JFrame
+ createTableLayout()
+ {
+ JFrame frame = new JFrame("TableLayout");
+
+ JPanel panel = new JPanel(new TableLayout("cols=4"));
+ frame.getContentPane().add(panel);
+
+ panel.add(new JButton("Button1"));
+ panel.add(new JButton("Button2"));
+ panel.add(new JButton("Button3"));
+ panel.add(new JButton("Button4"));
+ panel.add(new JButton("Button5"), "cspan=4");
+ panel.add(new JButton("Button6"), "cspan=3");
+ panel.add(new JButton("Button7"));
+ panel.add(new JButton("Button8"), "rspan=2");
+ panel.add(new JButton("Button9"), "cspan=3");
+ panel.add(new JButton("Button10"), "cspan=3 rweight=1");
+
+ return frame;
+ }
}
diff --git a/libs/FLib/TableLayout/doc/example/TableExplorer.java b/libs/FLib/TableLayout/doc/example/TableExplorer.java
index d66c497..90c3a5e 100644
--- a/libs/FLib/TableLayout/doc/example/TableExplorer.java
+++ b/libs/FLib/TableLayout/doc/example/TableExplorer.java
@@ -24,1039 +24,1039 @@ import org.freixas.tablelayout.*;
*/
public class TableExplorer
- extends JFrame
- implements CaretListener, ActionListener, ListSelectionListener,
- FocusListener, MenuListener
+ extends JFrame
+ implements CaretListener, ActionListener, ListSelectionListener,
+ FocusListener, MenuListener
{
//**********************************************************************
// Constants
//**********************************************************************
-static final String[] tablePositionList = {
- "Default",
- "tn", "tne", "tnw",
- "ts", "tse", "tsw",
- "te", "tw", "tc"
-};
+ static final String[] tablePositionList = {
+ "Default",
+ "tn", "tne", "tnw",
+ "ts", "tse", "tsw",
+ "te", "tw", "tc"
+ };
-static final String[] tableFillList = {
- "Default", "tfh", "tfv", "tf"
-};
+ static final String[] tableFillList = {
+ "Default", "tfh", "tfv", "tf"
+ };
-static final String[] positionList = {
- "Default",
- "n", "ne", "nw",
- "s", "se", "sw",
- "e", "w", "c"
-};
+ static final String[] positionList = {
+ "Default",
+ "n", "ne", "nw",
+ "s", "se", "sw",
+ "e", "w", "c"
+ };
-static final String[] fillList = {
- "Default", "fh", "fv", "f"
-};
+ static final String[] fillList = {
+ "Default", "fh", "fv", "f"
+ };
//**********************************************************************
// Fields
//**********************************************************************
-JFrame layout;
-JPanel layoutPane;
-JFrame code;
-JPanel codePane;
-
-HashMap compHash = new HashMap();
-HashMap attrHash = new HashMap();
-
-JMenu fileMenu;
-JMenu windowMenu;
-JMenu helpMenu;
-
-JMenuItem exitItem;
-JMenuItem previewItem;
-JMenuItem packItem;
-JMenuItem codeItem;
-JMenuItem generateItem;
-JMenuItem aboutItem;
-
-JButton upButton;
-JButton downButton;
-JButton removeButton;
-JButton addButton;
-
-JList compList;
-DefaultListModel compListModel;
-JTextField compEntryField;
-
-JTextField columnsField;
-JTextField[] tableInsetFields = new JTextField[4];
-JTextField rowGapField;
-JTextField colGapField;
-JComboBox tablePositionBox;
-JComboBox tableFillBox;
-
-JTextField[] tableCellInsetFields = new JTextField[4];
-JComboBox tableCellPositionBox;
-JComboBox tableCellFillBox;
-JTextField tableRowWeightField;
-JTextField tableColWeightField;
-
-JTextField tableAttributesField;
-
-JTextField[] insetFields = new JTextField[4];
-JComboBox positionBox;
-JComboBox fillBox;
-JTextField rowWeightField;
-JTextField colWeightField;
-JTextField colPositionField;
-JTextField skipCellsField;
-JTextField rowSpanField;
-JTextField colSpanField;
-
-JTextField cellAttributesField;
-
-JTextArea codeTextArea;
-JScrollPane codeTextScroll;
-
-String textWhenFocusGained = null;
-boolean ignoreEvents = false;
-
-TableAttributes tableAttributes = null;
+ JFrame layout;
+ JPanel layoutPane;
+ JFrame code;
+ JPanel codePane;
+
+ HashMap compHash = new HashMap();
+ HashMap attrHash = new HashMap();
+
+ JMenu fileMenu;
+ JMenu windowMenu;
+ JMenu helpMenu;
+
+ JMenuItem exitItem;
+ JMenuItem previewItem;
+ JMenuItem packItem;
+ JMenuItem codeItem;
+ JMenuItem generateItem;
+ JMenuItem aboutItem;
+
+ JButton upButton;
+ JButton downButton;
+ JButton removeButton;
+ JButton addButton;
+
+ JList compList;
+ DefaultListModel compListModel;
+ JTextField compEntryField;
+
+ JTextField columnsField;
+ JTextField[] tableInsetFields = new JTextField[4];
+ JTextField rowGapField;
+ JTextField colGapField;
+ JComboBox tablePositionBox;
+ JComboBox tableFillBox;
+
+ JTextField[] tableCellInsetFields = new JTextField[4];
+ JComboBox tableCellPositionBox;
+ JComboBox tableCellFillBox;
+ JTextField tableRowWeightField;
+ JTextField tableColWeightField;
+
+ JTextField tableAttributesField;
+
+ JTextField[] insetFields = new JTextField[4];
+ JComboBox positionBox;
+ JComboBox fillBox;
+ JTextField rowWeightField;
+ JTextField colWeightField;
+ JTextField colPositionField;
+ JTextField skipCellsField;
+ JTextField rowSpanField;
+ JTextField colSpanField;
+
+ JTextField cellAttributesField;
+
+ JTextArea codeTextArea;
+ JScrollPane codeTextScroll;
+
+ String textWhenFocusGained = null;
+ boolean ignoreEvents = false;
+
+ TableAttributes tableAttributes = null;
//**********************************************************************
// Main
//**********************************************************************
-static public void
-main(
- String[] args)
-{
- new TableExplorer();
-}
+ static public void
+ main(
+ String[] args)
+ {
+ new TableExplorer();
+ }
//**********************************************************************
// Constructors
//**********************************************************************
-/**
- * Create the TableExplorer JFrame.
- */
+ /**
+ * Create the TableExplorer JFrame.
+ */
-TableExplorer()
-{
- super("TableExplorer");
+ TableExplorer()
+ {
+ super("TableExplorer");
- // Table with three columns
- // Row 1: Buttons for managing component list
- // Row 2: Component list
- // Row 3: Attribute settings
+ // Table with three columns
+ // Row 1: Buttons for managing component list
+ // Row 2: Component list
+ // Row 3: Attribute settings
- setJMenuBar(createJMenuBar());
+ setJMenuBar(createJMenuBar());
- getContentPane().setLayout(
- new TableLayout("cols=3 cgap=5 " +
- "titop=2 tibottom=2 tileft=2 tiright=2"));
+ getContentPane().setLayout(
+ new TableLayout("cols=3 cgap=5 " +
+ "titop=2 tibottom=2 tileft=2 tiright=2"));
- getContentPane().add(createButtonPane());
- getContentPane().add(createListPane(), "cweight=1");
- getContentPane().add(createAttributePane(), "n fh");
+ getContentPane().add(createButtonPane());
+ getContentPane().add(createListPane(), "cweight=1");
+ getContentPane().add(createAttributePane(), "n fh");
- pack();
- setVisible(true);
+ pack();
+ setVisible(true);
- layout = new JFrame("Table Layout Preview");
- layoutPane = (JPanel)layout.getContentPane();
- layoutPane.setName("DEBUG");
- layoutPane.setLayout(new TableLayout());
- layoutPane.setOpaque(true);
+ layout = new JFrame("Table Layout Preview");
+ layoutPane = (JPanel)layout.getContentPane();
+ layoutPane.setName("DEBUG");
+ layoutPane.setLayout(new TableLayout());
+ layoutPane.setOpaque(true);
- code = new JFrame("Table Layout Code");
- codePane = createCodePane();
- code.setContentPane(codePane);
- code.pack();
+ code = new JFrame("Table Layout Code");
+ codePane = createCodePane();
+ code.setContentPane(codePane);
+ code.pack();
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- compEntryField.grabFocus();
+ compEntryField.grabFocus();
- layout.setSize(300, 300);
-}
+ layout.setSize(300, 300);
+ }
//**********************************************************************
// Public
//**********************************************************************
-public void
-caretUpdate(
- CaretEvent e)
-{
- if (e.getSource() == compEntryField) {
- String text = compEntryField.getText();
- addButton.setEnabled(text.length() > 0);
- }
-}
-
-public void
-actionPerformed(
- ActionEvent e)
-{
- if (ignoreEvents) return;
-
- if (e.getSource() == addButton ||
- e.getSource() == compEntryField) {
-
- String name = compEntryField.getText();
-
- JButton button = new JButton(name);
- addToLayout(button);
- compHash.put(name, button);
- attrHash.put(name, new Attributes());
- compListModel.addElement(name);
- compEntryField.setText("");
- addButton.setEnabled(false);
- }
-
- else if (e.getSource() == removeButton) {
- String name = (String)compList.getSelectedValue();
- if (name != null) {
- Component c = (Component)compHash.get(name);
- layoutPane.remove(c);
- compHash.remove(name);
- attrHash.remove(name);
- compListModel.removeElement(name);
- removeButton.setEnabled(false);
- layoutPane.revalidate();
- }
- }
-
- else if (e.getSource() == upButton) {
- int index = compList.getSelectedIndex();
- if (index > 0) {
- String name = (String)compListModel.elementAt(index);
- compListModel.removeElementAt(index);
- compListModel.insertElementAt(name, index - 1);
- compList.setSelectedIndex(index - 1);
-
- Component c = (Component)compHash.get(name);
- Attributes a = (Attributes)attrHash.get(name);
- layoutPane.remove(index);
- layoutPane.add(c, a.toString(), index - 1);
- layoutPane.revalidate();
- }
- }
-
- else if (e.getSource() == downButton) {
- int index = compList.getSelectedIndex();
- if (index > -1 && index < compListModel.getSize() - 1) {
- String name = (String)compListModel.elementAt(index);
- compListModel.removeElementAt(index);
- compListModel.insertElementAt(name, index + 1);
- compList.setSelectedIndex(index + 1);
-
- Component c = (Component)compHash.get(name);
- Attributes a = (Attributes)attrHash.get(name);
- layoutPane.remove(index);
- layoutPane.add(c, a.toString(), index + 1);
- layoutPane.revalidate();
- }
+ public void
+ caretUpdate(
+ CaretEvent e)
+ {
+ if (e.getSource() == compEntryField) {
+ String text = compEntryField.getText();
+ addButton.setEnabled(text.length() > 0);
+ }
}
- else if (e.getSource() == insetFields[0] ||
- e.getSource() == insetFields[1] ||
- e.getSource() == insetFields[2] ||
- e.getSource() == insetFields[3] ||
- e.getSource() == positionBox ||
- e.getSource() == fillBox ||
- e.getSource() == rowWeightField ||
- e.getSource() == colWeightField ||
- e.getSource() == colPositionField ||
- e.getSource() == skipCellsField ||
- e.getSource() == rowSpanField ||
- e.getSource() == colSpanField) {
- String name = (String)compList.getSelectedValue();
- changeLayout(name);
+ public void
+ actionPerformed(
+ ActionEvent e)
+ {
+ if (ignoreEvents) return;
+
+ if (e.getSource() == addButton ||
+ e.getSource() == compEntryField) {
+
+ String name = compEntryField.getText();
+
+ JButton button = new JButton(name);
+ addToLayout(button);
+ compHash.put(name, button);
+ attrHash.put(name, new Attributes());
+ compListModel.addElement(name);
+ compEntryField.setText("");
+ addButton.setEnabled(false);
+ }
+
+ else if (e.getSource() == removeButton) {
+ String name = (String)compList.getSelectedValue();
+ if (name != null) {
+ Component c = (Component)compHash.get(name);
+ layoutPane.remove(c);
+ compHash.remove(name);
+ attrHash.remove(name);
+ compListModel.removeElement(name);
+ removeButton.setEnabled(false);
+ layoutPane.revalidate();
+ }
+ }
+
+ else if (e.getSource() == upButton) {
+ int index = compList.getSelectedIndex();
+ if (index > 0) {
+ String name = (String)compListModel.elementAt(index);
+ compListModel.removeElementAt(index);
+ compListModel.insertElementAt(name, index - 1);
+ compList.setSelectedIndex(index - 1);
+
+ Component c = (Component)compHash.get(name);
+ Attributes a = (Attributes)attrHash.get(name);
+ layoutPane.remove(index);
+ layoutPane.add(c, a.toString(), index - 1);
+ layoutPane.revalidate();
+ }
+ }
+
+ else if (e.getSource() == downButton) {
+ int index = compList.getSelectedIndex();
+ if (index > -1 && index < compListModel.getSize() - 1) {
+ String name = (String)compListModel.elementAt(index);
+ compListModel.removeElementAt(index);
+ compListModel.insertElementAt(name, index + 1);
+ compList.setSelectedIndex(index + 1);
+
+ Component c = (Component)compHash.get(name);
+ Attributes a = (Attributes)attrHash.get(name);
+ layoutPane.remove(index);
+ layoutPane.add(c, a.toString(), index + 1);
+ layoutPane.revalidate();
+ }
+ }
+
+ else if (e.getSource() == insetFields[0] ||
+ e.getSource() == insetFields[1] ||
+ e.getSource() == insetFields[2] ||
+ e.getSource() == insetFields[3] ||
+ e.getSource() == positionBox ||
+ e.getSource() == fillBox ||
+ e.getSource() == rowWeightField ||
+ e.getSource() == colWeightField ||
+ e.getSource() == colPositionField ||
+ e.getSource() == skipCellsField ||
+ e.getSource() == rowSpanField ||
+ e.getSource() == colSpanField) {
+ String name = (String)compList.getSelectedValue();
+ changeLayout(name);
+ }
+
+ else if (e.getSource() == columnsField ||
+ e.getSource() == tableInsetFields[0] ||
+ e.getSource() == tableInsetFields[1] ||
+ e.getSource() == tableInsetFields[2] ||
+ e.getSource() == tableInsetFields[3] ||
+ e.getSource() == rowGapField ||
+ e.getSource() == colGapField ||
+ e.getSource() == tablePositionBox ||
+ e.getSource() == tableFillBox ||
+ e.getSource() == tableCellInsetFields[0] ||
+ e.getSource() == tableCellInsetFields[1] ||
+ e.getSource() == tableCellInsetFields[2] ||
+ e.getSource() == tableCellInsetFields[3] ||
+ e.getSource() == tableCellPositionBox ||
+ e.getSource() == tableCellFillBox ||
+ e.getSource() == tableRowWeightField ||
+ e.getSource() == tableColWeightField) {
+ changeTableLayout();
+ }
+
+ else if (e.getSource() == exitItem) {
+ System.exit(0);
+ }
+
+ else if (e.getSource() == previewItem) {
+ if (layout.isVisible()) {
+ layout.setVisible(false);
+ }
+ else {
+ layout.setVisible(true);
+ }
+ }
+
+ else if (e.getSource() == packItem) {
+ layout.pack();
+ }
+
+ else if (e.getSource() == codeItem) {
+ if (code.isVisible()) {
+ code.setVisible(false);
+ }
+ else {
+ generateCode();
+ code.setVisible(true);
+ }
+ }
+
+ else if (e.getSource() == generateItem) {
+ generateCode();
+ }
+
+ else if (e.getSource() == aboutItem) {
+ JOptionPane.showMessageDialog(this,
+ "<html>" +
+ "<h1><font face=Dialog>Table Explorer V1.0</font></h1>" +
+ "<font face=Dialog>Written by Antonio Freixas<br>" +
+ "<a src=\"mailto:tony@freixas.org\">tonyf@freixas.org</a>",
+ "About Table Explorer</font>",
+ JOptionPane.INFORMATION_MESSAGE);
+ }
}
- else if (e.getSource() == columnsField ||
- e.getSource() == tableInsetFields[0] ||
- e.getSource() == tableInsetFields[1] ||
- e.getSource() == tableInsetFields[2] ||
- e.getSource() == tableInsetFields[3] ||
- e.getSource() == rowGapField ||
- e.getSource() == colGapField ||
- e.getSource() == tablePositionBox ||
- e.getSource() == tableFillBox ||
- e.getSource() == tableCellInsetFields[0] ||
- e.getSource() == tableCellInsetFields[1] ||
- e.getSource() == tableCellInsetFields[2] ||
- e.getSource() == tableCellInsetFields[3] ||
- e.getSource() == tableCellPositionBox ||
- e.getSource() == tableCellFillBox ||
- e.getSource() == tableRowWeightField ||
- e.getSource() == tableColWeightField) {
- changeTableLayout();
+ public void
+ valueChanged(
+ ListSelectionEvent e)
+ {
+ if (ignoreEvents) return;
+
+ if (e.getSource() == compList) {
+ String name = (String)compList.getSelectedValue();
+ int index = compList.getSelectedIndex();
+
+ boolean hasObject = name != null;
+
+ removeButton.setEnabled(hasObject);
+ upButton.setEnabled(hasObject && index != 0);
+ downButton.setEnabled(hasObject &&
+ index != compListModel.getSize() - 1);
+ enableAttributes(hasObject);
+
+ if (hasObject) {
+ Attributes attributes = (Attributes)attrHash.get(name);
+ setAttributes(attributes);
+ }
+ }
}
- else if (e.getSource() == exitItem) {
- System.exit(0);
+ public void
+ focusGained(
+ FocusEvent e)
+ {
+ if (e.getSource() == insetFields[0] ||
+ e.getSource() == insetFields[1] ||
+ e.getSource() == insetFields[2] ||
+ e.getSource() == insetFields[3] ||
+ e.getSource() == rowWeightField ||
+ e.getSource() == colWeightField ||
+ e.getSource() == colPositionField ||
+ e.getSource() == skipCellsField ||
+ e.getSource() == rowSpanField ||
+ e.getSource() == colSpanField||
+ e.getSource() == columnsField ||
+ e.getSource() == tableInsetFields[0] ||
+ e.getSource() == tableInsetFields[1] ||
+ e.getSource() == tableInsetFields[2] ||
+ e.getSource() == tableInsetFields[3] ||
+ e.getSource() == rowGapField ||
+ e.getSource() == colGapField ||
+ e.getSource() == tableCellInsetFields[0] ||
+ e.getSource() == tableCellInsetFields[1] ||
+ e.getSource() == tableCellInsetFields[2] ||
+ e.getSource() == tableCellInsetFields[3] ||
+ e.getSource() == tableRowWeightField ||
+ e.getSource() == tableColWeightField) {
+
+ JTextField field = (JTextField)e.getSource();
+ textWhenFocusGained = field.getText();
+ }
+ else if (e.getSource() == positionBox ||
+ e.getSource() == fillBox ||
+ e.getSource() == tablePositionBox ||
+ e.getSource() == tableFillBox ||
+ e.getSource() == tableCellPositionBox ||
+ e.getSource() == tableCellFillBox) {
+
+ JComboBox box = (JComboBox)e.getSource();
+ textWhenFocusGained = (String)box.getSelectedItem();
+ }
+ else {
+ textWhenFocusGained = null;
+ }
}
- else if (e.getSource() == previewItem) {
- if (layout.isVisible()) {
- layout.setVisible(false);
- }
- else {
- layout.setVisible(true);
- }
+ public void
+ focusLost(
+ FocusEvent e)
+ {
+ if (textWhenFocusGained != null) {
+ if (e.getSource() == insetFields[0] ||
+ e.getSource() == insetFields[1] ||
+ e.getSource() == insetFields[2] ||
+ e.getSource() == insetFields[3] ||
+ e.getSource() == rowWeightField ||
+ e.getSource() == colWeightField ||
+ e.getSource() == colPositionField ||
+ e.getSource() == skipCellsField ||
+ e.getSource() == rowSpanField ||
+ e.getSource() == colSpanField) {
+
+ JTextField field = (JTextField)e.getSource();
+ if (!textWhenFocusGained.equals(field.getText())) {
+ changeLayout();
+ }
+ }
+ else if (e.getSource() == positionBox ||
+ e.getSource() == fillBox) {
+ JComboBox box = (JComboBox)e.getSource();
+ if (!textWhenFocusGained.equals(box.getSelectedItem())) {
+ changeLayout();
+ }
+ }
+ else if (e.getSource() == columnsField ||
+ e.getSource() == tableInsetFields[0] ||
+ e.getSource() == tableInsetFields[1] ||
+ e.getSource() == tableInsetFields[2] ||
+ e.getSource() == tableInsetFields[3] ||
+ e.getSource() == rowGapField ||
+ e.getSource() == colGapField ||
+ e.getSource() == tableCellInsetFields[0] ||
+ e.getSource() == tableCellInsetFields[1] ||
+ e.getSource() == tableCellInsetFields[2] ||
+ e.getSource() == tableCellInsetFields[3] ||
+ e.getSource() == tableRowWeightField ||
+ e.getSource() == tableColWeightField) {
+
+ JTextField field = (JTextField)e.getSource();
+ if (!textWhenFocusGained.equals(field.getText())) {
+ changeTableLayout();
+ }
+ }
+
+ else if (e.getSource() == tablePositionBox ||
+ e.getSource() == tableFillBox ||
+ e.getSource() == tableCellPositionBox ||
+ e.getSource() == tableCellFillBox) {
+
+ JComboBox box = (JComboBox)e.getSource();
+ if (!textWhenFocusGained.equals(box.getSelectedItem())) {
+ changeTableLayout();
+ }
+ }
+ }
+
+ textWhenFocusGained = null;
}
- else if (e.getSource() == packItem) {
- layout.pack();
+ public void
+ menuCanceled(
+ MenuEvent e)
+ {
}
- else if (e.getSource() == codeItem) {
- if (code.isVisible()) {
- code.setVisible(false);
- }
- else {
- generateCode();
- code.setVisible(true);
- }
+ public void
+ menuDeselected(
+ MenuEvent e)
+ {
}
- else if (e.getSource() == generateItem) {
- generateCode();
+ public void
+ menuSelected(
+ MenuEvent e)
+ {
+ if (e.getSource() == windowMenu) {
+ if (layout.isVisible()) {
+ previewItem.setText("Hide Preview Window");
+ }
+ else {
+ previewItem.setText("Show Preview Window");
+ }
+ if (code.isVisible()) {
+ codeItem.setText("Hide Code Window");
+ }
+ else {
+ codeItem.setText("Show Code Window");
+ }
+ }
}
- else if (e.getSource() == aboutItem) {
- JOptionPane.showMessageDialog(this,
- "<html>" +
- "<h1><font face=Dialog>Table Explorer V1.0</font></h1>" +
- "<font face=Dialog>Written by Antonio Freixas<br>" +
- "<a src=\"mailto:tony@freixas.org\">tonyf@freixas.org</a>",
- "About Table Explorer</font>",
- JOptionPane.INFORMATION_MESSAGE);
- }
-}
-
-public void
-valueChanged(
- ListSelectionEvent e)
-{
- if (ignoreEvents) return;
-
- if (e.getSource() == compList) {
- String name = (String)compList.getSelectedValue();
- int index = compList.getSelectedIndex();
-
- boolean hasObject = name != null;
-
- removeButton.setEnabled(hasObject);
- upButton.setEnabled(hasObject && index != 0);
- downButton.setEnabled(hasObject &&
- index != compListModel.getSize() - 1);
- enableAttributes(hasObject);
-
- if (hasObject) {
- Attributes attributes = (Attributes)attrHash.get(name);
- setAttributes(attributes);
- }
- }
-}
-
-public void
-focusGained(
- FocusEvent e)
-{
- if (e.getSource() == insetFields[0] ||
- e.getSource() == insetFields[1] ||
- e.getSource() == insetFields[2] ||
- e.getSource() == insetFields[3] ||
- e.getSource() == rowWeightField ||
- e.getSource() == colWeightField ||
- e.getSource() == colPositionField ||
- e.getSource() == skipCellsField ||
- e.getSource() == rowSpanField ||
- e.getSource() == colSpanField||
- e.getSource() == columnsField ||
- e.getSource() == tableInsetFields[0] ||
- e.getSource() == tableInsetFields[1] ||
- e.getSource() == tableInsetFields[2] ||
- e.getSource() == tableInsetFields[3] ||
- e.getSource() == rowGapField ||
- e.getSource() == colGapField ||
- e.getSource() == tableCellInsetFields[0] ||
- e.getSource() == tableCellInsetFields[1] ||
- e.getSource() == tableCellInsetFields[2] ||
- e.getSource() == tableCellInsetFields[3] ||
- e.getSource() == tableRowWeightField ||
- e.getSource() == tableColWeightField) {
-
- JTextField field = (JTextField)e.getSource();
- textWhenFocusGained = field.getText();
- }
- else if (e.getSource() == positionBox ||
- e.getSource() == fillBox ||
- e.getSource() == tablePositionBox ||
- e.getSource() == tableFillBox ||
- e.getSource() == tableCellPositionBox ||
- e.getSource() == tableCellFillBox) {
-
- JComboBox box = (JComboBox)e.getSource();
- textWhenFocusGained = (String)box.getSelectedItem();
- }
- else {
- textWhenFocusGained = null;
- }
-}
-
-public void
-focusLost(
- FocusEvent e)
-{
- if (textWhenFocusGained != null) {
- if (e.getSource() == insetFields[0] ||
- e.getSource() == insetFields[1] ||
- e.getSource() == insetFields[2] ||
- e.getSource() == insetFields[3] ||
- e.getSource() == rowWeightField ||
- e.getSource() == colWeightField ||
- e.getSource() == colPositionField ||
- e.getSource() == skipCellsField ||
- e.getSource() == rowSpanField ||
- e.getSource() == colSpanField) {
-
- JTextField field = (JTextField)e.getSource();
- if (!textWhenFocusGained.equals(field.getText())) {
- changeLayout();
- }
- }
- else if (e.getSource() == positionBox ||
- e.getSource() == fillBox) {
- JComboBox box = (JComboBox)e.getSource();
- if (!textWhenFocusGained.equals(box.getSelectedItem())) {
- changeLayout();
- }