A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Swing / AWT / SWT
Author
Redirecting of one frame to another frame
Ahesanali Khanusiya
Greenhorn
Joined: Jul 15, 2010
Posts: 11
posted
Jul 21, 2010 00:28:34
0
when I click any
JButton
than I want redirect one frame to another frame how its possible can you explain with example....
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
Jul 21, 2010 01:04:50
0
redirect what?
Ahesanali Khanusiya
Greenhorn
Joined: Jul 15, 2010
Posts: 11
posted
Jul 21, 2010 01:40:47
0
if i click button in swing and i want go other page of swing than how its possible.....
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
I like...
posted
Jul 21, 2010 01:50:18
0
Use a
CardLayout
.
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions
How To Answer Questions
Petar Thomas
Ranch Hand
Joined: Oct 11, 2009
Posts: 234
posted
Jul 22, 2010 08:00:00
0
What does mean "to redirect a frame" ?
Maybe then this is "redirecting a JPanel", not "a frame"?
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class Test { JFrame frame; JPanel one, two; Test(){ frame = new JFrame(); one = new JPanel(); JLabel l1 = new JLabel("one"); JButton b1 = new JButton("hop to two"); b1.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { frame.setContentPane(two); two.revalidate(); } }); one.add(l1); one.add(b1); two = new JPanel(); JLabel l2 = new JLabel("two"); JButton b2 = new JButton("hop to one"); b2.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { frame.setContentPane(one); one.revalidate(); } }); two.add(l2); two.add(b2); frame.setContentPane(one); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ public void run(){ new Test(); } }); } }
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Redirecting of one frame to another frame
Similar Threads
accessing frame contents
How to access nested frames with the frame name or id ?
Frame
Two JFrames...
How to show Modelless Frame
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter