java - How do I remove the A on the top of the JTable inside a JScrollPane? -
why there on top of table?
i placed jtable within jscrollpane create scrollable. there methods need place? did not place letter though cant track.
import java.awt.eventqueue; import javax.swing.jframe; import javax.swing.jpanel; import java.awt.borderlayout; import javax.swing.boxlayout; import javax.swing.jtable; import javax.swing.border.lineborder; import java.awt.color; import javax.swing.jscrollpane; import javax.swing.scrollpaneconstants; public class rawr { private jframe frame; private jscrollpane scrollpane; private jtable table; /** * launch application. */ public static void main(string[] args) { eventqueue.invokelater(new runnable() { public void run() { seek { rawr window = new rawr(); window.frame.setvisible(true); } grab (exception e) { e.printstacktrace(); } } }); } /** * create application. */ public rawr() { initialize(); } /** * initialize contents of frame. */ private void initialize() { frame = new jframe(); frame.setbounds(100, 100, 450, 300); frame.setdefaultcloseoperation(jframe.exit_on_close); jpanel panel = new jpanel(); frame.getcontentpane().add(panel, borderlayout.center); panel.setlayout(new boxlayout(panel, boxlayout.y_axis)); scrollpane = new jscrollpane(); scrollpane.settooltiptext(""); scrollpane.sethorizontalscrollbarpolicy(scrollpaneconstants.horizontal_scrollbar_never); panel.add(scrollpane); table = new jtable(100, 1); table.setborder(new lineborder(new color(0, 0, 0))); scrollpane.setviewportview(table); } } how remove it? thanks!
set column name explicitly using:
string[] colnames = new string[]{"your column name"}; defaulttablemodel defaulttablemodel = new defaulttablemodel(colnames, 100); table = new jtable(defaulttablemodel); if create table using new jtable(100, 1) see a, b , on column headers because constructor javadoc says:
constructs jtable numrows , numcolumns of empty cells using defaulttablemodel.
since jtable constructor not have info column headers. can create defaulttablemodel not know column header names. defaulttablemodel extends abstracttablemodel , javadoc of abstracttablemodel.getcolumnname() says
returns default name column using spreadsheet conventions: a, b, c, ... z, aa, ab, etc. if column cannot found, returns empty string.
java swing user-interface jtable jscrollpane
No comments:
Post a Comment