Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Paul Clapham
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Saloon Keepers:
Tim Holloway
Carey Brown
Roland Mueller
Piet Souris
Bartenders:
Forum:
Swing / AWT / SWT
How to change Jtable Total Rows in runtime ?
raminaa niilian
Ranch Hand
Posts: 551
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thank you for reading my post
How i can change number of rows in a JTable at runtime ?
for example if it has 4 rows in when i made the table and i
want it to has 20 rows in some case
what property of Jtable give the bility to me ?
Michael Dunn
Ranch Hand
Posts: 4632
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
here's a basic way
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; class Testing extends JFrame { String colNames[] = {"Column 1", "Column 2", "Column 3"}; DefaultTableModel dtm = new DefaultTableModel(null,colNames); public Testing() { setLocation(200,100); setDefaultCloseOperation(EXIT_ON_CLOSE); JTable table = new JTable(dtm); JScrollPane sp = new JScrollPane(table); JPanel panel = new JPanel(new BorderLayout()); panel.add(sp,BorderLayout.CENTER); JPanel btnPanel = new JPanel(); JButton btn = new JButton("Add 10 Rows"); btnPanel.add(btn); panel.add(btnPanel,BorderLayout.SOUTH); getContentPane().add(panel); pack(); btn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ for(int x = 0; x < 10; x++) { dtm.addRow(new String[3]); }}}); } public static void main (String[] args){new Testing().setVisible(true);} }
raminaa niilian
Ranch Hand
Posts: 551
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
Thank you very much.
it helped too much , and now i havemy table , without out of bound exception.
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
JTable
JTable
JTable
refreshing a JTable
JTable(!!!)
More...