I have 2 frames (classes exactly) customer & items...

when a button clicked (button 'BUY') on customer frame it navigates to items frame.
mean time i made customer frame customer.setEnabled(false) .
i called to item frame by simply creating an object of item class.

then , when i coming back to customer frame from item frame.. (i can't simply create an object, i am recalling the disabled frame..) so i have to make customer.setEnabled(true)

how can i do it.....?

i simply called customer.setEnabled(true) with in the item class.
it doesn't work.

please help...

1) Have you considered doing something like this:

package snip.swing.frame;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Example extends JFrame implements ActionListener {
    /** Static data */
    private static final int DIM_X = 300;
    private static final int DIM_Y = 300;
    private static final String TITLE = "Example";

    /** 1-customers panel active */
    /** 2-items panel active */
    private static int state = 1;

    /** Components */
    private JPanel cPanel; // Customers panel
    private JLabel cLabel;
    private JPanel iPanel; // Items panel
    private JLabel iLabel;
    private JButton toggleButton;

    public Example() {
	setTitle(TITLE);
	setLayout(new FlowLayout());

	Dimension dim = new Dimension(DIM_X, DIM_Y);
	setSize(dim);

	cPanel = new JPanel();
	cLabel = new JLabel("Panel: Customers is now visible");
	cPanel.add(cLabel);
	/* other components related to this panel go here */
	this.add(cPanel);
	cPanel.setVisible(true);

	iPanel = new JPanel();
	iLabel = new JLabel("Panel: Items is now visible");
	iPanel.add(iLabel);
	/* other components related to this panel goes here */
	this.add(iPanel);
	iPanel.setVisible(false);

	toggleButton = new JButton("toggle");
	toggleButton.addActionListener(this);
	add(toggleButton);
    }

    @Override
    public void actionPerformed(ActionEvent ae) {
	/** Alternate views when pressing the button */
	System.out.println("Action");
	if (state == 1) {
	    state = 2;
	    cPanel.setVisible(false); /* make customers panel invisible */
	    iPanel.setVisible(true);
	} else {
	    state = 1;
	    iPanel.setVisible(false); /* make items panel invisible */
	    cPanel.setVisible(true);
	}
    }

    public static void main(String args[]) {
	Example e = new Example();
	e.setVisible(true);
    }
}

You can have one frame, with two different panels: customers and items. The two panels will "share" the same object and constructs as the main frame, but will be able to act individually.
Help: google "JPanel tutorial"

2) Instead setEnabled, you cand try setVisible

Thanx
it helps me to solve my other problem.

pawan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.