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

 
 


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

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 Pages:
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
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 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
swings
swings  how to disable the labels.i am using the setenable(false) method to disable the label, but still mouse events(mouse clicked) are working on that label, how can i deactivate the mouse events also on the label
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 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 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 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 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 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 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
swings
swings  My program contains more one JComboBoxes how can i selectitems in my program. Please answer me my id raja.chaya@gmail.com
swings
swings  Thank you deepak it is fine.... I think you have gone through mine sent code in that i am not able add that Textfield dynamically. Can youhelp me how can i add textfields dynamically in my code lookin forward to hear
Swings and JDBC
Swings and JDBC  Hi.. I am vinay.. I am developing a small application using swings and mysql. I am sending part of the code here.. The problem is i... created JTextfields... but i am not getting how i can fetch those particular
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
java swings - Swing AWT
java swings  I am doing a project for my company. I need a to show the performance of the employees by using bar bharts. Please give me how can we write the code for bar charts using java swings.  Hi friend, I am
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 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
Draw Line
Draw Line  sir i want to draw a moving line in j2me.That line should also show arrow in moving direction. How can we do so
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
Beans in Swings table
Beans in Swings table  Hi Sir/Madam.... I am Trying Develop an Swing from which include an table which displays the data from mysql table and i am adding one Jtextfield in each row in the last column and i want to update
swings - Java Beginners
of the specific point. how can i get the center point of the character and how can... a character/string at a specific point.For this i am using drawstring method , this is a inbuilt method in java, while using this method i am facing a small
Java draw triangle draw method?
Java draw triangle draw method?  hi how would i construct the draw method for an triangle using the 'public void draw (graphics g ) method? im unsure how to use the g.fillPolygon and g.drawPolygon? i have this for drawing
applet - Applet
applet   how to draw textboxes using applets  Hi Friend...*; import java.awt.*; public class CreateTextBox extends Applet implements.../applet/ Thanks
problem with applet plugin - Applet
-->com.ezsoft.applets.Upload.java please friends how can i resolve that problem...problem with applet plugin  hello friends, iam using Eclipse IDE. i created one applet and i want to plugin that applet into webpage.. when i am
applet question
applet question  sir please tell me that how can i call an event on clicking on applet window without using any component
how to connect swings with jdbc... - Java Beginners
how to connect swings with jdbc...  Hi friends, Is it possible, to connect swings with data base like oracle....i want to store data into database... by using servlets and jsp but is it possible by using swings........ for data base
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
java swings
java swings  Hi, I have one class file using three panel methods,the three methods is used for three tabs.then how can i set the background image.Please send the sample code for me. I already posted two questions,but i didnt get
java swings - IDE Questions
java swings  I'm developing a java desktop database application using NetBeans 6.5 and using mysql as database,When I create the table and link with my program it automatically gives the front end;can I change the look and feel
javaa swings - IDE Questions
using NetBeans 6.5 and using mysql as database,When I create the table and link with my program it automatically gives the front end;can I change the look and feel of that front end,if yes how? Jtable look n feel should be changed please
core java - Applet
core java   Namaste sir , how can draw a line in Applet. I want when...(MouseEvent evt) { } } Then call this applet with html file 'applet.html'. Draw Line using mouse Thanks    The applet name
Applet
Applet  Draw the class hierarchy of an Applet class. Also explain how to set background and forground colors in java
How to draw a television
How to draw a television Try to draw a television... Shape: First draw a Rectangle shape with black color by using Rectangle tool (U... by the Rectangle tool (U key) as I have done here. Inner Shadow: Go to Layer Menu
applet connected to table in MS Access database
applet connected to table in MS Access database   i have connected my java code with the MS access database and this is my code, can anyone tell me how to show the table in an applet...pls import java.sql.
applet problem - Applet
applet problem  How can I create a file in client side by a java applet . Surely it will need a signed applet .But how can a signed applet create a file in the client side
how to record qvga video using j2me - Applet
how to record qvga video using j2me  hello if it is possible how i can record qvga video usin j2me
core java - Applet
core java  how can draw rectangle in applet. when i pressed in mouse button the rectangle's size will also increase
swings
swings  i have 20 labels in mappanel ,if i click on the one label ,how to know which one is selected in this...  Hi Friend, Try...*; class ActionOnLabel extends JFrame{ int i=0; static JPanel panel; public
swings
swings  i have a string1 it contains 3 parts,for example "123456... this. and the string3 should contain "123456 +(second string) hello" "second string can be dynamic data whatever we give from string2,that should be displayed on the screen. i
applet images sleeping programme - Applet
applet images sleeping programme  Dear Sir,         I shall be much tankful to you, if u can kindly give me the programe for    In a Applet how... java.applet.Applet; import java.util.Random; public class AppletSleep extends Applet
how can i hide and show tables
how can i hide and show tables  hai, i am creating a form which the code is included below i want to hide the tables initially and after i click go... which is having a table consists of database data and a Go button. Using
How can i search and insert within a query
How can i search and insert within a query  if it is possible..., terminal) in another table. i am trying these but not successful, A problem occur... in mysql through text fields. i am using batch,semester and degree onchange
Servlet and Applet - Applet
Invoke and run an Applet from Servlet  How can i invoke and run an applet from servlet. Can anyone provide me the sample code
how to record qvga video using j2me - Applet
how to record qvga video using j2me  hello if it is possible how i can record qvga video usin j2me?   Hi Friend, Please visit the following links: http://www.roseindia.net/j2me/video-midlet.shtml http
java - Applet
java  How can i develop an expert system using applets? can you help me with some sample source code
Applet JSP communication - Applet
Applet JSP communication  Hi.. I've an application where i need to get the data from the applet to JSP... How can i do this..?? can anyone explain with a sample code
creating hyperlinks in applet - Applet
creating hyperlinks in applet  Dear sir, how can i move from one applet to another applet and how can i use previous applet input data in anotherapplet(just like session tracking) thanks
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