Results 1 to 2 of 2
- 03-20-2012, 08:13 AM #1
Member
- Join Date
- Mar 2012
- Posts
- 3
- Rep Power
- 0
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)entityAndAddressList.ge t(i);
data[i][0]=entityAndAddress.getEntityId();
data[i][1]=entityAndAddress.getEntityType();
data[i][2]=entityAndAddress.getEntityType()+""+entityAndAddr ess.getEntityId();
}
table = new JTable(data, columnNames);
table.setPreferredScrollableViewportSize(new Dimension(1000, 1000));
table.setFillsViewportHeight(false);
if (DEBUG) {
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
printDebugData(table);
}
});
}
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
//Add the scroll pane to this panel.
add(scrollPane);
}
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));
}
System.out.println();
}
System.out.println("--------------------------");
}
/**
* 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
frame.setContentPane(newContentPane);
//Display the window.
// frame.setSize(300, 300);
frame.pack();
frame.setVisible(true);
}
}
================================================== ==========================================
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 ,
Suresh.
- 03-20-2012, 11:42 AM #2
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)
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Why won't this rectangle display in my JFrame?
By wikemol in forum New To JavaReplies: 1Last Post: 01-07-2012, 07:14 AM -
Second JFrame won't display as I intend
By elnbado in forum AWT / SwingReplies: 0Last Post: 03-08-2011, 12:45 PM -
can display image in JFrame?
By xCLARAx in forum AWT / SwingReplies: 14Last Post: 04-03-2009, 07:02 PM -
Unable to display JDialog from JFrame
By jv5 in forum NetBeansReplies: 2Last Post: 02-04-2009, 04:33 AM -
Display of tables and labels in the same pane
By Karanam in forum AWT / SwingReplies: 6Last Post: 10-20-2008, 08:34 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks