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



Home Answers Viewqa Swing-AWT Regarding 2 windows
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


raveen
Regarding 2 windows
1 Answer(s)      3 years and a month ago
Posted in : Swing AWT


Hi, I want 2 separate windows,when i click on a 1st window submit btn then it will show 2nd window. In 2nd window i want 1 textbox.i entered some text on that text box and when i close the 2nd window then the text in textbox displayed in 1st window test field.plzzzzz provide the code in swings.

Thanks in advance


Advertisement
View Answers

August 24, 2011 at 5:55 PM


1)Frame1.java:

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

public class Frame1{
  public static void main(String[] args){
    Frame1 sr = new Frame1("");
  }

  public Frame1(String st){
    final JFrame frame = new JFrame("Frame1");
    frame.setLayout(null);
    JTextField text=new JTextField(20);
    text.setText(st);
    JButton b = new JButton("Submit");
    b.setBounds(20,20,80,20);
    text.setBounds(20,50,100,20);
    frame.add(b);
    frame.add(text);
    frame.setSize(400,200);
    frame.setVisible(true);

    b.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent e){
      Frame2 f=new Frame2();
      frame.setVisible(false);
      f.setVisible(true);
      f.setSize(300,100);
      }
    });
  }
}

2)Frame2.java:

import javax.swing.*;
import java.awt.event.*;
class Frame2 extends JFrame
{
    Frame2()
    {
    setTitle("Frame2");
    JLabel lab=new JLabel("Enter text: ");
    final JTextField text=new JTextField(20);
    JButton b=new JButton("Click");
    setLayout(null);
    lab.setBounds(10,10,150,20);
    text.setBounds(170,10,100,20);
    b.setBounds(10,40,100,20);
    add(lab);
    add(text);
    add(b);
    setVisible(true);
    setSize(400,200);
    b.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
        setVisible(false);
        new Frame1(text.getText());
        }
    });
    }
}


Related Tutorials/Questions & Answers:
Regarding 2 windows
Regarding 2 windows  Hi, I want 2 separate windows,when i click on a 1st window submit btn then it will show 2nd window. In 2nd window i want 1 textbox.i entered some text on that text box and when i close the 2nd window
regarding struts 2
regarding struts 2   is it not possible to get values from applicationresources.properties into our application in struts 2
Advertisements
Regarding Documentation of Packages
Regarding Documentation of Packages  Hello How to get java packages ie documentation of classes ,Interfaces and methods from windows command prompt.In the sense Java.lang,java.awt,java.math etc
Regarding repository
Regarding repository  How to check in and check out using SVN repository using eclipse
regarding rev
regarding rev  write a prog. in java that display all the arguments passed at the command line in reverse order
Regarding Project
Regarding Project  sir, i am doing a project in java. my project is CITY GUIDE it is an web application. please give me documentation of my project
Regarding Project
Regarding Project  sir, i am doing a project in java. my project is CITY GUIDE it is an web application. please give me documentation of my project
Regarding Hibernate
Regarding Hibernate  Both JDBC and Hibernate are used to connect to database then whats the need of going to hibernate? What are the main differences? And could you let me know please
Regarding Documentation of API
Regarding Documentation of API  Hello How to get java documentation of classes ,Interfaces and methods from windows command prompt.In the sense.... How to type in Windows command prompt(console) to get the documentation API
Regarding Documentation of API
Regarding Documentation of API  Hello How to get java documentation of classes ,Interfaces and methods from windows command prompt.In the sense... in Windows command prompt(console) to get the documentation API.   Give
Regarding javascript
Regarding javascript  Hi, I want 4 upload buttons in HTML CODE and Among 4 browse buttons user is not selected any one then provide a prompt message like plz select any 1 file among 4 buttons.If user is selected either 1st
regarding jtable...
regarding jtable...  sir, im working with jtables. i wanted to populate a jtable from the database and when i click any row it should add a container below that row itself and show the required details of the row
Regarding Datasource
Regarding Datasource  Hi friend, Good morning,how r u,i want to share 1 information to u,I got a job in VERIZON DATA SERVICES INDIA PVT.LTD,u help a lot when i am in academic project,with that project only i got a job
windows username - JSP-Servlet
windows username  how to reset the password and username of windows using jsp
regarding project
regarding project  OBJECTIVES OF THIS PROJECT: -Ability to test the programmer for basic interaction skills to understand the client requirement. -Ability of the programmer to ask the right questions and get the relevant
regarding project
regarding project  OBJECTIVES OF THIS PROJECT: -Ability to test the programmer for basic interaction skills to understand the client requirement. -Ability of the programmer to ask the right questions and get
regarding project
regarding project   sir we need help about project. we have idea about his project please guide me sir. OBJECTIVES OF THIS PROJECT: -Ability to test the programmer for basic interaction skills to understand the client
Running Jar file in Windows
Running Jar file in Windows  Running Jar file in Windows
Query regarding JSP, JDBC
Query regarding JSP, JDBC  can I get the code for the question asked by me regarding JSP,JDBC
Windows File Protection
Windows File Protection  I would like to know if there is any way to place a file or folder under windows protection such that it can't be deleted, or in generel if there is a way to prevent a file or folder from being deleted
MongoDB uninstall windows service
MongoDB uninstall windows service  Hi, Previously I installed... from windows service. Can any one tell me How to uninstall the MongoDB from windows server? Thanks   Hi, You can remove the MongoBD service using
regarding jdbc - JDBC
regarding jdbc  how i can configure java with ms access
windows authentication with hibernate - Hibernate
windows authentication with hibernate  Does anyone know how to setup a datasource for SQL Server that uses Windows authentication instead of SQL Server mixed mood authentication? Is it possible with hibernate framwork? Thanks
links open new windows
links open new windows  Why do my links open new windows rather than update an existing frame
problem regarding tomcat server 6.0
problem regarding tomcat server 6.0  Jul 27, 2012 10:39:19 PM... Foundation\Tomcat 6.0\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDO WS\system32;C:\WINDOWS;C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\WINDO WS\system32;C:\WINDOWS;C
wifi et windows
wifi et windows  est ce qu'on peut capturer les trames d'un reseau wifi sous windows?? et merci pour la reponse
Regarding weblogic portal
Regarding weblogic portal  Hi, My name is Ramanuja.i am working on weblogic portal.if u know any info regarding plz provide the materials or information to me.plz help me. Thanks in advance
Regarding project - Applet
Regarding project  hi friend , iam doing project in Visual cryptography in Java so i need the Help regarding how to make a share of a original imahe into shares anu
Windows 7 refresh DNS
Windows 7 refresh DNS  Windows 7 refresh DNS How to refresh DNS in Window 7/Windows and linux? Thanks   Hi, In windows it is very easy to refresh the DNS. go to the command prompt (dos prompt) and then issue
creating windows service - RMI
creating windows service  Hi, I have created a project using spring RMI and have some server.jar file which contians all the classes of server and server.exe file which is used to start the server. But I want to create a windows
Regarding core java
Regarding core java  how do we find reverse of string with out using String functions
 

 

 

DMCA.com