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



Home Answers Viewqa Java-Beginners swing text field problem

Have Programming Question? Ask it here!
 
 
 


om
swing text field problem
0 Answer(s)      10 months ago
Posted in : Java Beginners


I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here is the code

import javax.swing.*;

import java.awt.event.*;

class Frame1 extends JFrame

{

private JButton btn1;

private JTextField tf1;
public Frame1()
{
    setLayout(null);
    setSize(500,500);
    tf1=new JTextField();
    tf1.setBounds(100,100,100,30);
    btn1=new JButton("click for second frame");
    btn1.setBounds(100,250,100,30);
    btn1.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e)
        {
            String text=tf1.getText();
            new Frame2(text);
        }
    });
add(tf1);
add(btn1);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public JTextField getTextField1()
{
    return tf1;
}

} class Frame2 extends JFrame { private JButton btn2; private JTextField tf2; private String secondtext; public Frame2() {

}
public Frame2(String firsttext)
{
    setLayout(null);
    setSize(500,500);
    tf2=new JTextField();
    tf2.setText(firsttext);
    secondtext=tf2.getText();
    tf2.setBounds(100,100,100,30);
    btn2=new JButton("click for first frame");
    btn2.setBounds(100,250,100,30);
    btn2.addActionListener(new MyActionListener());
    add(tf2);
    add(btn2);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
}
public JTextField getTextField2()
{

    return tf2;
}
public String getText()
{

    return secondtext;

}

} class MyActionListener extends Frame1 implements ActionListener { private String text; private JTextField tf1; private JTextField tf2; private Frame2 frame2; public MyActionListener() {

    super();
    frame2=new Frame2();
    text=frame2.getText();
    modify();
}
public void actionPerformed(ActionEvent e)
{
    new MyActionListener();
}
public void modify()
{
    tf1=super.getTextField1();
    tf2=frame2.getTextField2();
    tf1.setText(text);
}

}

class MyFrame
{

public static void main(String args[])

{

new Frame1();

} }


Advertisement
View Answers

