Share on Google+Share on Google+

mohammed afsar
how to go from one frame to another frame in swings
3 Answer(s)      7 years ago
Posted in : Java Beginners

Ads

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
one frame update another frame
one frame update another frame  How do I make a link or form in one frame update another frame
Advertisements
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
how to create frame in swings
how to create frame in swings  how to create frame in swings
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...;One frame has five component, user can drag and drop component from one
frame update another frame.
frame update another frame.   How do I make a link or form in one frame update another frame
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: import java.awt.*; import javax.swing.*; import java.awt.event.*; class RetrieveDataFromTextFields{ public static void main(String[] args
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
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 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
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... key). Inverse: Go to Select menu > Apply Inverse (Shift + Ctrl + I
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 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
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 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 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 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> <
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
Calling awt Frame methods from subclass
Calling awt Frame methods from subclass  Calling awt Frame methods from subclass
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
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
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
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
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 set a image in frame? - Swing AWT
how to set a image in frame?  how to set a image in frame using swing
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads