User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 391,582 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,664 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 2909 | Replies: 9
Reply
Join Date: Oct 2004
Posts: 5
Reputation: mmr is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mmr mmr is offline Offline
Newbie Poster

Java Internal frames

  #1  
Oct 6th, 2004
Hi All,

I am working with Internal Frames. I used JDesktopPane and added 2 frames to it. I made one frame visible and the other was setVisible(false). This happens when I first run the program(Only first frame appearing). Now, what I want is to make the second frame visible, when I click a button on the first frame. Can you please help me out.

Thank you
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2004
Posts: 604
Reputation: freesoft_2000 is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 6
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: Java Internal frames

  #2  
Oct 6th, 2004
hi everyone,
use the setVisible(true) method of theJInternalFrame class.

Richard west
Reply With Quote  
Join Date: Sep 2004
Posts: 35
Reputation: tigerxx is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
tigerxx tigerxx is offline Offline
Light Poster

Re: Java Internal frames

  #3  
Oct 6th, 2004
Originally Posted by mmr
Hi All,

I am working with Internal Frames. I used JDesktopPane and added 2 frames to it. I made one frame visible and the other was setVisible(false). This happens when I first run the program(Only first frame appearing). Now, what I want is to make the second frame visible, when I click a button on the first frame. Can you please help me out.

Thank you

u just add it to container of(ie,desktop pane) main frame ie;window of ur app and make it setVisible(true)
so
wer u r buton is now in main frame or in first internal frame?
if it's in main frame
i think cod will be like this
********************************************
JFrame a= new JFrame("Main Window");
JInternalFrame f1 = new JInternalFrame();
JInternalFrame f2 = new JInternalFrame();
a.setContentPane(desktopPane);
Container c = getContentPane();
now
c.add(f1);
c.add(f2);
c.add(btn)
now add actionlistener for btn
f1.setVisible(true);
f2.setVisible(false);
now in action performed of btn
add

f2.setVisible(true);
************************************
if btn in first frame the whole thing will change
please sepecify that also
if u want pls snd mails to jijoy18@yahoo.com
pls feel free to ask qstns.
Reply With Quote  
Join Date: Oct 2004
Posts: 5
Reputation: mmr is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mmr mmr is offline Offline
Newbie Poster

Re: Java Internal frames

  #4  
Oct 12th, 2004
Hi tigerXX

Thanks for the reply. As you mentioned, the button is in the 1st Internal frame and there comes the problem for me.
Reply With Quote  
Join Date: Sep 2004
Posts: 35
Reputation: tigerxx is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
tigerxx tigerxx is offline Offline
Light Poster

Re: Java Internal frames

  #5  
Oct 13th, 2004
then u should be adding the button to the container of the 1st internal frame
and in the actionperfromed of the button please add the code i
specified.
Reply With Quote  
Join Date: Jul 2003
Location: Bamberg, Germany
Posts: 117
Reputation: Iron_Cross is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 2
Iron_Cross's Avatar
Iron_Cross Iron_Cross is offline Offline
Junior Poster

Re: Java Internal frames

  #6  
Oct 14th, 2004
So long as you have an instance of the second internal frame in the class with the listeners it shouldn't be that hard. If worste comes to worste make the instance of the second internal frame static.
Also could you post some of your code, or explain why you're having such a hard time with this problem.
elitehackers.info
Today's Penny-Arcade!
Pain is weakness leaving the body!
Reply With Quote  
Join Date: Sep 2004
Posts: 35
Reputation: tigerxx is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
tigerxx tigerxx is offline Offline
Light Poster

Re: Java Internal frames

  #7  
Oct 14th, 2004
hi mmr

i have a piece of code for u
/************************************************/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class Test extends JFrame implements ActionListener {

JInternalFrame f1 = new JInternalFrame("Frame1");
JInternalFrame f2 = new JInternalFrame("Frame2");
Container cont;
JButton jBtn = new JButton("Click");
public Test(){
cont = this.getContentPane();
cont.setLayout(new FlowLayout());
cont.add(f1);
cont.add(f2);
Container co = f1.getContentPane();
co.setLayout(new FlowLayout());
co.add(jBtn);
f1.setVisible(true);
f1.setBounds(0,0,100,100);
f2.setVisible(false);
f2.setBounds(100,100,50,50);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setBounds(0,0,400,400);
setVisible(true);
jBtn.addActionListener(this);
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource()==jBtn){
cont.add(f2);
f2.setVisible(true);
cont.add(new JLabel("Second Frame is Visible NOW"));
}
}
public static void main(String args[]){
new Test();
}


}
/***************************************************/
try this code and send me reply
i think this is ur requirement
if not plz be more specific
best luck
plz be feel free to ask qstns
bye
Reply With Quote  
Join Date: Oct 2004
Posts: 5
Reputation: mmr is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mmr mmr is offline Offline
Newbie Poster

Re: Java Internal frames

  #8  
Oct 15th, 2004
Hi tigerXX

Thanks for the reply. That works. I used desktop pane and added 2 internal frames to it. But now I understood. Thank you.
Reply With Quote  
Join Date: Oct 2004
Posts: 5
Reputation: mmr is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mmr mmr is offline Offline
Newbie Poster

Re: Java Internal frames

  #9  
Oct 15th, 2004
Originally Posted by mmr
Hi tigerXX

Thanks for the reply. That works. I used desktop pane and added 2 internal frames to it. But now I understood. Thank you.

Hi TigerXX,

But what happens if we use desktop pane??? How should we manage?
Reply With Quote  
Join Date: Sep 2004
Posts: 35
Reputation: tigerxx is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
tigerxx tigerxx is offline Offline
Light Poster

Re: Java Internal frames

  #10  
Oct 17th, 2004
Originally Posted by mmr
Hi TigerXX,

But what happens if we use desktop pane??? How should we manage?


u can use it bye

set
this.setContentPane(new JDesktopPane());
remaining everything as i have mentioned like above
thnkx............
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 10:55 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC