diff options
| author | Paul Buetow <paul@buetow.org> | 2008-05-21 21:24:42 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-05-21 21:24:42 +0000 |
| commit | 6fd1d5c225c70677ef40ec7d76111b849e5d7d75 (patch) | |
| tree | d58f8bb0913c0d0329e1b240628ac2af0c972d6c /sources/prefs/editors/VSEditorTable.java | |
| parent | db4ae1c41883f6f78d8107429f7f4871c45f47d5 (diff) | |
JTable editor done?!? :)
Diffstat (limited to 'sources/prefs/editors/VSEditorTable.java')
| -rw-r--r-- | sources/prefs/editors/VSEditorTable.java | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/sources/prefs/editors/VSEditorTable.java b/sources/prefs/editors/VSEditorTable.java index 8d5de52..bc35b57 100644 --- a/sources/prefs/editors/VSEditorTable.java +++ b/sources/prefs/editors/VSEditorTable.java @@ -6,6 +6,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; +import javax.swing.text.*; import prefs.*; @@ -19,6 +20,10 @@ public class VSEditorTable extends JTable { private String key; private Component comp; + public VSNode(String key) { + this.key = key; + } + public VSNode(String key, Component comp) { this.key = key; this.comp = comp; @@ -35,6 +40,10 @@ public class VSEditorTable extends JTable { public Component getRendererComponent() { return comp; } + + public boolean isSeparator() { + return comp == null; + } } private class VSEditorTableModel extends AbstractTableModel implements TableCellRenderer { @@ -56,16 +65,26 @@ public class VSEditorTable extends JTable { public Object getValueAt(int row, int col) { VSNode node = nodes.get(row); + if (node.isSeparator()) { + if (col == 1) + return ""; + + return node.getKey(); + } + if (col == 0) return node.getKey(); - else - return node.getComponent(); + + return node.getComponent(); } public boolean isCellEditable(int row, int col) { if (col == 0) return false; + if (nodes.get(row).isSeparator()) + return false; + return true; } @@ -78,6 +97,17 @@ public class VSEditorTable extends JTable { VSNode node = nodes.get(row); + if (node.isSeparator()) { + JTextPane pane = new JTextPane(); + if (col == 0) { + pane.setText(node.getKey()); + Style style = pane.addStyle("Bold", null); + StyleConstants.setBold(style, true); + } + pane.setBackground(new Color(0xCF, 0xCF, 0XCF)); + return pane; + } + if (col == 0) { JTextField field = new JTextField(" "+node.getKey()+":"); field.setBorder(null); @@ -114,7 +144,8 @@ public class VSEditorTable extends JTable { setBackground(Color.WHITE); getTableHeader().setVisible(false); TableColumn col = getColumnModel().getColumn(1); - col.setMaxWidth(90); + col.setMinWidth(100); + col.setMaxWidth(100); col.setResizable(false); col = getColumnModel().getColumn(0); @@ -123,6 +154,13 @@ public class VSEditorTable extends JTable { public void addVariable(String key, Component comp) { nodes.add(new VSNode(key, comp)); + } + + public void addSeparator(String text) { + nodes.add(new VSNode(text)); + } + + public void fireTableDataChanged() { model.fireTableDataChanged(); } } |
