how to display a table and buttons in swings

how to display a table and buttons in swings

View Answers

July 14, 2009 at 11:13 AM

Hi Friend,

Try the following code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class Form extends JFrame
{
JButton ADD;
JPanel panel;
JLabel label1,label2;
final JTextField text1,text2;
Form()
{
label1 = new JLabel();
label1.setText("Name:");
text1 = new JTextField(20);

label2 = new JLabel();
label2.setText("Address:");
text2 = new JTextField(20);

ADD=new JButton("ADD");

panel=new JPanel(new GridLayout(3,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(ADD);
add(panel,BorderLayout.CENTER);
setTitle("FORM");

ADD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value1=text1.getText();
String value2=text2.getText();
Object rowData[][] = { { value1, value2} };
Object columnNames[] = { "Name", "Address"};
JTable table = new JTable(rowData,columnNames);
JScrollPane scrollPane = new JScrollPane(table);
JButton button1=new JButton("Add");
JButton button2=new JButton("Delete");
JPanel pan=new JPanel();
pan.add(scrollPane);
pan.add(button1);
pan.add(button2);
JFrame tab=new JFrame();
tab.setVisible(true);
tab.add(pan, BorderLayout.CENTER);
tab.setSize(500,100);
}
});
}
}
class TableAndButton
{
public static void main(String arg[])
{
try
{
Form frame=new Form();
frame.setSize(300,100);
frame.setVisible(true);
}
catch(Exception e)
{}
}
}

Thanks









