Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how can i draw a table using applet or swings
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


mohammed afsar
how can i draw a table using applet or swings
1 Answer(s)      5 years and 3 months ago
Posted in : Java Beginners



Advertisement
View Answers

July 8, 2009 at 11:31 AM


Hi Friend,

Try the following code:

import java.awt.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;

public class CreateTable extends JFrame{
public static void main(String []args){

DefaultTableModel model = new DefaultTableModel();
JTable table = new JTable(model);

model.addColumn("Name");
model.addColumn("Age");
Scanner scan = new Scanner (System.in);

String [] st=new String[5];
for (int i=0; i<st.length; i++) {
String input = JOptionPane.showInputDialog("Enter Name");
st[i] = input;
}
int [] age = new int [5];
for (int i=0; i<age.length; i++) {
String input = JOptionPane.showInputDialog("Enter Age");
age[i] = Integer.parseInt(input);

}
for(int i=0;i<5;i++){
model.addRow(new Object[] { st[i],age[i] });
}

JFrame f = new JFrame();
f.setSize(300, 100);
f.add(new JScrollPane(table));
f.setVisible(true);

}
}

Hope that it will be helpful for you.

Thanks


Related Tutorials/Questions & Answers:
how can i draw a table using applet or swings - Java Beginners
how can i draw a table using applet or swings  Hi RoseIndia, Actually, I was trying for creating a table using applet or swings.......... My task is create a table and enter the integer values during run time......I have
How can i draw a line using java swings
How can i draw a line using java swings  Sir my program contains different components i am using JFrame. I want to draw a straight line between components(Jtextfeilds, Jlabels).So could you help me for it. Thank You
Advertisements
How can i draw a line using java swings
How can i draw a line using java swings  Sir my program contains different components i am using JFrame. I want to draw a straight line between components(Jtextfeilds, Jlabels).So could you help me for it. Thank You
how can i close particular frame in swings - Java Beginners
how can i close particular frame in swings  Hi, I want to know, how can we close a particular frame when mulitple frames are appearing as output... in swings and three frames are having their own close buttons and when i click
How can I paginate a table which has shown in a div through Ajax in client side without using database
How can I paginate a table which has shown in a div through Ajax in client side without using database   The table is shown by calculation in a PHP... the table
how can i draw line between two panel contaning circle and line between their center?
how can i draw line between two panel contaning circle and line between their center?   how can i draw line between two panel contaning circle and line between their center
how to store data in table using swings - Java Beginners
how to store data in table using swings  Hi, I am doing a project in which i need to store some data in the table using swings.......Iam using... , whether do i have any option in swings to increase my output look (my target
how to draw network(lines and nodes) in java - Applet
project. I want to know, how can we draw a network(with lines and nodes, any number of lines and nodes... say 5). I also want to know how can we draw a graph..."....... how can i solve this problem.......please tell me Thanks
how to drag top most images which is draw on applet.
how to drag top most images which is draw on applet.  Please help me, I have draw 83 images one by one from g.drawImages(,,,,); now I want to drag last image from 83 images and drop it suitable place, Now please help me , how can
how to display a table and buttons in swings - Java Beginners
how to display a table and buttons in swings  Hi frends, Actually i want to display a table during runtime and at the same time i also want to add different buttons below this displayed table using swings.....please can any
how can i store text box values as it is in database table
how can i store text box values as it is in database table  CUSTOMER DESCRIPTION
how can we store the encrypted passwaord in swings?
how can we store the encrypted passwaord in swings?   how can we store the encrypted passwaord in swings
how to draw a table on jframe in java - Java Beginners
how to draw a table on jframe in java  how to draw a table on jframe...", "MCA" } }; Object headers[] = { "Upper", "Lower" }; JTable table... scrollPane = new JScrollPane(table); JFrame frame = new JFrame
How can I execute a PHP script using command line?
How can I execute a PHP script using command line?  How can I execute a PHP script using command line
how can i achieve multiple inheritance in java without using inheritance ?
how can i achieve multiple inheritance in java without using inheritance ?  how can i achieve multiple inheritance in java without using inheritance
How i can send testing mail on my id using java?
How i can send testing mail on my id using java?  Which packages i should use to implementing java mail service??? Thanks
how to enter matrix data into a table of swings - Java Beginners
how to enter matrix data into a table of swings   Hi frends, I... and insert the data into that table using swings...........matrix can be anything... into table..not any this matrix, i should display any size of matrix... please help me
How can I generate diff image using Jmagick?
How can I generate diff image using Jmagick?  Hi, I used 'compare...: 2008.67 (0.0306503) all: 1536.39 (0.0234439) I am not able to do this using Jmagick. Can anybody help me get a diff image with similar metric using Jmagick
How i can send mail by using jsp.............. - JavaMail
How i can send mail by using JSP  Hi, will you please tell me how i can send mail by using jsp. Tell me in detail. Thanks!  Example and JSP... to create a send mail program using JSP.JSP Send Mail Program Resources:-http
How I can filling pdf file that crated by livecycle using itext
How I can filling pdf file that crated by livecycle using itext  I have pdf file that already done by livecycle.. I read it then I used...) How i can do
how to display a table and buttons in swings - Java Beginners
how to display a table and buttons in swings  Hi frends, Actually i want to display a table during runtime and at the same time i also want to add different buttons below this displayed table using swings.....please can any
how can i prevent duplicate records using servlets and MVC model?
how can i prevent duplicate records using servlets and MVC model?  hai, I need a program to insert values into database at the same time it shows error msg on response page while we are giving duplicate entry of a primary key.i
how to draw multilple circles in a circular form and connect them with lines - Java Beginners
how to draw multilple circles in a circular form and connect them with lines  Hi, Can anyone explains me , how to draw multiple circles using a single applet or swings in a circular form and connect them with lines. It should
Swings - Applet
Swings  Sir, I have developed an application in swings i want to call that class in applet. is it possible. or otherwise is there any way to deploy...) { if (str == null) return 0; int cnt = 0; for (int i = 0;; cnt
How can I access databse through JSP. I am using postgresql-8.4.4-1-windows as database and jboss-4.0.5.GA as server.
How can I access databse through JSP. I am using postgresql-8.4.4-1-windows as database and jboss-4.0.5.GA as server.  I am using postgresql-8.4.4-1... netbeans-6.1-ml-windows.How can I set up connection to database? Please help me
How to add dropdown list in a row of a sort table applet?
How to add dropdown list in a row of a sort table applet?  How to add dropdown list in a row of a sort table applet
User Registration Form Using JSP(JspBeans) after that how i can insert in database
User Registration Form Using JSP(JspBeans) after that how i can insert in database   User Registration Form Using JSP(JspBeans) after that how i can insert in database
How can I do it? .click();
How can I do it? .click();  I have a very unusual problem. I want...("a"); x.click(); </script> So it's click on an element witch one Id's is "a", but I want that it make mouseup in this element. How can I do it, because if I write
How can I learn Java?
How can I learn Java?  Hi, I have just completed a course in HTML and C programming language. I have some programming experience in visual basic... programming. How can I learn Java? in shortest possible time. I mean I just want to begin
Write a Java applet to draw cylinder and pentagon shapes.
Write a Java applet to draw cylinder and pentagon shapes.  Write a Java applet to draw cylinder and pentagon shapes
how should i can solve
how should i can solve  Web based program - Input - Person's contact details with Passport Number as Unique Key. Save data in to oracle / MySQL. Output - List of Persons saved in the database. Technology to be used - JSP
 

 

 

DMCA.com