<Swing Dev> JFrame whose content changes as we click on the different buttons?
Alexander Scherbatiy
alexandr.scherbatiy at oracle.com
Wed Mar 27 08:35:21 UTC 2013
Try to ask the question on the Java Swing forum first:
https://forums.oracle.com/forums/forum.jspa?forumID=950
Thanks,
Alexandr.
On 3/26/2013 7:44 PM, Norah Jones wrote:
> I am using Java's Swing here to make a UI application. I have a created a JFrame, with some buttons. When I click on this button, I want a new JFrame with some different content at this place. However, I do not want a new JFrame to load here.
> One approach, I know is of setting the visbility of the second JFrame to be True in the actionPerformed(ActionEvent obj) method of the button in the first JFrame. But it again loads a new JFrame and I don't want that.
>
> public class FirstUI extends JFrame {
> JButton but1;
> public FirstUI(){
> but1= new JButton("Click here");
> add(but1);
>
> XYZ obj= new XYZ():
> but1.addActionListener(obj);
> }
>
> public class XYZ implements ActionListener{
> public void actionPerformed(ActionEvent obj1){
>
> // WHAT TO DO HERE
> }
> }
> }
>
> I only want a single JFrame whose content changes as we click on different buttons. How can I achieve that ?
>
>
More information about the swing-dev
mailing list