Results 1 to 2 of 2
  1. #1
    ynglsuresh is offline Member
    Join Date
    Mar 2012
    Rep Power

    Default How to display two tables using Jframe?

    Hi I am able to display one table using JFrame. i want to display one more table below the table which i displayed now.

    can any one help me on this..

    here is the sample code

    ================================================== ============
    public class UIMA_Result extends JPanel{

    private boolean DEBUG = false;
    int first=0;
    JTable table;

    public UIMA_Result(ArrayList<EntityTO> entityAndAddressList)

    String[] columnNames = {"Entity","EntityType","Address"};

    Object [][]data=new Object[entityAndAddressList.size()][3];

    /*for(EntityAndAddressTO entityAndAddress:entityAndAddressList)

    for(int i=0;i<entityAndAddressList.size();i++)
    EntityTO entityAndAddress=(EntityTO) t(i);
    data[i][2]=entityAndAddress.getEntityType()+""+entityAndAddr ess.getEntityId();


    table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(1000, 1000));

    if (DEBUG) {
    table.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.


    private void printDebugData(JTable table) {
    int numRows = table.getRowCount();
    int numCols = table.getColumnCount();
    javax.swing.table.TableModel model = table.getModel();

    System.out.println("Value of data: ");
    for (int i=0; i < numRows; i++) {
    System.out.print(" row " + i + ":");
    for (int j=0; j < numCols; j++) {
    System.out.print(" " + model.getValueAt(i, j));

    * Create the GUI and show it. For thread safety,
    * this method should be invoked from the
    * event-dispatching thread.
    public static void createAndShowGUI(ArrayList<EntityTO> entityAndAddressList) {
    //Create and set up the window.
    JFrame frame = new JFrame("Mindteck UIMA");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);

    //Create and set up the content pane.
    UIMA_Result newContentPane = new UIMA_Result(entityAndAddressList);
    newContentPane.setOpaque(true); //content panes must be opaque

    //Display the window.
    // frame.setSize(300, 300);

    ================================================== ==========================================
    In this case am passing arraylist and displying the list values in the table.. i want to display the one more table below of this table

    can any one help me on this

    Thanks ,

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: How to display two tables using Jframe?

    1. Scout around the FAQs section of the site and learn how to use code tags so that posted code retains its formatting.
    2. Use an appropriate layout manager and add as many components as you want: Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Why won't this rectangle display in my JFrame?
    By wikemol in forum New To Java
    Replies: 1
    Last Post: 01-07-2012, 07:14 AM
  2. Second JFrame won't display as I intend
    By elnbado in forum AWT / Swing
    Replies: 0
    Last Post: 03-08-2011, 12:45 PM
  3. can display image in JFrame?
    By xCLARAx in forum AWT / Swing
    Replies: 14
    Last Post: 04-03-2009, 07:02 PM
  4. Unable to display JDialog from JFrame
    By jv5 in forum NetBeans
    Replies: 2
    Last Post: 02-04-2009, 04:33 AM
  5. Display of tables and labels in the same pane
    By Karanam in forum AWT / Swing
    Replies: 6
    Last Post: 10-20-2008, 08:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts