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() {
	setLayout(new FlowLayout());

	Dimension dim = new Dimension(DIM_X, DIM_Y);

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

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

	toggleButton = new JButton("toggle");

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

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

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

it helps me to solve my other problem.


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.