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



Home Answers Viewqa Swing-AWT navigating the value of JTextField from one JFrame to another
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


neelam
navigating the value of JTextField from one JFrame to another
2 Answer(s)      4 years and 11 months ago
Posted in : Swing AWT



Advertisement
View Answers

November 25, 2009 at 12:04 PM


Hi Friend,

Try the following code:

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;

public class NavigateTextField extends JFrame{
JLabel label1,label2;
JTextField text1,text2;
JPanel panel;
JButton button;
public NavigateTextField(){
panel=new JPanel(new GridLayout(3,2));
label1=new JLabel("Name");
label2=new JLabel("Address");
text1=new JTextField(5);
text2=new JTextField(5);
button=new JButton("Detail");

try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root";, "root");
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("Select * from data");
String name="";
String address="";
if(rs.next()){
name=rs.getString(1);
address=rs.getString(2);
}
text1.setText(name);
text2.setText(address);
rs.close();
st.close();
}
catch(Exception e){}
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ev){
String value1=text1.getText();
String value2=text2.getText();
JLabel l1=new JLabel("Name= "+value1);
JLabel l2=new JLabel("Address= "+value2);
JPanel p=new JPanel();
p.add(l1);
p.add(l2);
JFrame f=new JFrame();
f.add(p);
f.pack();
f.setVisible(true);

}

});
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(button);
add(panel);
pack();
setVisible(true);
}
public static void main(String[]args){
NavigateTextField n=new NavigateTextField();
}
}

Thanks


November 25, 2009 at 1:33 PM


Hello
first of all thankyou very very much for your reply..
the code which you gave is working also..
but only first record is comming...
how can I fetch all the records from database using up and down keys of keyboard?
And also I wanted to know that the code which you have given me is to just copy an item ...but I want to retrive the new records from database using the the value of JForm1(JTextField of JForm1)..
can you plz help me regarding this...
I will be thankfull to you for this..
waiting for you reply
Regards
Neelam


