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



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


B Nagendra Reddy
Adding JTable into existing Jframe.
0 Answer(s)      2 years 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.


Advertisement
View Answers

Related Tutorials/Questions & Answers:
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
Advertisements
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
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
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
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 djile pak.java
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
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
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
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
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
JTable  need to add values to a JTable having 4 coloumns ,2 of them are comboboxes
JTable
JTable  Hello, i cannot display data from my table in the database to the cells of my JTable. please help me
jtable
jtable  how to get the values from database into jtable and also add a checkbox into it and then when selected the checkbox it should again insert into database the selected chewckbox.plzz help
jtable
jtable  hi Sir i am working netbeans IDE,I have a jtable when i insert values in jtable then i am unable to print all inserted values,For eg if i insert 1,2,3,4,5,6,7,8 values then , i am getting output
jtable
jtable  hey i have build a form and i m also able to add data from database to jtable along with checkbox.the only problem is that if i select multiple checkboxes the data doesnt get inserted into new database and if only one
Refresh JFrame
Refresh JFrame  How to refersh a JFrame and its componets
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
Hiding a JFrame
javax.swing.*; import java.awt.event.*; class PassData extends JFrame { JTextField... java.awt.*; import java.awt.event.*; class NextPage extends JFrame { NextPage
Hiding a JFrame
javax.swing.*; import java.awt.event.*; class PassData extends JFrame { JTextField... java.awt.*; import java.awt.event.*; class NextPage extends JFrame { NextPage
Adding an employee
Adding an employee  coding for adding an employee
how to reset JFrame
how to reset JFrame  how to reset JFrame
 

 

 

DMCA.com