summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAudrius Meskauskas <audriusa@Bioinformatics.org>2006-02-15 08:50:57 +0000
committerAudrius Meskauskas <audriusa@Bioinformatics.org>2006-02-15 08:50:57 +0000
commita54cb3ba8cfeee78fd97bd2512cb9e72649a41be (patch)
tree4da3dc857c76fb63d0fd4844a15ba260f8bfd24d /examples
parentf83c2df882a379ce47a8babe3fabe9ece756c837 (diff)
downloadclasspath-a54cb3ba8cfeee78fd97bd2512cb9e72649a41be.tar.gz
2006-02-15 Audrius Meskauskas <AudriusA@Bioinformatics.org>
* examples/gnu/classpath/examples/swing/TableDemo.java (TModel, createContent): Explain which value appears in the header. * javax/swing/JTable.java (setColumnModel): Only set the column header value if the getHeaderValue() returns null.
Diffstat (limited to 'examples')
-rw-r--r--examples/gnu/classpath/examples/swing/TableDemo.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/examples/gnu/classpath/examples/swing/TableDemo.java b/examples/gnu/classpath/examples/swing/TableDemo.java
index d4a1a95fa..1fbf2de53 100644
--- a/examples/gnu/classpath/examples/swing/TableDemo.java
+++ b/examples/gnu/classpath/examples/swing/TableDemo.java
@@ -48,7 +48,6 @@ import javax.swing.JTable;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
-import javax.swing.table.TableColumnModel;
/**
* Displays the editable table. The first column consists of check boxes.
@@ -115,11 +114,13 @@ public class TableDemo extends JFrame
}
/**
- * The column name.
+ * The column name, as suggested by model. This header should not be
+ * visible, as it is overridden by setting the header name with
+ * {@link TableColumn#setHeaderValue} in {@link TableDemo#createContent}.
*/
public String getColumnName(int column)
{
- return "Demo "+column;
+ return "Error "+column;
}
/**
@@ -191,10 +192,16 @@ public class TableDemo extends JFrame
DefaultTableColumnModel cm = new DefaultTableColumnModel();
for (int i = 0; i < cols; i++)
{
- int w = 100+20*i;
TableColumn column = new TableColumn(i);
- column.setPreferredWidth(w);
+
+ // Showing the variable width columns.
+ int width = 100+20*i;
+ column.setPreferredWidth(width);
+
+ // If we do not set the header value here, the value, returned
+ // by model, is used.
column.setHeaderValue("Width +"+(20*i));
+
cm.addColumn(column);
}