| | |
Drawing A Table On A Container(Panel)
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2004
Posts: 9
Reputation:
Solved Threads: 0
/*Hello everybody out there!,
I found out that JTable class of the swing package allows one to draw a table on a container.It's as simple as creating the object of the class and passing two arguments into its construct,the first being number of rows and the second the number of columns.Then you go on ahead to add the object on to the container.(panel)
something like this...*/
import javax.swing. *;
class DrawTable
{
static JPanel panel;
static JTable table;
static JFrame frame;
public static void main(String args[])
{
panel=new JPanel();
table=new JTable(4,6);
panel.add(table);
frame = new JFrame("Table");
frame.getContentPane().add(panel);
frame. setSize(230,230);
frame.setVisible(true);
}
}
/*Now here's my problem.
How can I go about inserting values into the table?
Also,can I increase the size(width and height) of the cells?,
Is there any other thing I could do with this table apart fro inserting values and increasing its size?
I'll quite appreciate your contributions.Thanks */
I found out that JTable class of the swing package allows one to draw a table on a container.It's as simple as creating the object of the class and passing two arguments into its construct,the first being number of rows and the second the number of columns.Then you go on ahead to add the object on to the container.(panel)
something like this...*/
import javax.swing. *;
class DrawTable
{
static JPanel panel;
static JTable table;
static JFrame frame;
public static void main(String args[])
{
panel=new JPanel();
table=new JTable(4,6);
panel.add(table);
frame = new JFrame("Table");
frame.getContentPane().add(panel);
frame. setSize(230,230);
frame.setVisible(true);
}
}
/*Now here's my problem.
How can I go about inserting values into the table?
Also,can I increase the size(width and height) of the cells?,
Is there any other thing I could do with this table apart fro inserting values and increasing its size?
I'll quite appreciate your contributions.Thanks */
![]() |
Similar Threads
- help me with inserting table at runtime in panel (ASP.NET)
- How to add table layout panel at runtime (C#)
- Taking Values from another form to Table layout panel ("How?") (VB.NET)
- Table Layout Pannels (C#)
Other Threads in the Java Forum
- Previous Thread: 37049
- Next Thread: class designs in java-air traffic controller system--need help!!
Views: 9421 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Java
911 addball android api append apple applet application arguments array arrays automation binary bluetooth button chat class classes client code component css csv database detection draw eclipse ee error event exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me java javaprojects jmf jni jpanel julia jvm key linux list loan loop map method methods mobile netbeans newbie number object oracle os output packets phone print problem program programming project recursion reporting robot scanner screen se server service set size sms socket software sort sql stream string swing test threads time transfer tree ubuntu windows wrong






