Sample code in AWT:
-------------------

import java.awt.*;

class Try {
public static void main(String[] args)
{
Frame frame = new Frame();
Panel panel = new Panel();
Button button = new Button("Click");
panel.add(button);
panel.setEnabled(false);
frame.add(panel);
frame.setVisible(true);
frame.pack();
}
}

By executing the above code the button in the panel gets disabled.

Sample code in Swing:
---------------------
import javax.swing.*;

class Try {
public static void main(String[] args)
{
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JButton button = new JButton("Click");
panel.add(button);
panel.setEnabled(false);
frame.getContentPane().add(panel);
frame.setVisible(true);
frame.pack();
}
}

By executing the above code the button in the panel does not get disabled.