Home Answers Viewqa Java-Beginners Adding JTable into existing Jframe.

 
 


B Nagendra Reddy
Adding JTable into existing Jframe.
0 Answer(s)      6 months and 3 days ago
Posted in : Java Beginners

i need to add JTable into this code pls help me..

package Com; import Com.Details; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;

import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JDesktopPane; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JTextField; @SuppressWarnings("serial") public class AddPage extends JFrame {

JDesktopPane pane = new JDesktopPane();
static Details details= new Details();

JTextField searcharea;

String str;

{ setLayout(null);

     setTitle("Employee Details Application");

 JButton add=new JButton("ADD NEW");
 JButton edit=new JButton("EDIT");
 JButton delete=new JButton("DELETE");
 JButton save=new JButton("SAVE");
 JButton cancel=new JButton("CANCEL");
 JButton close=new JButton("CLOSE");
 JButton print=new JButton("PRINT");


 add.setBounds(10,40,100,40);
 edit.setBounds(120,40,100,40);
 delete.setBounds(240,40,100,40);
 save.setBounds(360,40,100,40);
 cancel.setBounds(480,40,100,40);
 close.setBounds(600,40,100,40);
 print.setBounds(720,40,100,40);

 add(add);
 add(edit);
 add(save);
 add(delete);
 add(cancel);
 add(close);
 add(print);

 String[] search={"--search by--","Employee_ID","Employee Name"};
    final JComboBox box=new JComboBox(search);
    box.setBounds(10,120,100,25);
    add(box);
 searcharea=new JTextField();
     searcharea.setBounds(130,120,150,25);

     add(searcharea);
     JButton submit=new JButton("SUB");
     submit.setBounds(300,125,80, 20);
     add(submit);

details.setBounds(100,60,1300,600);

    add(pane);

//Action Listener for button //for adding new details
add.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e)
            {
                AddPage addpage=new AddPage();
                addpage.add(details);
                //EmployeeMain empmain=new EmployeeMain();
                //empmain.main(null);

            }
        });   

/*for editing previous details   
     edit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e)
            {
                AddPage addpage=new AddPage();
                addpage.add(details);
                System.out.println("edit carefully");
            }
        });     */
     //for saving 
save.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e)
            {
                details.insert();
           //EmployeeMain empmain=new EmployeeMain();
           //empmain.main(null);
          System.out.println("saved successfully");
            }

        });     
//action area for search area.
submit.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {
    String selecteditem=(String) box.getSelectedItem();
    if(selecteditem=="Employee_ID"){
        Employee employee=new Employee();
        String emp=searcharea.getText();
        AddPage addpage=new AddPage();
        addpage.add(details);
        details.setEmpID(emp);

    }

    else if(selecteditem=="Employee Name"){
        Employee employee=new Employee();
        String emp=searcharea.getText();
        AddPage addpage=new AddPage();
        addpage.add(details);
        details.setEmpName(emp);
    }
    }
});

    //end action listener
     //table addition

setVisible(true); setSize(1250,1000);

} public static void main(String[] args) { new AddPage(); //addpage.add(details); // addpage.add(table);

} }

Thanks in advance.

View Answers









