Home Answers Viewqa Swing-AWT Regarding 2 windows

 
 


raveen
Regarding 2 windows
1 Answer(s)      a year and 9 months 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

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 Pages:
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
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 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 applets - Java Beginners
regarding applets  sir can you please tell how one applet can send request to another say i want to send some information   Hi friend..., dim.width-2, dim.height-2); for (int i = 0; i < NumLines; i++) { int x
regarding sending mesage - JavaMail
regarding sending mesage  i have tried the following program /* import java.util.*; import javax.mail.*; import javax.mail.internet.*; import... MimeMessage(session); ^ 2 errors */ please help
Open Source Windows
Open Source Windows       FireFox 2 The award-winning Web browser from Mozilla is now even...; Miro Beautiful interface. Plays any video type (much more than windows
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
Java for Windows
Java for Windows       First of all download jdk for windows and then install and configure the Java SE... and Installing J2SE Software on Windows Platform  To download J2SE for windows
Regarding method returns multiple values
Regarding method returns multiple values  Hi, 1)I have a requirement like,1 method returns multiple values.how to do that one. 2)can i use method, for example like getFile()[] in this way or not. plzzzzzzzzzzzzzzzzzz provide
regarding oops - Java Interview Questions
regarding oops  what is the differences between web server and application server?   Hi Friend, Difference between Web Server... of protocols. 2)Application server is more capable of dynamic behaviour than
jdbc warning regarding to ms access
jdbc warning regarding to ms access  shows warning msg while compiling using ms access : warning: sun.jdbc.odbc.JdbcOdbcDriver is Sun proprietary API...()) { System.out.println(rs.getInt(1)); System.out.println(rs.getString(2
regarding date field validation - Ajax
regarding date field validation  i have developed user information...} if (i==2) {this[i] = 29} } return this } function isDate(dtStr){ var... } if (strDay.length<1 || day<1 || day>31 || (month==2 && day>
How to Create User Account in Windows 8 with Windows live ID
If you have installed the latest version of operating system .i.e. Windows 8 on your PC and already have a Windows live ID, here, you will learn how to create an user account in Windows 9 using your windows live ID. 1. To start
How To Install Windows 8
In this tutorial we will discuss about how to install windows 8 on your computer. Microsoft has come up with the latest version of operating system Windows 8 and if you are willing to install the latest version of Windows 8 in your
Struts 2 problem - Struts
Struts 2 problem  Hello I have a very strange problem. I have an application that we developed in JAVA and the application works ok in Windows... seemed to worked fine, until the user reported to us a problem. After doing
Windows 8 Operating System
Windows 8 is the latest innovation, which has been launched to make easy handling of the Windows operating system. Launched by the Microsoft it is expected... available which teach you regarding the Window 8 quick guide that certainly enables
Windows 8 versus Android
Windows 8 has launched at a time when the much thrived smart phone and tab... the potential success of all the platforms and in talking of Windows 8 versus Android... android is a platform that almost swept majority of smart phone devices Windows phone
How to Create a Different User Account in Windows 8?
If you have already installed windows 8 on your computer but facing problem in creating a user account, here you are. In this windows 8 tutorial, we will discuss How to create a different user account in Windows 8? Once you install
System and Hardware Requirement for Windows 8
Microsoft has launched its new Windows 8 in the market, but most of the users are thinking is their computer, laptop or tablet enough to run Windows 8. Here... or tablet must have to run Windows 8: The Processor must be 1 Gigahertz (GHz
regarding ms acces database and servlet - JDBC
regarding ms acces database and servlet  hello there, i am trying...;Administrative Tool->Data Sources(ODBC) 2. Open User DSN tab 3. Add a user DSN 4...) + " " + rs.getString(2) + ""); } } catch (Exception e
How to Install WAMP Server on XP and Windows
How to Install WAMP Server on XP WAMP stands for Windows Apache MySQL PHP. WAMP Server is an open source software, which is free to use under the GPL licence... and download from there.   2. Download Wamp You can download wamp from
Regarding Gantt chart generation - Java Beginners
Regarding Gantt chart generation  how to generate a jdbc gantt chart using jfreechart api in netbeans simple java application?  Hi Friend...)))); schedule1.add(new Task("Testing", new SimpleTimePeriod(date(2
Need simple java code to start and stop the remote windows service.
Need simple java code to start and stop the remote windows service.  Hi, I Need simple java code to start and stop the remote windows service. Example:There are two servers 1) Server A and 2) Server B. If a notepad.exe file
Remote Desktop Setting in Windows 8
In windows 8 operating system you can easily access other computers inside.... To configure 'Remote Desktop Connection' on your Windows 8 installed PC, first of all....     2. Now, go to the 'Control Panel' from the Start menu
how to compare 2 arrays using java?
how to compare 2 arrays using java?  hi can anyone give me the information regarding comparision of arrays.   Java Compare Arrays
Proxy Setting in Windows 8 for IE
If you have installed Windows 8 in your computer and facing problem... computer.   2. Now, go to the 'Tools' option of the browser located... the Proxy settings on your computer and can use internet on your Windows 8
Network IP Setting in Windows 8
Another important thing to connect your Windows 8 installed PC to internet... Network IP in Windows 8 on your PC. 1. To access your Network IP setting... from the menu.   2. Once you click on the Network option, you
regarding rev
regarding rev  write a prog. in java that display all the arguments passed at the command line in reverse order
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 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
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am...; </form> </html> 2)pdfTable.jsp: <%@page import="java.io.*"%>... PdfPTable(2); table.addCell("Name"); table.addCell("Address
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am...; </form> </html> 2)pdfTable.jsp: <%@page import="java.io.*"%>... PdfPTable(2); table.addCell("Name"); table.addCell("Address
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am...; </form> </html> 2)pdfTable.jsp: <%@page import="java.io.*"%>... PdfPTable(2); table.addCell("Name"); table.addCell("Address
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am...; </form> </html> 2)pdfTable.jsp: <%@page import="java.io.*"%>... PdfPTable(2); table.addCell("Name"); table.addCell("Address
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am...; </form> </html> 2)pdfTable.jsp: <%@page import="java.io.*"%>... PdfPTable(2); table.addCell("Name"); table.addCell("Address
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am...; </form> </html> 2)pdfTable.jsp: <%@page import="java.io.*"%>... PdfPTable(2); table.addCell("Name"); table.addCell("Address
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am...; </form> </html> 2)pdfTable.jsp: <%@page import="java.io.*"%>... PdfPTable(2); table.addCell("Name"); table.addCell("Address
query regarding exporting table from jsp page to pdf
query regarding exporting table from jsp page to pdf  hello i am...; </form> </html> 2)pdfTable.jsp: <%@page import="java.io.*"%>... PdfPTable(2); table.addCell("Name"); table.addCell("Address
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 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 8 PC Setting Step by Step Guide
setting but with the introduction of Windows 8 by Microsoft, things are going be be little different now. Along with the control panel, Windows 8 introduces... to access PC setting in your Windows 8 operating system computer. Step 1
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  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
windows username - JSP-Servlet
windows username  how to reset the password and username of windows using jsp
Query regarding JSP, JDBC
Query regarding JSP, JDBC  can I get the code for the question asked by me regarding JSP,JDBC
regarding jdbc - JDBC
regarding jdbc  how i can configure java with ms access

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.