Related Tutorials/Questions & Answers:
navigating the value of JTextField from one JFrame to another - Swing AWT
navigating the value of JTextField from one JFrame to another  hello I m doing one project where I m retriving the data from databse in JTextField... button all the details of an item of JTextField will be displayed in another
navigating the value of JTextField from one JFrame to another - Swing AWT
navigating the value of JTextField from one JFrame to another  Hello... to retrive the new records from database using the the value of JForm1... JFrame{ JLabel label1,label2; JTextField text1,text2; JPanel panel; JButton
Advertisements
Copy data from one JTextField to another JTextField
Copy data from one JTextField to another JTextField..., you will learn how to copy the data from one JTextField into another... and then paste into another JTextField. JTextField is used in the swing
passing data from one jframe to another
passing data from one jframe to another  I have two JFrame,built by using the GUI Editor netbeans 6.9.i have to pass a data from a Jtextfield in the first Jframe to another JLabel in the other JFrame.Can you please help me,how
Get JTextField value from another class
Get JTextField value from another class   ... value from other class. For this, we have created two classes ClassA.java and ClassB.java. In ClassA, we have defined a textbox 'text1' that will get the value from
Problem passing a value from one jsp to another using href
Problem passing a value from one jsp to another using href  first page.jsp <a href="common.jsp?param=<%l.get(k).parentname%>">...);%> since url print a common.jsp?param=Arts but attr return a null value
Problem passing a value from one jsp to another using href
Problem passing a value from one jsp to another using href  first page.jsp <a href="common.jsp?param=<%l.get(k).parentname%>">...);%> since url print a common.jsp?param=Arts but attr return a null value
passing textbox value from one page to another page using html n javascript
passing textbox value from one page to another page using html n javascript  on button onclick event pass text box value and i want to pass value...;/td> </tr> <tr> <td colspan=2><input type=submit value
calling one jsp from another jsp page
calling one jsp from another jsp page  need coding for calling one jsp from another jsp including the xml file.Its urgent
Return Value from One Form
Return Value from One Form  I have two buttons in main form client... is there.when i click dedupe button another form will open. i want to get a field value of dedupe form and use in bank form..how to do
how to open one Jframe from main method call
how to open one Jframe from main method call  I have downloaded...(is a JFrame) Rules.java(is a JFrame) PlayGame.java have three buttons Play - i... Rules.java Jframe should be opened Exit - exits the application Now what i want
File copy from one directory to another in java
File copy from one directory to another in java  I am trying to find very good code example for copying a file from one directory to another...? Is there any size issue while copying the file from one directory to another
how to go from one frame to another frame in swings - Java Beginners
how to go from one frame to another frame in swings  Hi, My task is to go from one frame to another.......... let us think that iam having two... JFrame{ JLabel label=new JLabel(); JTextField text=new JTextField(20); JPanel
update one table from another table
update one table from another table  hello, i need to update one table fields by using another table fields. I have to tables Products.... for example TotalQuantity field from Products table should be updated if i
how to pass a string from one class to another
string from one class to another. import java.util.*; class A{ static String... string from one class to another. import java.io.*; class Class1 { public...how to pass a string from one class to another  hi all, Good morning
How to navigate from one jsf to another in eclipse
How to navigate from one jsf to another in eclipse  Hi there is my...; <h:outputText value="USER DETAILS FORM"> </h:outputText> </b>... id="UserDetail"> <h:panelGrid columns="2"> <h:outputText value
How to forward the control from one jsp to another?
How to forward the control from one jsp to another?  Hi! This is Prasad Jandrajupalli. I have the 3 JSP's, but I want communicate with each... is not communicate with the Third JSP. I want forward the control from first jsp to second
copying data from one table to another
copying data from one table to another  i need to copy data from one table to another table.. i.e the 1st eid of employee table must be copied to the 1st eid in appusers table, 2nd eid of employee to the 2nd eid of appusers
to bring checked data from one page to another
to bring checked data from one page to another  thanks for your help... there is one jsp page , on it there is a link, on click of which it is opening second... fetching data from the database on second jsp page with checkbox corresponding each
how to write function of copy from one to another location in this code
how to write function of copy from one to another location in this code  I need to write a code to copy a file from one location to another using... class Browse extends JFrame implements ActionListener { JButton button1
get the value from another class - Java Beginners
get the value from another class  Hello to all, I have stupid question. I have main.java and ConfigXML.java(read my config xml file). Code from...)).getNodeValue().trim(); from my ConfigXML.java in main.java. Sorry for my bad
How to return a string from a JTextField
How to return a string from a JTextField  Hi, Am new to java, and am trying to get a string from a JTextField so that I can compare it with another... { public static void main(String[] args) { JFrame f=new JFrame
How To Pass data from one GUI to another in java swing
How To Pass data from one GUI to another in java swing  I'm new to java and part of our assignment is to build a GUI and display a result set from data input. I'm stuck at how to get the user's input from JTextFields and combobox
swings:how to link from one form to another form
swings:how to link from one form to another form  how to link from one form to another form
how to copy file from one directory to another in java with examples
how to copy file from one directory to another in java with examples  how to copy file from one directory to another in java with examples? I want... copy from one directory to another in java. Thanks
How to pass variable from one class to another in java
How to pass variable from one class to another in java  How to pass variable from one class to another in java?   Example: public class...); System.out.println("Another Class variables value:" + class1.getIdNo
calling one jap page from another jsp page
calling one jap page from another jsp page  i created a button in one jsp page i need to call another jsp page as an action to that button. so how can i call.. plz any one explain. its urgent
Pass cookie from one site to another within the same domain
Pass cookie from one site to another within the same domain  Hi, I want to pass a cookie from one website to another within the same domain. This is just to identify whether the same user is logged in or not. Can anyone help me
File copy from one drive to another. - Java Beginners
File copy from one drive to another.  I want to copy a .mp3 file from one drive(let d: drive)to another drive(let e: drive) in my Windows XP. How can I do
how to pass an array from one jsp to another jsp - JSP-Servlet
how to pass an array from one jsp to another jsp  hi friedns, can any One tell me how to send an array from one jsp to another jsp,pls any one send the code for this.also porvid the code how to retrive the arry in another jsp
problem in sending data from one ip to another ip in JAVA
problem in sending data from one ip to another ip in JAVA  Hi guys . this is naveen kumar...i need a help. i want to connect one ip to another ip (like ping),after that i want send the data with my system(Ip) to another ip
 

 

 

DMCA.com