Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-27-2008, 03:10 PM
Member
 
Join Date: Jan 2008
Posts: 23
abhiN is on a distinguished road
Passing data from one JFrame to another
Hi

I am developing an application in which i want to pass the data from one JFrame to another..

Actually what i want is like--

On my first frame i m displaying a blank JTable(Table1)..
Now when i click on the first row from the table1 it'll generate new frame containing a JTable(table2) with the values from the database..

Now i want to pass the values from the table2 to table1 dynamically.. means when i double click on any row from table2, all data from that row will be added to 1st row in table1..

weather it is possible to pass the data in such a manner or is there any another way to pass data from one frame to another..

plz reply..
thanks..
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-27-2008, 05:16 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,144
hardwired is on a distinguished road
There may be a lot of ways to put something like this together. In general it is better to have only one JFrame and to use JDialogs for additional top–level containers.
Code:
class Frame1 JTable table Frame1() { table.addMouselistener(listener); show table in frame } private MouseListener listener = new MouseAdapter() { public void mousePressed(MouseEvent e) { Point p = e.getPoint int row = table.rowAtPoint(p); int col = table.columnAtPoint(p); openDialog(row, col); } }; private void openDialog(int row, int col) { JTable localTable = new JTable localTable.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if(e.getClickCount == 2) { int row = localTable.getRowAtPoint(e.getPoint()) collect row data from localTable set data in table } } )); populate table with data base data for row/col show table in JDialog/JFrame } }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-28-2008, 06:39 AM
Member
 
Join Date: Jan 2008
Posts: 23
abhiN is on a distinguished road
Thanks hardwired for reply.

According to ur code it'll generate the table with values from DB by clicking on row in table1, but how do I get the values from the database table(table2) to my current table(table1).

I want to get the entire row from the table2,on which user will double click to be get added to table1...
weather it is possible??

plz reply..
thanks..
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JNI - passing and returning parameters by value java_to_c New To Java 0 01-31-2008 09:49 PM
passing data dynamically abhiN Advanced Java 1 01-22-2008 10:43 AM
passing dynamic data abhiN Web Frameworks 0 01-17-2008 02:16 PM
Passing a value.. Lagarto New To Java 0 08-01-2007 05:32 PM
Passing the Values Lagarto Database 1 07-16-2007 04:03 AM


All times are GMT +3. The time now is 08:10 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org