Related Tutorials/Questions & Answers:
swing text field problem
swing text field problem  I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here
swing text field problem
swing text field problem  I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here
Advertisements
focus text field - Swing AWT
focus text field  i want to move cursor to next text field by pressing enter.i have created the following coding. but it does nt working.pls help...://www.roseindia.net/java/example/java/swing/ Thanks. Amardeep
focus text field - Swing AWT
focus text field  i want to move cursor to next text field by pressing enter.i have created the following coding. but it does nt working.pls help me.thanks in adv. package labwork; import java.awt.KeyboardFocusManager
text field
text field  How to retrieve data from text field   Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; class RetrieveDataFromTextFields{ public static void main
CALULATION IN TEXT FIELD
CALULATION IN TEXT FIELD  Suppose 3 text Field first amount ,second amount and third sum of these amount,this amount will appear when tab in next filed(i don't want use any type button) in java swing HOW? PLEASE HELP
converting field to text sql
converting field to text sql  I wanted to convert the field to TEXT in SQL.. is it possible?   SQL - Converting the field to TEXT works... the field to TEXT works SELECT CONVERT(TEXT,fld_name) FROM TABLE_NAME
jsf text field not blank
jsf text field not blank  text field not clear in jsf onclick of reset button in my application initial value not deleted   Hello Friend, Post your code. Thanks
validate text field iPhone
validate text field iPhone  i got two different UITextfield in my iPhone application for user login. Just wondering how to validate
Text field save as word file
Text field save as word file  Dear experts At run how to save set of text field contains text into single Word file. To save in our desktop computer. Solve my problem
Digit Only text field
Digit Only text field  How should we accept digits only in a textbox? (using JSTL only, without Javascript
iPhone Text Field Border 
Text Field Boarder  In this tutorial will learn about the text field Boarder, we can set the boarder of text field by selecting the text field... for the text field. This project is View Based Application and here will take four text
clearing text field in spring form
clearing text field in spring form  hi, I have spring form in that i have security question dropdown field and security answer text field ,when i submitted form with errors the answers text field value should be clear, for this i
rich text field - JSP-Servlet
rich text field  Hi, this is jawahar. my question i need rich text field in my program . plz send me the code
Swing Problem on submission of button
Swing Problem on submission of button  How to close current frame (Frame1) and open a new frame (Frame2) already created and pass the data to frame2 from frame1 on the clicking of button in swing
text field validation - Java Beginners
text field validation  hi How to validate allow only decimal number in text box in jsp?  Hi Friend, Try the following code: function isDecimal(str){ if(isNaN(str) || str.indexOf(".")<0){ alert
problem in swing-awt
problem in swing-awt  I am doing project in core java and i am facing one problem. I have to add command prompt(terminal) to the fream at bottom but not getting the solution. So please help me. thanks and regards, Aakash
Text Field in HTML
Text Field in HTML       The Text Field in HTML are one line areas, which enable the user... Text Field in HTML.In this Tutorial, the code create a text field in HTML page
jdbc and swing problem in netbeans
jdbc and swing problem in netbeans  i reteived the table from database in a jdbc program. next i want to do is place the table as it is in a jpanel.. i am using netbeans IDE can u tel me how to do that one?? urgent
jdbc and swing problem in netbeans
jdbc and swing problem in netbeans  i reteived the table from database in a jdbc program. next i want to do is place the table as it is in a jpanel.. i am using netbeans IDE can u tel me how to do that one?? urgent
Swing and AWT Problem - Swing AWT
Swing and AWT Problem  hi sir i have a problem i know from one Jframe we can send values to another Jframe. so in my project i have one fame containing three textfields CODE: String a=TNa.getText().toString(); String b
swing frame problem
swing frame problem  Hi All, I m creating a swing/awt based window application which will take some data from user and according to that data... a frame which have few buttons and Text Box to get some data from user at this time
tooltip problem - Swing AWT
tooltip problem  Hi All, I am using SWT_AWT bridge in my code to embed swing components into SWT Composite. I am using a Swing JButton in SWT Composite. My problem is that I am unable to see the tooltip for this button even
Can i insert image into struts text field
Can i insert image into struts text field  please tell me can i insert image into text field
regarding out put display in html text field
regarding out put display in html text field  how to dispaly the output coming from servlet in a particular text field of html
problem with JTable - Swing AWT
problem with JTable  hi guys, i was a student and i am very new to swings.i was having an assignment like i need to create a JTable with checkboxes inside it.i do have another checkbox outside the Table.i need to write
JSP combo and text field related questio
JSP combo and text field related questio  in JSP,i had stored data from database in a textboxes usin combo..now i want to use these values of text... and name given to that text field..but its showing somethimng null pointer exception
How to Define Text Field Validation iPhone
How to Define Text Field Validation iPhone  Hi, Can anybody explain me how to define textfield validation iPhone program. please phone online help reference or example. Thanks
Java Problem Steps - Swing AWT
Java Problem Steps  How to create a Jar File From the Dos prompt of a Swing program having two classes in the program with one is public class one of them
two text box problem
two text box problem  i have two text box in two different pages and same variable use in two text box when enter value in first text box it's reflection show in second text box , how i reduce it in jsf ?   Hi Friend
iPhone Text Field Validation
iPhone Text Field Validation In any user based application "... data from user. In this tutorial we are going to limiting the text field input...;. We have also take a Text field on the view to take the input from user
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table wth edit...;/td>"); the i am getting "rs.getString" in the text field also..  
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table as if i am... "rs.getString" in the text field also..   import java.awt.*; import
set text field appearance to default - Java Beginners
set text field appearance to default  hi, i am doing a program, in which i have a form for the user to input some data. i wanted to change the border color of a text box if the input was incorrect, but when i fail to set
retrive record from the text field and insert into to database
retrive record from the text field and insert into to database  the following code is inserting values in the my sql database but i want to insert... ServletException,IOException{ response.setContentType("text/html
Use of Text Field
Use of Text Field, Text box, Text Area, Checkbox,Dropdownlist and Radio... types of information. A form contains form elements checkbox, text field, radio...;/form> Text Fields: Text fields are used to allow
Multiple session problem - Swing AWT
Multiple session problem  I am working in a Linux based java swing application. Problem: I have optimized JDialog and JPanel for my use.... This problem is quite critical as UI looks quite unpredictable due
Text Field Midlet Example
Text Field MIDlet Example       This example illustrates how to insert text field in your form... the form with name and company field. The TextField
java swing problem - Java Beginners
java swing problem  i doesn't know about the panel in swings here i had created one frame then created a panel and i added that to my frame but which is not adding any item and it not showing that item on the panel tell me how
Jfree chart problem - Swing AWT
Jfree chart problem  hello i have a problem related to jfree chart i have some data and i want to display data in two different chart stacked area chart and line chart both in a single frame. That is hybrid combination
validating text fields - Swing AWT
validating text fields  hi i am using NETBEANS IDE so when i want to validate TEXTFEILDS if one textfield is blank then it should focus on that particular textfield so help me with this plz..... /* * To change this template
Java Swings problem - Swing AWT
Java Swings problem  Sir, I am facing a problem in JSplitPane. I want the divider in the splitpane to be customized. I have a splitpane with Horizontal orientation and here, there lies the divider between left component and right
Frame refresh problem - Swing AWT
to correct this problem....its urgent!! thnks in adv..  Hi Friend
Write an applet program to transfer the content of the text field into the component on clicking a button
Write an applet program to transfer the content of the text field into the component on clicking a button  Write an applet program to transfer the content of the text field into the component on clicking a button
Retrive data from databse to a text field - Java Server Faces Questions
Retrive data from databse to a text field  Hi, Can you give me a source code to rertrve data from Mysql databse to a text field using JSF.....by selecting option from a dropdown option
Fetched Record from database show into text field of html page
Fetched Record from database show into text field of html page  hi, i have a database with field merchant_code, merchant_name, city, region... in the text field of merchant name then suggest all merchant name in the form
Show text field & check input using jQuery
Show text field & check input using jQuery In this tutorial, we will discuss about how to display 'text field' by a button click & check... how to display 'text field' by a button click & check input using
javascript cal code for selecting date in text field - JSP-Servlet
javascript cal code for selecting date in text field  HI I want javascript calendar code to select date in text field in jsp.pls send me?  Hi Friend, Please visit the following links: http://www.roseindia.net
Can not input value into text field which use sx:datetimepicker
Can not input value into text field which use sx:datetimepicker  I am using lib: struts2-dojo-plugin-2.2.3.1.jar. My source is below: I input value from calendar, it runs normal. But i input value from keyboard by hands
File format validation and text field validation in java swings
File format validation and text field validation in java swings   i am reading a jpg image file throuh jfilechooser in java swings,when we press browse button for selecting file it will display filechooser in this process when
Advertisements
 

 

 

DMCA.com