Related Tutorials/Questions & Answers:
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
Advertisements
how to use stringtokenizer on table? and display in table format.
display result in row format  how to use stringtokenizer on table? and display in table format
how to use stringtokenizer on table? and display in table format.
how to use stringtokenizer on table? and display in table format.  table is retrieved from mysql database and each row contains data like(java,c,c++,.net
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 want to display a matrix data into a particular table...... Actually if the user... and insert the data into that table using swings...........matrix can be anything
Display data from xml file to Swings - Swing AWT
Display data from xml file to Swings  Hi, We are Preparing a stand alone application. Where the Swings is the front end. There will be only... clicking the buttons in swings it has to display 20 record in one shot in table
how to display a table from database using servlet
how to display a table from database using servlet  how to display a table with values from servletpage   Hi Friend, Please go through the following link:ADS_TO_REPLACE_1 http://roseindia.net/jsp/servlet-jsp-data
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 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 display data in List Or grid or in table in Jsp
how to display data in List Or grid or in table in Jsp   <%@page...(); } %> </body> </html> this is my jsp code i want to display String P Value in List GIrd or Table please help am able to Print display data
How to Display values from databse into table
How to Display values from databse into table  I want to display values from database into table based on condition in query, how to display that? For example i have some number of books in database but i want to display books
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... the table with that textfield values... The thing is it will be having multiple
how to display values from database into table using jsp
how to display values from database into table using jsp  I want to display values from database into table based on condition in query, how to display that? For example i have some number of books in database but i want
How To Display MS Access Table into Swing JTable - Java Beginners
How To Display MS Access Table into Swing JTable  How to Display...){ System.out.println(e); } JTable table = new JTable(data, columnNames); TableColumn... JScrollPane( table ); p.add( scrollPane ); JFrame f=new JFrame(); f.add(p
Display items in table
Display items in table  I have a listbox which has some items... in a table. I want these items to be displayed in the table to be unique...i.e. if I reselect those same items they should not be displayed in the table and may
how to display the selected row from the data table in model panel ??
how to display the selected row from the data table in model panel ??  the below displayed is my datatable:tableDatas.xhtml <rich:dataTable value="#{tableRecordBean.dataList}" var="dataItems" onRowClick="#{rich
how to display data from mysql table in text box using jsp??
how to display data from mysql table in text box using jsp??  <p>hi, i have a written a code to display data from a mysql table into txtboxes... the secified table. rs = statement.executeQuery(QueryString); </code>
how to create frame in swings
how to create frame in swings  how to create frame in swings
Display Label and radio buttons runtime with respect to DB values
Display Label and radio buttons runtime with respect to DB values  Requirement: I am getting alertCondition,Y,W values from DB the the cooresponding.... how can we populate the values at front end? Which layout is better one? How
display:table export only data
display:table export only data  I am using display:table tag with attribute export="true". Using that I can export table data in excel. Here one of the column is in hyper link. But i need to export only data not html tag . Can
display of colors in a table - JSP-Servlet
display of colors in a table  Hi, If i have a table of 4 by 4 boxes, numbering from 1-16 in sequence, how do i make them display one column of one color and another column of another color? Thanks!  Hi Friend
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.
How to display data fom MySQL DataBase-table in to JSP file by submitting... DataBase/DB Name:lokesh; Table Name:TR_list; columns:nodename,packageno,TR... have to display the Nodename and packageno. i.e.,select nodename,packageno from
How to display all the rows in JSP ,MySQL select condition statement IN dept_table
How to display all the rows in JSP ,MySQL select condition statement IN dept_table  I iam unable to display all the rows in JSP select statement from... is displayed.@select * from department where dept_no=10;My display code in JSP
How to display all the Select values from the MySQL database table in where condition= In JSP?
How to display all the Select values from the MySQL database table in where... to display all the select values from MySQL DB** only first value is displayed in the jsp file. @select * from table dept where dept_no=10;" jsp code i have used
how to upload and download images using buttons in jsp?
how to upload and download images using buttons in jsp?  how to upload and download images using buttons in jsp
swings
swings  i have a JFrame, in that i want to display tabs and want to have common buttons for all that tabs, and this buttons should be placed at bottom of the JFrame. Please post me the answer Thanking You
Buttons
Buttons  I have created a web page with radio button group with two radio buttons for accepting the home appliances categories,Kitchen appliances and other appliances.I want to check for the appliance chosen when the required
How can combine threads and buttons?
How can combine threads and buttons?  I would like to start an application, stop it and restart it again and stop etc. I tried the following code... TestActionEvent(); frame.setTitle("Two buttons
how to display?
how to display?  How to write a select query for displaying data where i have author as multivalued attribute
how to display?
how to display?  How to write a select query for displaying data where i have author as multivalued attribute
how to display?
how to display?  How to write a select query for displaying data where i have author as multivalued attribute
Html form using JavaScript to display the table content
Html form using JavaScript to display the table content  HI... want to write a Html JavaScript coding to display the content from database. can you teach me how and give me the code for that? Regards Karthik M
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
display table details when selecting table name in drop down liat
display table details when selecting table name in drop down liat  ... database to the dropdownlist in jsp. Example: 1st i want to display the list of tables from the database to the dropdown list... if i select the particular table
Display table performing action on another table
Display table performing action on another table In this section, we have created two tables. The data in table 1 have shown as a result of the database. We have retrieved the values from the database and display
display data from a table in Access Database in a HTML page
display data from a table in Access Database in a HTML page  how to display data from a table in Access Database in a HTML page in a Java Program
how to display?
how to display?  I have to write a code for searcing books in library...:8080/examples/jsp/searchbook.jsp" method="post"> <table align="center"> <...;search.jsp</strong> <body> <table border=2> <tr> <th>
SWINGS
SWINGS  WHAT ARE THE DIFFERENCES BETWEEN AWT AND SWINGS
How to create form in Swings
How to create form in Swings  How to create registration, login and question form in Java Swing?   Creating different forms in Java Swing - Examples how to create registration form in swing swing login form example
how can i close particular frame in swings - Java Beginners
in swings and three frames are having their own close buttons and when i click...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
How to create XML from Swings
How to create XML from Swings  How to create XML using Swings. I have a Swing GUI and capturing all data from it.When i click on submit, an xml... components and display it in xml file. import java.io.*; import java.util.*; import
HOW TO DISPLAY TABLEEEE
HOW TO DISPLAY TABLEEEE  Please teach me how to display table step by step like a kid who didnt know anything? please !! I try so many times but it is not working out ! S.O.S !!! HELP ME PLEASEEEE
How to create dynamic buttons for adding products on a cart.
How to create dynamic buttons for adding products on a cart.  Hi. I... dynamic products from a database, and i would like to know how to group this products... the top content--> <div id="top"> <table width="70
Swings/awt - Swing AWT
Swings/awt  Hi, how to write action listeners to the Buttons in RichTextEditor tool bar.. thanks in advance...it's Urgent... i am very much new to Swings
how to add audio clip in swings with event handling
how to add audio clip in swings with event handling  hello dear, i wanna to play audio clip in java program in JFrame in swings by event handling... how it can be done...... thanks alot
filter and display html table data using ajax - Ajax
filter and display html table data using ajax  Hi i am stuck up... to DisplayCategory.jsp i want to display the data retrieved from the session in a 2d array on DisplayCategory.jsp in the form of the html table using responseText. how to do
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 to display the current time
How to display the current time  I was develop online web portal. In this web portal i am going to display time. I am using <%= new java.util.Date() %> to display the time. But it display the time after that cannot changed
how to display records from database
how to display records from database  I want to display records from database in tables, the database is having 2000 records and i want to display 20 records at a time and to use next and previous link buttons to show
how to display image with listview
how to display image with listview  How can i display the list view with the related images from database

Ads