how to go from one frame to another frame in swings

how to go from one frame to another frame in swings

View Answers

July 9, 2009 at 10:46 AM

Hi Friend,

Try the following code:

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

public class MoveFrame extends JFrame{
JLabel label=new JLabel();
JTextField text=new JTextField(20);
JPanel panel=new JPanel(new GridLayout(2,2));
JButton button1 =new JButton("OK");
JButton button2 =new JButton("Next");

public MoveFrame(){
label.setText("Enter Name:");
panel.add(label);
panel.add(text);
panel.add(button1);
panel.add(button2);
add(panel,BorderLayout.CENTER);
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
JOptionPane.showConfirmDialog(null, "Are you Confirm?");
}
});
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value=text.getText();
JLabel label1=new JLabel("Welcome: "+value);
JPanel pan=new JPanel();
pan.add(label1);
JFrame frame1 = new JFrame();
frame1.setVisible(true);
frame1.add(pan);
frame1.setSize(250,100);

}
});
}
public static void main(String arg[]){
MoveFrame frame=new MoveFrame();
frame.setSize(300,100);
frame.setVisible(true);
}
}

Thanks

July 9, 2009 at 9:19 PM

Hi rose india,

The code which u have given is very helpful.........Thnaks mate, u have decreased all my stress.....thanks a lot

August 16, 2012 at 4:50 PM

hi how to navigate from one panel to another panel by clicking a button. Eg: there are 2 buttons in main frame. register train_list

when i click train_list It has to open new panel train list and has to hide the home panel. Then in the train list panel there is a back button. When I press back button, It has to go to the home panel. Please tell me how to do this









