Home Answers Viewqa Java-Beginners how to display a table and buttons in swings

 
 


mohammed afsar
how to display a table and buttons in swings
1 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners

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 Pages:
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
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
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 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
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
Radio Buttons - Java Beginners
Radio Buttons  Hello Sir, How to create the code for the password recovery page(like forgot gmail password question and answer page)using the radion buttons in display the same page in jsp.I need only how to make the question
swings - Java Beginners
swings  i want to display a window while pressing a button .In that window i want to add images, by selecting the image it will display on the jpannel. how can i do this........  Hi Friend, Try the following code
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
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 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: http://roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks
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
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
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
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 the following code: import java.awt.*; import javax.swing.*; import java.awt.event.
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 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
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 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
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>
how to go from one frame to another frame in swings - Java Beginners
how to go from one frame to another frame in swings  Hi, My task... buttons on a frame........button names are ok and next........ when iam clicking next, it should open a new frame and display the output......... I should do
advanced repalcement for TableModel in java swings
result in JTable.Don't want to display hard coded data. we dont know how many..., Is there any advanced replacement for java TableModel.I want to display the search...[][] getTableData (JTable table) { DefaultTableModel dtm = (DefaultTableModel
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
JList in java swings - Java Beginners
JList in java swings  HI I am trying to create a JList of buttons. i want the display of buttons in horizontal direction. How can i do it ....its...(buttons); controlButtons.setLayoutOrientation(JList.VERTICAL_WRAP
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
Create Multiple Buttons
Create Multiple Buttons using Java Swing       In this section, you will learn how to create multiple buttons labeled with the letters from A to Z respectively. To display them, we
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 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 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
JSP & Swings
JSP & Swings  How to integrate jsp and swings
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
swings - Java Beginners
swings   how t upload images in swings. thanks   ...()); cp.add(new JScrollPane(list),BorderLayout.CENTER); JPanel buttons = new JPanel...); buttons.add(addButton); cp.add(buttons,BorderLayout.SOUTH); currentDir = new File
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
java-swings - Java Beginners
java-swings  How to write a program for JTree within a JTable cell in java swings.A table should be displayed when i click on the cell of the table. Please help. Thank u
how to create frame in swings
how to create frame in swings  how to create frame in swings
swings question
swings question  how to change the background color with the help of color values by using swings
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>
swings - Java Beginners
swings  i want to display a background pattern in mappannel, which... the background patterns, is there any inbuilt background patterns in java and how can i display it in a shape(polygon
swings - Java Beginners
swings  i created one jframe, in that i added ok button. i want to add some images with name in that frame .By selecting the image and press ok button it will display on the jpannel, how can i do
add Buttons in JavaScript
add Buttons in JavaScript  How to add Buttons in JavaScript
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
swings - Java Beginners
swings  hi friends, I am working in gis project. i want to display... will be appear above the specific point.I want to display the symbol at the center of the specific point. how can i get the center point of the character and how can
java swings - Java Beginners
java swings  Hi, I need the code for how can i set the joptionpane color(background and foreground). can i set the delay time for joptionpane display. Please send the code .its urgent. Thanks, Valarmathi
swings for webnms
swings for webnms  if i am expanding node of jtree then i want to collapse previous expanding node of jtree in swings how is it possible
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
javaa swings - IDE Questions
javaa 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... of that front end,if yes how? Jtable look n feel should be changed please

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.