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



Home Answers Viewqa Java-Beginners opening new window
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


vandana
opening new window
1 Answer(s)      5 years and 3 months ago
Posted in : Java Beginners



Advertisement
View Answers

July 18, 2009 at 11:25 AM


Hi Friend,

Try the following code:

1)'A.java'

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

public class A{
JTextField text;
JLabel label;
JPanel panel;
JButton button;
JFrame frame;
public A(){
frame=new JFrame();
panel=new JPanel(new GridLayout(2,2));
text=new JTextField();
label=new JLabel("Enter Name:");
button=new JButton("SUBMIT");
panel.add(label);
panel.add(text);
panel.add(button);
frame.add(panel,BorderLayout.CENTER);

button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value=text.getText();
B page=new B();
page.setVisible(true);
JLabel label = new JLabel("Welcome:"+value);
page.getContentPane().add(label);
frame.disable();
}
});
frame.setSize(300,100);
frame.setVisible(true);
}
public static void main(String arg[])
{


A ab=new A();
}

}

2) 'B.java'

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

class B extends JFrame
{
B()
{
setDefaultCloseOperation(javax.swing.
WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Welcome");
setSize(300, 100);
}
}

Thanks


Related Tutorials/Questions & Answers:
opening new window - Java Beginners
opening new window  Hi All, I have two classes with me , lets say... window.i.e., I want to know, how a new window(B) can be opened by clicking a button on the first(parent)window.The show() method does open a new window
JAVA SCRIPT CODE FOR OPENING A WEBSITE IN A NEW WINDOW - Java Beginners
JAVA SCRIPT CODE FOR OPENING A WEBSITE IN A NEW WINDOW   PLS... DATA, IT MUST OPEN A WEB SITE IN A NEW WINDOW. SPECIFICATION:MAKING ONLY "1... in solving the problem : JavaScript Window Open function poponload
Advertisements
Opening a new window in Echo3
Opening a new window in Echo3   ... will create a new Window. To create this example we have created two class files... of an application. Here we have created a new Window by constructing the object
Java - Opening a url in new window from an applet
Java - Opening a url in new window from an applet       This is the example of opening a url from.... When you click the button "google", new browser window will open
Java - Opening a url in new window from an applet
Java - Opening a url in new window from an applet  ... will open new browser window and then show you the web page. Opening a new... how to open a new window from an applet. You can use the code given
opening new browser with new JSESSIONID using java
opening new browser with new JSESSIONID using java  I am facing... one IE browser and manually. And i ran my LaunchURL.java file, it is opening new.... I have to open a new browser window with new JSESSIONID. Here is my code
JavaScript Open link in new window
JavaScript Open link in new window...; In this section, you will learn how to open a new window on clicking the link using JavaScript.  To open a new window with a link within the web
how to focus on the new window opened from JSF ?
how to focus on the new window opened from JSF ?  Hi guys, I have commandLink with action which using javascript to open a new window(window.open()). Problem is, the new window opens at background behind the current window
Opening a URL from an Applet
Opening a URL from an Applet       Introduction This is the example of opening a url in same window from an applet. This program shows that how a url is opened in same
Code for opening a new mail from the default mail box and copy the database contents
Code for opening a new mail from the default mail box and copy the database contents  Guys, here is how it goes when i click on a button say "mail... respectively be fetched ,and my default mail should be opened and a new mail
Java - Opening a URL from an Applet
;    - show in a new, top-level window "string"... Java - Opening a URL from an Applet       This is the example of opening a url in same
Window
Window  how to create an window of a person like regestration form
JSP Window. Open
;       JSP Window. Open  is used to open a new window in JSP. The JavaScript function  window.open( ) open a new browser...','window name','attribute1, attribute2') : The method allows you to open a new
changes in netbeans/ browser so that each application run opens in a new window of browser
changes in netbeans/ browser so that each application run opens in a new window of browser  hieeee... I want to change netbeans setting. So that each time i run an application it opens up in a new window rather than a new tab
Opening Notepad
Opening Notepad  Sir/madam I want to open notepad from java applications and save the contents on it. Can someone please help me to do this. With Regards Vaishnavi Vishwanath   To open the notepad, just go through
datetime picker is not opening
in this date time picker is not opening. The same opens in JSP code. My code... variables var winCal; var dtToday=new Date(); var Cal; var docCal; var MonthName... of calendar window. var cnLeft="500";//left coordinate of calendar window var
new
new    hi i am jane pls explain the difference between string greeting = good morning string greeting = new string ("good morning
new
new  hi the difference between string sname = good morning string sname =new("good morning
new
new    hi i am jane pls explain the difference between heap memory and stack memory
Multi window
contains all the details. when i submit this page, a new window opens and asks to enter password. if password entered is correct, the flow goes to previous window
new
new   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html
window in center
window in center  if i run the programme thw window is in lie in top left corner i want a window open in center
Opening a browser only with body from a java program
Opening a browser only with body from a java program  Hi all, I got following requirement, Opening a browser window only with body and title bar. And based on some condition, after some time, i have to close the browser window
Window Blind
Window Blind  Custom built . Over 30 years of shutter experience. Free in-home consultations
Chat window
the chat window pops up.. It is a div in the chat homepage.. There are few other... in the same application. I want to know how to retain the chat window (along..., the chat window should be constant across all pages in the application for current
IllegalStateException for file opening
){ } File requiredFile = new File(strabsoluteFileName... { OutputStream os = response.getOutputStream(); FileInputStream fis = new... File</th></tr> <% File f = new File("C:/UploadedFiles"); File
IllegalStateException for file opening
){ } File requiredFile = new File(strabsoluteFileName... { OutputStream os = response.getOutputStream(); FileInputStream fis = new... File</th></tr> <% File f = new File("C:/UploadedFiles"); File
window closing
window closing  hello, In my project i have login,logout and some jsp pages are there and each jsp page is using javascript and onunload script. and i need one solution that,when ever user trying to close browser window
Window Script
Window Script  i want to write windows script can you help me in writing those i want to write script so that it follows below steps Step 1) downloading file from FTP 2) Unzip it 3) Edit it 4) zip it 5) upload again to FTP
opening node in treeview struts layout - Struts
opening node in treeview struts layout  Example of opening node in treeview struts layoutopening node in treeview struts layout Hello every one, i am new to this group , i am having the same problem , Struts Layout tree view
"opening video data error" in j2me
"opening video data error" in j2me  Any one know about the error c When i am trying to play video on spice device its throw an exception, but the same code work on other devices very well please tell me the issue behind
Advertisements
 

 

 

DMCA.com