| | |
Java Internal frames
![]() |
•
•
Join Date: Oct 2004
Posts: 5
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Sep 2004
Posts: 35
Reputation:
Solved Threads: 0
•
•
•
•
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
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.
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.
Also could you post some of your code, or explain why you're having such a hard time with this problem.
•
•
Join Date: Sep 2004
Posts: 35
Reputation:
Solved Threads: 0
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
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
![]() |
Similar Threads
- Internal frames (Java)
Other Threads in the Java Forum
- Previous Thread: hey guys; having some trouble with this program i'm writing
- Next Thread: Java buildfile (need help)
| Thread Tools | Search this Thread |
2dgraphics 3d @param affinetransform android api apple applet application arc arguments array arrays automation banking binary binarytree bluetooth chatprogramusingobjects class client code color compare component count database derby design detection eclipse eclipsedevelopment encryption error fractal game givemetehcodez graphics gridlayout gui guitesting helpwithhomework html ide if_statement image integer interface j2me java java.xls javadesktopapplications javaprojects jni jpanel julia keytool keyword linux list macintosh map method methods mobile netbeans object open-source os pong problem producer program project projectideas property read recursion reference replaysolutions rim scanner server set size sms sort sql stop string swing terminal threads transforms tree ui unicode validation web windows





