Total members 11889 |It is currently Thu Mar 28, 2024 11:23 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Hi sami and all of codemiles members,

Is there a standard way to move between frames within a single application, if there exist please give me an example?

thank you




Author:
Newbie
User avatar Posts: 6
Have thanks: 0 time

Mohamed Alzahar wrote:
Hi sami and all of codemiles members,

Is there a standard way to move between frames within a single application, if there exist please give me an example?

thank you

What Do u mean to move between Frame. In Java u can open and close frames and the application will still be running !! :roll:

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

suppose you develop an application that contain multiple JFrame classes and one Main class, and each JFrame class contain two buttons labled as Next and Previous:
public class Main{
private JFrame1 f1;
private JFrame2 f2;
private JFrame3 f3;
private JFrame4 f4;

public static void main(String [] args)
{
f1=new JFrame1();
f1.show();
}

In the previous code you create an instance from f1 and f1 currently on your screen that display a simple frame contain Next and Previous buttons,

The Challange here "My question ", how you can link Next button using actionPerformed to display f2 and Previous button using the actionPerformed to display f3?


If the above code not correct send the correct code but consider my question

salam


}


Author:
Newbie
User avatar Posts: 6
Have thanks: 0 time

Oh ,First of all using show() is not good , Because Java Designers noticed problems in some cases. you can use setVisible(true) to show a frame and setVisible(false) to hide a frame and use dispose() function to close the frame (remove it from the memory ) .
well using the ActionListener implementation you will write
Code:
   next.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                    setVisible(false); // for the current frame
                   if(nextframe!=null)
                    nextframe.setVisible(true); // for the next frame
                }
            }
        });

so i mean u will take a reference to the next frame for each frame
Code:
public class Main{
private myFrame f1;
private myFrame f2;
private myFrame f3;
private myFrame f4;

public static void main(String [] args)
{
f4=new myFrame(null);
f3=new myFrame(f4);
f2=new myFrame(f3);
f1=new myFrame(f2);



f1.show();
}



i hope i helped u ! :mrgreen:

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 4 posts ] 

  Related Posts  to : Moving between frames
 moving glasspane between frames     -  
 moving files in php     -  
 HOW TO KEEP OBJECT MOVING FOLLOW.     -  
 Moving Background in flash     -  
 Create a moving text banner     -  
 moving file with copy() function in php     -  
 Javascript Code For Moving Images On Click Of A Button     -  
 a moving graph sortof widget build using Swing     -  



Topic Tags

Java Swing
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com