Related Tutorials/Questions & Answers:
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... this task in swings or applet......... i have gone through one example of login
another frame by using awt or swings
another frame by using awt or swings  how to connect one frame to another frame by using awt or swings
Advertisements
one frame update another frame
one frame update another frame  How do I make a link or form in one frame update another frame
how to create frame in swings
how to create frame in swings  how to create frame in swings
frame update another frame.
frame update another frame.   How do I make a link or form in one frame update another frame
Drag and Drop components from one frame to another frame
Drag and Drop components from one frame to another frame... button etc.) from one frame to another frame. In this code we have used..., user can drag and drop component from one to another frame. Download Source
Show a hidden frame previously from another from
Show a hidden frame previously from another from  How can i show a hidden frame previously by this code: jframe_name.hide(); and make it visible from another frame i'm waiting for the answer, and i'll be thankfull
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 can i close particular frame in swings - Java Beginners
how can i close particular frame in swings  Hi, I want to know, how can we close a particular frame when mulitple frames are appearing as output... on second frame close button, it should only get close....iam trying this in swings
FRAME
FRAME  WHILE I'M RUNNINGFILE OF A GUI PROGRAMME(JDBC CONNECTION) INSTEAD OF OUTPUT FRAME ONLY TWO BLANK FRAMES ARE GETTING DISPLAYD... CAN ANYONE HELP ME TO SOLVE DS PROBLEM
FRAME
FRAME  WHILE I'M RUNNINGFILE OF A GUI PROGRAMME(JDBC CONNECTION) INSTEAD OF OUTPUT FRAME ONLY TWO BLANK FRAMES ARE GETTING DISPLAYD... CAN ANYONE HELP ME TO SOLVE DS PROBLEM
frame
frame  how to creat a frame in java   Hi Friend, Try the following code:ADS_TO_REPLACE_1 import java.awt.*; import javax.swing.*; import java.awt.event.*; class RetrieveDataFromTextFields{ public static void
how to access the object of one frame on clicking a button without using this keyword
how to access the object of one frame on clicking a button without using... extends Frame { public static void main(String args[]) { Button b1...) { System.exit(0); } }); } } class Myclass extends Frame implements
How to close a frame on action event of a button from a different class ?
How to close a frame on action event of a button from a different class ?  How to close a frame on action event of a button from a different class... was opened when I had press first jbutton from control-frame) when I press second
I want display frame in another frame - Java Beginners
I want display frame in another frame  Hi all, this is available... in left side uses link if i click this link then open the page in another frame... the page into other frame then you have to create another frame to be shown
how to output text from comboBox from first frame to textField on the second frame? please help me.. thank you in advance..
how to output text from comboBox from first frame to textField on the second frame? please help me.. thank you in advance..  how to output text from comboBox from first frame to textField on the second frame? please help me
How to make frame of the picture, make frame of the picture, frame of the picture
How to make frame of the picture       This is about a frame example that has been made by some steps... by the Polygonal lasso tool (L key). Inverse: Go to Select menu > Apply Inverse (Shift
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
how to pass a string from one class to another
how to pass a string from one class to another  hi all, Good morning... 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 can i close a frame. - Java Beginners
how can i close a frame.  Hi, My question is how can we close a frame when an action is taken......For example let us think that we have a frame and in that table is displayed and one button is added to that frame
Calling awt Frame methods from subclass
Calling awt Frame methods from subclass  Calling awt Frame methods from subclass
How to navigate from one jsf to another in eclipse
How to navigate from one jsf to another in eclipse  Hi there is my...; <from-view-id>/JSF/UserDetail.jsp</from-view-id> <navigation-case> <from-outcome>success</from-outcome> <
pass data from java frame to file
pass data from java frame to file  i want to write the data to file, and data must be copy from java frame java frame contains 7-8 labels n below that 1 table. i want store all this data to 1 file. plz help me
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... ); } public void actionPerformed(ActionEvent e) { Chooser frame = new Chooser
how to add panel inside frame?
how to add panel inside frame?  I prepared a Frame with two labels and text fields and one button.when ever user clicks on the button two text fields should be appear(those text fields should be added to the panel) .I want
how to call a frame having threading concept
how to call a frame having threading concept   i hav a frame having buttton on it .on click event of the button ,i want to call another frame which... of that frame ,frame is displaying but no other content. that frame contains
how to print JInternal frame component ?
how to print JInternal frame component ?  hello sir, i devalop a swing application .but problem is that how display report & print it. some data prefech from database & keep to jtable but how it is print with table
How to center a frame
How to center a frame In this tutorial, you will learn how to center a frame on screen. A Frame is a top-level window having a title and a border and its... and minimize also. Here we are going to center the frame on the screen
Show Addition, Subtraction, Intersection, Exclusive OR on one frame
illustrates you how to show Addition, Subtraction, Intersection, ExclusiveOR on one frame... Show Addition, Subtraction, Intersection, Exclusive OR on one frame... the functions on one frame. Two classes Rectangle2D and Ellipse2D are used which
Show Addition, Subtraction, Intersection, Exclusive OR on one Frame
illustrates you how to show Addition, Subtraction, Intersection, ExclusiveOR on one... the functions on one frame. Two classes Rectangle2D and Ellipse2D are used... Show Addition, Subtraction, Intersection, Exclusive OR on one
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
link to other frame - Applet
link to other frame  how a button to open to another frame? and the frame can keyin the data and it can show at the previous frame
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
how to set a image in frame? - Swing AWT
how to set a image in frame?  how to set a image in frame using swing
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...; } } //Another class Class2. public class Class2 { public static void main(String
How to Synchronize the Entire collection Frame Work?
How to Synchronize the Entire collection Frame Work?  How to Synchronize the Entire collection Frame Work?   I Think We must implement the Through Sub Interfaces of Collection Frame work
How to Create Button on Frame
How to Create Button on Frame     ...; frame the topic of Java AWT package. In the section, from the generated output... the created object from the setLayout() method of the Frame class.ADS_TO_REPLACE_2 Here
billing frame
billing frame  how to generate billing frame using swing which contain sr. no, name of product, quantity, price & total
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
How to design a frame of the picture.
How to design a frame of the picture.       This is a picture frame example, it will help you to make a picture frame easily because it has some simple steps. If you want
how to call a frame having threading concept
how to call a frame having threading concept   i hav a frame having buttton on it .on click event of the button ,i want to call another frame which... of that frame ,frame is displaying but no other content. that frame contains
panel and frame
panel and frame  What is the difference between panel and frame
Java Frame
Java Frame  What is the difference between a Window and a Frame
How to make non resizable frame in Swing?
How to make non resizable frame in Swing?  I want code for making JFrame no re-sizable in the Swing based desktop application. Share me the code for this purpose. Thanks   Hi, Please check the tutorial Making a Frame
how display jsp frame - Java Beginners
how display jsp frame  Hi all, I am creating two jsp in frame... in another frame,you have to use target attribute of tag in your footer.jsp.... giving link in footer.jsp file this link will be display.but not opn another
frame generation
frame generation  Hi I wnat to genarate one frame with two tabs working ,production..and I want two radiobuttons sector ,others in the frames..based on the tab selection I want to clikc the radio button..when i ckick the radio
how to use one form out of multiple form from one jsp to another jsp
how to use one form out of multiple form from one jsp to another jsp  Hi All. please give me your valuable advise for below requirement.. I have... one form from abc.jsp as it is to another .jsp(say def.jsp).Your advise
How to create CheckBox On frame
How to create CheckBox On frame     ... will learn how to create CheckBox on the frame. In the Java AWT, top-level windows... can learn in very efficient manner. In this section, you will see how to create
how can i print the selected content of a frame
how can i print the selected content of a frame  hello sir, I am designing a bill calculate program. I want to print the bill in crystal form. I want to skip all the text fields shapes and all the button from the frame.. but all
Creating a Frame
Creating a Frame : Swing Tutorials       This program shows you how to create a frame in Java Swing... and adding it to the container one by one. The frame initially are not visible

Ads