java--form Defaulttable

Source: Internet
Author: User
Tags rowcount

int rowcount=200;
int columncount=5;

DefaultTableModel Defaulttablemodel=null;

Defaulttablemodel=new DefaultTableModel (Rowcount,columncount);
Defaulttablemodel.setvalueat ("AA", 0,0);
Defaulttablemodel.setvalueat ("BB", 0, 1);
Defaulttablemodel.setvalueat ("CC", 0,2);
Defaulttablemodel.setvalueat ("DD", 0, 3);
Defaulttablemodel.setvalueat ("EE", 0,4);

Jtable=new jtable (DefaultTableModel);
Jtable.setpreferredscrollableviewportsize (New Dimension (400,80));
Jscrollpane_right=new JScrollPane (jtable);
Jscrollpane_right.setborder (Borderfactory.createtitledborder ("Machine Summary"));

This mode: Displays the table when it is opened by default, and displays the column name.

Add the data later and use the setValueAt function as well.

The above method has a slightly problematic title:

int rowcount=200;
int columncount=5;
JTable Jtable=null;
DefaultTableModel defaulttablemodel=new DefaultTableModel (rowcount,columncount);
DefaultTableModel defaulttablemodel=new DefaultTableModel ();//set to empty here
Defaulttablemodel.addcolumn ("MM1");//Set caption individually
Defaulttablemodel.addcolumn ("MM2");
Defaulttablemodel.addcolumn ("MM3");
Defaulttablemodel.addcolumn ("MM4");
Defaulttablemodel.addcolumn ("MM4");
Defaulttablemodel.setcolumncount (ColumnCount);//Set the number of rows and columns individually
Defaulttablemodel.setrowcount (RowCount);

The method of adding element values is the same ~ ~

java--form Defaulttable

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.