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



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

Have Programming Question? Ask it here!
 
 
 


mohammed afsar
how can i draw a table using applet or swings
1 Answer(s)      5 years and a month 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 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 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 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 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 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 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 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 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 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
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 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
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
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
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 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
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
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
difference between applet and swings
difference between applet and swings  what are the major difference...-rectangular whereas Heavy weight components are rectangular 5) Swings... between Swing and Applet: 1)Swing is light weight component while applet
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???  How can change Button Label value Every Time when... not possible in Java otherwise in VB or NetBeans solu Sothat i can use only Method
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???  How can change Button Label value Every Time when... not possible in Java otherwise in VB or NetBeans solu Sothat i can use only Method
how to draw lines,circles, rectangles on JSP (using Java Graphics)
how to draw lines,circles, rectangles on JSP (using Java Graphics)  how to draw lines,circles, rectangles on JSP (using Java Graphics)   ... Polygon(); Random random = new Random(); for (int i=0; i < 5; i
How we can create a table through procedure ?
How we can create a table through procedure ?  How we can create a table through procedure
How can we repair a MySQL table?
How can we repair a MySQL table?  How can we repair a MySQL table
How to draw pie chart in J2ME
How to draw pie chart in J2ME  Hi, I'm developing a program using J2ME and I want to draw a pie chart but it seems J2ME language hasn't available chart component like JFreeChart in Java! could any one help me how can I draw a pie
Draw bufferimage in jpanel using netbeans
Draw bufferimage in jpanel using netbeans  please i need urgent help. i have form which contains some fields generated in netbeans. how can i draw bufferimage in Jpanel that is inside the form. thanks
how can i make monthly register ?
how can i make monthly register ?  how can i make monthly register ? iam using jdeveloper
i want to protect mysql database table which user can not view to table and can not copy my table till then us
i want to protect mysql database table which user can not view to table and can not copy my table till then us  i want to protect mysql database table which user can not view to table and can not copy my table till then user do
how can i remove newline characters and tabs
how can i remove newline characters and tabs   how can i remove newline characters and tabs ? but i wont to using GUI .please help
i want to protect mysql database table which user can not view to table and can not copy my table till then us
i want to protect mysql database table which user can not view to table and can not copy my table till then us  i want to protect mysql database table which user can not view to table and can not copy my table till then user do
how can i close a frame. - Java Beginners
how can i close a frame.  Hi, My question is how can we close...............my target is when i click on that button, a new frame is coming and updated table... frames as i go on clicking button...........can we have like when i click on button
how can i create a discussion forum?
how can i create a discussion forum?  how can i create a discussion forum for my e- mentoring site for women which can be used by a registered user only. i am using jsp and servlets and i am working with netbeans 6.8.
Image Movement using Swings
Image Movement using Swings  How to move image using Swings
how to run applet - Applet
how to run applet   Hi everybody i am using connecting jdbc in applet program. this is executed successfully with appletviewer command >... how can i execute in browser ? Thanks in advance thanks for seeing my
How can i modify my account in roseindia
How can i modify my account in roseindia  Presently am not using my gmail id. I have to modify my roseindia account. Please send the answer to following mail id
how i can get jqfade.js library
how i can get jqfade.js library  how i can get jqfade.j script library
how can i add hibernate plugin to eclipse?
how can i add hibernate plugin to eclipse?  how can i add hibernate plugin to eclipse
 

 

 

DMCA.com