Related Pages:
Adding JTable into existing Jframe.
Adding JTable into existing Jframe.  i need to add JTable...("serial") public class AddPage extends JFrame { JDesktopPane pane = new...(100,60,1300,600); add(pane); //Action Listener for button //for adding new
Adding JTable into existing Jframe.
Adding JTable into existing Jframe.  i need to add JTable...("serial") public class AddPage extends JFrame { JDesktopPane pane = new...(100,60,1300,600); add(pane); //Action Listener for button //for adding new
Adding JTable into existing Jframe.
Adding JTable into existing Jframe.  i need to add JTable...("serial") public class AddPage extends JFrame { JDesktopPane pane = new...(100,60,1300,600); add(pane); //Action Listener for button //for adding new
How to refresh a jTable On adding or deleting record ....
How to refresh a jTable On adding or deleting record ....   Hii Sir, I am developing a project in which a jtable is getting populated... from same panel and i want jtable to be refreshed after every addition
Java: Adding Row in JTable
Java: Adding Row in JTable   how about if we already have the JTAble created earlier. And i just found nothing to get its DefaultTableModel, thus, I can't call insertRow() method. Is there any work around for this? I found
jtable-adding a row dynamically
jtable-adding a row dynamically  hi..i am doing a project for pharmacy .. *pblm:* when i want to enter the details in jtable while running the application there are 3 rows and 4 columns which is default bt when we we have
Adding A Primary Key to an Existing Table
Adding A Primary Key to an Existing Table   Been trying to add a primary key to a MySQL table using Java for two days with no success. I'm new to Java and JDBC so bear patience with me. It connects to the database without problem
JTable
JTable  Hi I have problems in setting values to a cell in Jtable which is in a jFrame which implements TableModelListener which has a abstract method tableChanged(TableModelEvent e) . I'll be loading values from data base when
JTable
); JFrame f = new JFrame(); f.getContentPane().add(p...; data[0][9]=codigopostal; data[0][10]=pais; JFrame frame=new JFrame(); String labels[]={"Nome","Apelido","Nome do meio","Telefone
JTable populate with resultset.
JTable populate with resultset.  How to diplay data of resultset using JTable?   JTable is component of java swing toolkit. JTable class is helpful in displaying data in tabular format. You can also edit data. JTable
adding data to the database with the use of jtable - Java Beginners
adding data to the database with the use of jtable  how can i add data to the database with the use of jtable. and also can able to view the records in the database in the table.. tnx :G
adding data to the database with the use of jtable - Java Beginners
adding data to the database with the use of jtable  how can i add data to the database with the use of jtable. and also can able to view the records in the database in the table.. tnx :G
how update JTable after adding a row into database
how update JTable after adding a row into database  J have two... in JTable, and it's OK, but after adding a row into database table does't update. How update JTable after adding a row into database? package djilepak.javaclss.for
Adding text in to text area of jframe at new line with different background colour
Adding text in to text area of jframe at new line with different background colour  Hi, I am reading text from text file and i want to write... colour. it is possible in text area of jframe
adding mouse listeners to drop target
adding mouse listeners to drop target  import java.awt.*; import... JFrame { private static ActionListener actionListener; public static void main(String[] args) { new JPanels(); } public JPanels() { JFrame frame
Appending a Column in JTable
in JTable. For adding a new column in JTable component you have to need a table model... Appending a Column in JTable     ... of program: In this program, we will see how to add (append) a new column in JTable
Inserting a Column in JTable
. After adding a column, the JTable will contain 4 columns. The new column of ... Inserting a Column in JTable     ... to insert a column in JTable at a specified location. As, you have learnt in previous
JFrame
JFrame  write an application with a JFrame that five labels describing reasons that a customer might not buy your product(for example "Too expensive") every time the user clicks a Jbutton, remove one of the negative reasons
jframe
jframe  Create a JFrame for the Summervale Resort. Allow the user to view the information about different rooms available, dining options and activities offered. Include at least two options in each menu and display appropriate
JFrame
Jframe. How can i do it. Please help me to do it. Or what else can i have
REPORT WITH JTABLE
JTableDatabase extends JFrame{ ResultSet rs; JTableDatabase(){ final...(Exception e){} JTable table = new JTable(data, columnNames); JScrollPane scrollPane
JTable - JDBC
{ JFrame f; JPanel p; JLabel l; JTextField tf; JButton btn; JTable tb...JTable   Hello..... I have Jtable with four rows and columns and i have also entered some records in MsSql database. i want to increase Jtable's
add XMl to JTable
add XMl to JTable  Hi.. i saw the program of adding add XMl to JTable using DOM parser,but i need to do that in JAXB ,is it possible to do? help me
Adding checkbox to List as item
Adding checkbox to List as item   can we add checkox to List   Hi Friend, Try the following code: import java.awt.*; import javax.swing.... main(String args[]) { JFrame frame = new JFrame
JTable - Swing AWT
*; public class JTableToConsole extends JFrame { public Object GetData(JTable...JTable  Hi Deepak, i want to display the Jtable data... how could i show jtable data on the console. Thanks, Prashant   Hi
adding the delete code
adding the delete code  hello sir... i need to add a delete button... java.util.Scanner; import javax.swing.*; public class DisplayInfo extends JFrame... bar to JFrame setJMenuBar(menuBar); //Add listener to all menu items
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 = new JTable(rows, headers); table.setTableHeader(null); JScrollPane
Jmagick how to add image on an existing image
Jmagick how to add image on an existing image  hi, I am using...) on an existing image. can any one explains how ? Thanks.   hi, In Jmagick you can use the following code to add image on an existing image You can give one
problem with JTable - Swing AWT
to swings.i was having an assignment like i need to create a JTable... an action event such that if i check the checkbox outside the JTable,all the checkboxes inside the JTable should be checked. details: for creating JTable
problem in adding a fullscreen frame nd adding a glass pane to it
problem in adding a fullscreen frame nd adding a glass pane to it  hi , here is my code import java.awt.*; import javax.swing.*; import java.awt.ToolKit; class MyFrame extends Jframe{ Container c; JPanel glass; MyFrame
Connecting JTable to database - JDBC
(){ JFrame frame = new JFrame("Getting Cell Values in JTable"); JPanel...Connecting JTable to database  Hi.. I am doing a project on Project... to store this JTable content in my database table.. This is a very important
java swing (jtable)
java swing (jtable)  hii..how to get values of a particular record in jtable from ms access database using java swing in netbeans..?? please help... from database and display it in jtable. import java.awt.*; import java.sql.
How to delete and update from Jtable cell in swing app
How to delete and update from Jtable cell in swing app  Hii Sir, I am developing a swing app for adding,updating and deleting from jtable... is getting removed from the jtable but selected row is getting deleted from
jtable combo - Java Beginners
jtable combo  i am using jtable (using defaulttablemodel) ,when i am click on a particular cell of jtable i want to display the combo box...(String[] args) { JFrame f=new JFrame(); f.setLayout(new BorderLayout
Jtable Question - Java Beginners
Jtable Question  Hello Sir, I have Created Database in MS access 2007 ,I want show the table data in to Swing JTable, How I can Show it, plz Help...(); stmt.close(); } catch(Exception e){ System.out.println(e); } JTable table = new
JTable - Java Beginners
JTable  Hi, I have some problem with JTable. On show All button hit.... my problem is with Jtable, sometimes it is visible and sometimes it is not. when... { JFrame f; SpringLayout sl; JTabbedPane tp; JPanel p; JButton showbutton
JTable
JTable  Values to be displayed in JTextfield when Clicked on JTable Cells
JTable
JTable  i want to delete record from JTable using a MenuItem DELETE. and values of JTable are fetched from database....please reply soon
JTable
JTable   how to select a definite cell which containing a similar text containg to the one which the user entering from a jtable at runtime in java
search filter and JTable
my question is: how can i make search data in JTable of java? i wan to search records in table or textfield but the data display in JTable. Note: i dont...); p.add(t); p.add(b); JFrame f = new JFrame
update a JTable - Java Beginners
update a JTable   i have tried your advice as how to update a JTable...*; import java.awt.event.*; public class data extends JFrame {public static void main(String args[]) { JTable table; Connection con = null
JTable values are not gettiing properly
JTable values are not gettiing properly  Sir, I created one JTable...*; public class sd25 extends JFrame implements ActionListener { //3 month table details JTable table=null; JScrollPane js=null; Container cp=null; JPanel p=null
JTable
JTable  need to add values to a JTable having 4 coloumns ,2 of them are comboboxes
JTable - Java Beginners
want my JTable on the panel. and i also want to increase height and width...; class jsk implements ActionListener { JFrame f; SpringLayout sl; JTabbedPane... JFrame("Testing JSK SDMPL"); p=new JPanel();p.setBackground(Color.black
JTable - Java Beginners
implements ActionListener { JFrame f; SpringLayout sl; JTabbedPane tp; JPanel p; JButton showbutton; JScrollPane sp; jsk() { f=new JFrame...(); stat3.close(); JTable table = new JTable(data, columnNames
jTable data problem
(){ JFrame frame=new JFrame(); JTable table=new JTable(rftl); JPanel panel...jTable data problem  Hello. I have a code that read file and store in arraylist and then convert to array(To use for table model) My class extends
adding of two numbers in designing of frame
adding of two numbers in designing of frame  hello sir, now i'm... SumOfNumbers{ public static void main(String[] args){ JFrame f=new JFrame(); JLabel label1=new JLabel("First Number: "); JLabel label2=new
JTable
JTable  Hello, i cannot display data from my table in the database to the cells of my JTable. please help me
adding background image - Java Beginners
adding background image  how do i add background image to this code...*; public class sampleProg extends JFrame { JButton button = new JButton ("Result...(); JFrame frame = new JFrame(); public sampleProg (String str){ super(str

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.